Include token owners in TransactionTokenBalances (backport #20642) (#20676)

* 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

(cherry picked from commit e806fa6904)

# Conflicts:
#	ledger/src/blockstore.rs
#	transaction-status/Cargo.toml
#	transaction-status/src/token_balances.rs

* Fix conflicts

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
This commit is contained in:
mergify[bot]
2021-10-14 16:37:35 +00:00
committed by GitHub
parent 84644ce994
commit 3fd0f45e91
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,
}
}
}