Include token owners in TransactionTokenBalances (#20642)

* Cache owners in TransactionTokenBalances

* Light cleanup

* Use return struct, and remove pub

* Single-use statements

* Why not, just do the whole crate

* Add metrics

* Make datapoint_debug to prevent spam unless troubleshooting
This commit is contained in:
Tyera Eulberg
2021-10-13 21:46:52 -06:00
committed by GitHub
parent 13462d63a2
commit e806fa6904
17 changed files with 213 additions and 137 deletions

View File

@@ -66,6 +66,7 @@ message TokenBalance {
uint32 account_index = 1;
string mint = 2;
UiTokenAmount ui_token_amount = 3;
string owner = 4;
}
message UiTokenAmount {

View File

@@ -408,6 +408,7 @@ impl From<TransactionTokenBalance> for generated::TokenBalance {
amount: value.ui_token_amount.amount,
ui_amount_string: value.ui_token_amount.ui_amount_string,
}),
owner: value.owner,
}
}
}
@@ -435,6 +436,7 @@ impl From<generated::TokenBalance> for TransactionTokenBalance {
)
},
},
owner: value.owner,
}
}
}

View File

@@ -111,6 +111,8 @@ pub struct StoredTransactionTokenBalance {
pub account_index: u8,
pub mint: String,
pub ui_token_amount: StoredTokenAmount,
#[serde(deserialize_with = "default_on_eof")]
pub owner: String,
}
impl From<StoredTransactionTokenBalance> for TransactionTokenBalance {
@@ -119,11 +121,13 @@ impl From<StoredTransactionTokenBalance> for TransactionTokenBalance {
account_index,
mint,
ui_token_amount,
owner,
} = value;
Self {
account_index,
mint,
ui_token_amount: ui_token_amount.into(),
owner,
}
}
}
@@ -134,11 +138,13 @@ impl From<TransactionTokenBalance> for StoredTransactionTokenBalance {
account_index,
mint,
ui_token_amount,
owner,
} = value;
Self {
account_index,
mint,
ui_token_amount: ui_token_amount.into(),
owner,
}
}
}