-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Actor events for the verified registry (#1456)
* verifreg-balance-event-working * allocation and allocation removed * add more info to tests * finish all events * address review * address review
- Loading branch information
1 parent
1e50065
commit 7500bab
Showing
9 changed files
with
433 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// A namespace for helpers that build and emit verified registry events. | ||
|
||
use crate::{ActorError, AllocationID}; | ||
use crate::{ClaimID, DataCap}; | ||
use fil_actors_runtime::runtime::Runtime; | ||
use fil_actors_runtime::EventBuilder; | ||
use fvm_shared::ActorID; | ||
|
||
/// Indicates a new value for a verifier's datacap balance. | ||
/// Note that receiving this event does not necessarily mean the balance has changed. | ||
/// The value is in datacap whole units (not TokenAmount). | ||
pub fn verifier_balance( | ||
rt: &impl Runtime, | ||
verifier: ActorID, | ||
new_balance: &DataCap, | ||
) -> Result<(), ActorError> { | ||
rt.emit_event( | ||
&EventBuilder::new() | ||
.typ("verifier-balance") | ||
.field_indexed("verifier", &verifier) | ||
.field("balance", new_balance) | ||
.build()?, | ||
) | ||
} | ||
|
||
/// Indicates a new allocation has been made. | ||
pub fn allocation(rt: &impl Runtime, id: AllocationID) -> Result<(), ActorError> { | ||
rt.emit_event(&EventBuilder::new().typ("allocation").field_indexed("id", &id).build()?) | ||
} | ||
|
||
/// Indicates an expired allocation has been removed. | ||
pub fn allocation_removed(rt: &impl Runtime, id: AllocationID) -> Result<(), ActorError> { | ||
rt.emit_event(&EventBuilder::new().typ("allocation-removed").field_indexed("id", &id).build()?) | ||
} | ||
|
||
/// Indicates an allocation has been claimed. | ||
pub fn claim(rt: &impl Runtime, id: ClaimID) -> Result<(), ActorError> { | ||
rt.emit_event(&EventBuilder::new().typ("claim").field_indexed("id", &id).build()?) | ||
} | ||
|
||
/// Indicates an existing claim has been updated (e.g. with a longer term). | ||
pub fn claim_updated(rt: &impl Runtime, id: ClaimID) -> Result<(), ActorError> { | ||
rt.emit_event(&EventBuilder::new().typ("claim-updated").field_indexed("id", &id).build()?) | ||
} | ||
|
||
/// Indicates an expired claim has been removed. | ||
pub fn claim_removed(rt: &impl Runtime, id: ClaimID) -> Result<(), ActorError> { | ||
rt.emit_event(&EventBuilder::new().typ("claim-removed").field_indexed("id", &id).build()?) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.