feat(zcoin): impl balance event streaming#2076
Conversation
onur-ozkan
left a comment
There was a problem hiding this comment.
Thanks for the work!
Some notes from my end:
mm2src/coins/z_coin.rs
Outdated
| let (z_balance_event_sender, z_balance_event_handler) = match get_z_balance_event_handlers(self.ctx) { | ||
| Some((sender, receiver)) => (Some(sender), Some(receiver)), | ||
| None => (None, None), | ||
| }; |
There was a problem hiding this comment.
Nit: You can handle ctx.event_stream_configuration directly here without needing to return Option in get_z_balance_event_handlers, or even better remove get_z_balance_event_handlers entirely?
| pub enum ZBalanceEvent { | ||
| Triggered, | ||
| } |
There was a problem hiding this comment.
if it's going to be only this "Triggered" value for event handlers, you can use () instead of an enum type.
| while let Some(event) = bal.next().await { | ||
| match event { |
onur-ozkan
left a comment
There was a problem hiding this comment.
Thanks for the fixes. We can merge this once the @KomodoPlatform/qa team confirms this is working as expected on Native and WASM platforms.
| const EVENT_NAME: &'static str = "COIN_BALANCE"; | ||
| const ERROR_EVENT_NAME: &'static str = "COIN_BALANCE_ERROR"; |
There was a problem hiding this comment.
Note for the future development: We may need to maintain all the available event names from a single source without needing to type them manually for each implementation.
mariocynicys
left a comment
There was a problem hiding this comment.
Just one nit, LGTM otherwise.
| z_spending_key, | ||
| z_tx_prover: Arc::new(z_tx_prover), | ||
| light_wallet_db, | ||
| consensus_params: self.protocol_info.consensus_params, |
There was a problem hiding this comment.
this clone is redundant? no?
498880d
|
@borngraced please resolve conflicts that appeared due to merging the tx history PR. |
* dev: feat(zcoin): balance event streaming (GLEECBTC#2076) feat(zcoin): tx_history support for WASM target (GLEECBTC#2077)
Implement balance event streaming for
zcoinforNativeandWASMtargetAfter each update to the wallet database with a new block, we check for any transactions within the block. If transactions are detected, we initiate a balance event notification to retrieve the latest balance from the database and send/update