-
Notifications
You must be signed in to change notification settings - Fork 14
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
chore: add cap as storage service for claimable messages #62
Conversation
|
||
s.add_claimable_message(ClaimableMessage { | ||
ic_kit::ic::spawn(async move { |
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.
there is a insert_sync
which guarantees finality by doing the spawn for you
https://github.com/Psychedelic/cap/blob/main/sdk/rust/src/transaction/insert.rs#L126
} | ||
|
||
pub async fn register_messages() { | ||
let mut pending_registrations = STATE.with(|s| s.get_all_claimable_messages()); |
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.
Then we can use the insert_many_sync
which takes in a iterator of pending_registrations
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.
theres no need for this now, every message is going to be processed sync and the pending ones are handled by cap_cdk.
STATE ClaimableAssets its only used during pre and post upgrade now.
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.
Refer to my comment about flushing below
fn to_cap_event(&self) -> IndefiniteEvent; | ||
} | ||
|
||
impl ToEvent for ClaimableMessage { |
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.
impl ToEvent for ClaimableMessage { | |
impl ToCapEvent for ClaimableMessage { |
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, didnt commit this as commit suggestion
because im importing in different files also, so I updated all at once.
}); | ||
|
||
// flush STATE claimable messages queue | ||
register_messages().await |
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.
Similarly, if we use cap insert sync it handles the flushing mechanism
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.
LGTM, could we link an issue to this at least to explain why we are doing this
69c0b08
to
765207d
Compare
Description
Changes:
remove_claimable_asset
since now they are stored in CAPget_claimable_messages
because that query now needs to be perform to CAP root.ProxyState.unclaimed_messages.