-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(etl): rework etl args, add accounts selector functionality
* Get rid of any required JSON configuration for ETL * Add accounts selector functionality to ETL
- Loading branch information
1 parent
b1be37c
commit 0b371bd
Showing
10 changed files
with
170 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,5 @@ test-ledger | |
programs | ||
docker/geyser-outputs | ||
docker/solana-outputs | ||
.env | ||
snapshot |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"owners": [ | ||
"metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s", | ||
"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb", | ||
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", | ||
"CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d" | ||
], | ||
"select_all_accounts": false | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
plerkle_snapshot/src/bin/solana-snapshot-etl/accounts_selector.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
//! Copied from plerkle/src/accounts_selector.rs with some API-changing improvements. | ||
use std::collections::HashSet; | ||
use tracing::*; | ||
|
||
const fn select_all_accounts_by_default() -> bool { | ||
true | ||
} | ||
|
||
#[derive(Debug, serde::Deserialize)] | ||
pub(crate) struct AccountsSelectorConfig { | ||
#[serde(default)] | ||
pub accounts: Vec<String>, | ||
#[serde(default)] | ||
pub owners: Vec<String>, | ||
#[serde(default = "select_all_accounts_by_default")] | ||
pub select_all_accounts: bool, | ||
} | ||
|
||
impl Default for AccountsSelectorConfig { | ||
fn default() -> Self { | ||
Self { | ||
accounts: vec![], | ||
owners: vec![], | ||
select_all_accounts: select_all_accounts_by_default(), | ||
} | ||
} | ||
} | ||
|
||
#[derive(Clone)] | ||
pub(crate) struct AccountsSelector { | ||
pub accounts: HashSet<Vec<u8>>, | ||
pub owners: HashSet<Vec<u8>>, | ||
pub select_all_accounts: bool, | ||
} | ||
|
||
impl AccountsSelector { | ||
pub fn new(config: AccountsSelectorConfig) -> Self { | ||
let AccountsSelectorConfig { | ||
accounts, | ||
owners, | ||
select_all_accounts, | ||
} = config; | ||
info!( | ||
"Creating AccountsSelector from accounts: {:?}, owners: {:?}", | ||
accounts, owners | ||
); | ||
|
||
let accounts = accounts | ||
.iter() | ||
.map(|key| bs58::decode(key).into_vec().unwrap()) | ||
.collect(); | ||
let owners = owners | ||
.iter() | ||
.map(|key| bs58::decode(key).into_vec().unwrap()) | ||
.collect(); | ||
AccountsSelector { | ||
accounts, | ||
owners, | ||
select_all_accounts, | ||
} | ||
} | ||
|
||
pub fn is_account_selected(&self, account: &[u8], owner: &[u8]) -> bool { | ||
self.select_all_accounts || self.accounts.contains(account) || self.owners.contains(owner) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.