timestamp tagging
This commit is contained in:
parent
e278c14346
commit
f60e9f2a3b
|
@ -22,6 +22,9 @@ use yellowstone_grpc_proto::geyser::subscribe_update::UpdateOneof;
|
||||||
use yellowstone_grpc_proto::geyser::{SubscribeRequest, SubscribeRequestFilterAccounts, SubscribeUpdate};
|
use yellowstone_grpc_proto::geyser::{SubscribeRequest, SubscribeRequestFilterAccounts, SubscribeUpdate};
|
||||||
use yellowstone_grpc_proto::prost::Message as _;
|
use yellowstone_grpc_proto::prost::Message as _;
|
||||||
|
|
||||||
|
|
||||||
|
const ENABLE_TIMESTAMP_TAGGING: bool = true;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
pub async fn main() {
|
pub async fn main() {
|
||||||
// RUST_LOG=info,stream_blocks_mainnet=debug,geyser_grpc_connector=trace
|
// RUST_LOG=info,stream_blocks_mainnet=debug,geyser_grpc_connector=trace
|
||||||
|
@ -71,6 +74,11 @@ pub async fn main() {
|
||||||
trace!("got account update (green)!!! {} - {:?} - {} bytes",
|
trace!("got account update (green)!!! {} - {:?} - {} bytes",
|
||||||
update.slot, account_pk, account.data.len());
|
update.slot, account_pk, account.data.len());
|
||||||
|
|
||||||
|
if ENABLE_TIMESTAMP_TAGGING {
|
||||||
|
let since_the_epoch = std::time::SystemTime::now().duration_since(std::time::SystemTime::UNIX_EPOCH).expect("Time went backwards");
|
||||||
|
info!("got account update: write_version={};timestamp_us={};slot={}", account.write_version, since_the_epoch.as_micros(), update.slot);
|
||||||
|
}
|
||||||
|
|
||||||
match parse_token(&account.data, Some(6)) {
|
match parse_token(&account.data, Some(6)) {
|
||||||
Ok(TokenAccountType::Account(account_ui)) => {
|
Ok(TokenAccountType::Account(account_ui)) => {
|
||||||
// UiTokenAccount {
|
// UiTokenAccount {
|
||||||
|
@ -89,19 +97,23 @@ pub async fn main() {
|
||||||
// close_authority: None,
|
// close_authority: None,
|
||||||
// extensions: []
|
// extensions: []
|
||||||
// }
|
// }
|
||||||
if matches!(account_ui.state, Initialized) {
|
// all different states are covered
|
||||||
let owner = Pubkey::from_str(&account_ui.owner).unwrap();
|
// is_native: both true+false are sent
|
||||||
let mint = Pubkey::from_str(&account_ui.mint).unwrap();
|
assert_eq!(account.executable, false);
|
||||||
// 6 decimals as requested
|
assert_eq!(account.rent_epoch, u64::MAX);
|
||||||
let amount = &account_ui.token_amount.amount;
|
|
||||||
// groovie wallet
|
let owner = Pubkey::from_str(&account_ui.owner).unwrap();
|
||||||
if account_ui.owner.starts_with("66fEFnKy") {
|
let mint = Pubkey::from_str(&account_ui.mint).unwrap();
|
||||||
info!("update balance for mint {} of owner {}: {}", mint, owner, amount);
|
// 6 decimals as requested
|
||||||
}
|
let amount = &account_ui.token_amount.amount;
|
||||||
token_account_by_ownermint.entry(owner)
|
// groovie wallet
|
||||||
.or_insert_with(DashMap::new)
|
if account_ui.owner.starts_with("66fEFnKy") {
|
||||||
.insert(mint, account_ui);
|
info!("update balance for mint {} of owner {}: {}", mint, owner, amount);
|
||||||
}
|
}
|
||||||
|
token_account_by_ownermint.entry(owner)
|
||||||
|
.or_insert_with(DashMap::new)
|
||||||
|
.insert(mint, account_ui);
|
||||||
|
|
||||||
}
|
}
|
||||||
Ok(TokenAccountType::Mint(mint)) => {
|
Ok(TokenAccountType::Mint(mint)) => {
|
||||||
// not interesting
|
// not interesting
|
||||||
|
@ -136,7 +148,7 @@ pub async fn main() {
|
||||||
for token_account_mint in accounts_by_mint.iter() {
|
for token_account_mint in accounts_by_mint.iter() {
|
||||||
total += 1;
|
total += 1;
|
||||||
let (owner, mint, account) = (accounts_by_mint.key(), token_account_mint.key(), token_account_mint.value());
|
let (owner, mint, account) = (accounts_by_mint.key(), token_account_mint.key(), token_account_mint.value());
|
||||||
debug!("{} - {} - {}", owner, mint, account.token_amount.ui_amount_string);
|
// debug!("{} - {} - {}", owner, mint, account.token_amount.ui_amount_string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
info!("Total owner x mint entries in cache map: {}", total);
|
info!("Total owner x mint entries in cache map: {}", total);
|
||||||
|
|
Loading…
Reference in New Issue