-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(zcoin): impl balance event streaming #2076
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done thanks! :)
pub enum ZBalanceEvent { | ||
Triggered, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it's going to be only this "Triggered" value for event handlers, you can use ()
instead of an enum type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done thanks!
while let Some(event) = bal.next().await { | ||
match event { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to match the event
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one nit, LGTM otherwise.
dex_fee_addr, | ||
my_z_addr, | ||
my_z_addr_encoded, | ||
evk: ExtendedFullViewingKey::from(&z_spending_key), | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this clone is redundant? no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, thanks.
498880d
@borngraced please resolve conflicts that appeared due to merging the tx history PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
* dev: feat(zcoin): balance event streaming (KomodoPlatform#2076) feat(zcoin): tx_history support for WASM target (KomodoPlatform#2077)
Implement balance event streaming for
zcoin
forNative
andWASM
targetAfter 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