mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-14 07:26:51 +00:00
events
This commit is contained in:
@@ -97,6 +97,86 @@ pub struct OpenEvent {
|
||||
pub ts: i64,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
|
||||
pub struct CommitEvent {
|
||||
/// The authority of the commit transaction.
|
||||
pub authority: Pubkey,
|
||||
|
||||
/// The id of the block.
|
||||
pub block_id: u64,
|
||||
|
||||
/// The amount of hashpower committed.
|
||||
pub amount: u64,
|
||||
|
||||
/// The total amount of hashpower this user has committed.
|
||||
pub commitment: u64,
|
||||
|
||||
/// The timestamp of the event.
|
||||
pub ts: i64,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
|
||||
pub struct UncommitEvent {
|
||||
/// The authority of the commit transaction.
|
||||
pub authority: Pubkey,
|
||||
|
||||
/// The id of the block.
|
||||
pub block_id: u64,
|
||||
|
||||
/// The amount of hashpower committed.
|
||||
pub amount: u64,
|
||||
|
||||
/// The total amount of hashpower this user has committed.
|
||||
pub commitment: u64,
|
||||
|
||||
/// The timestamp of the event.
|
||||
pub ts: i64,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
|
||||
pub struct DepositEvent {
|
||||
/// The authority of the commit transaction.
|
||||
pub authority: Pubkey,
|
||||
|
||||
/// The id of the block.
|
||||
pub block_id: u64,
|
||||
|
||||
/// The amount of ORE collateral deposited.
|
||||
pub amount: u64,
|
||||
|
||||
/// The total amount of ORE this user has deposited as collateral.
|
||||
pub capacity: u64,
|
||||
|
||||
/// The timestamp of the event.
|
||||
pub ts: i64,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
|
||||
pub struct WithdrawEvent {
|
||||
/// The authority of the commit transaction.
|
||||
pub authority: Pubkey,
|
||||
|
||||
/// The id of the block.
|
||||
pub block_id: u64,
|
||||
|
||||
/// The amount of ORE collateral withdrawn.
|
||||
pub amount: u64,
|
||||
|
||||
/// The total amount of ORE this user has deposited as collateral.
|
||||
pub capacity: u64,
|
||||
|
||||
/// The timestamp of the event.
|
||||
pub ts: i64,
|
||||
}
|
||||
|
||||
event!(SwapEvent);
|
||||
event!(RewardEvent);
|
||||
event!(OpenEvent);
|
||||
event!(CommitEvent);
|
||||
event!(DepositEvent);
|
||||
event!(WithdrawEvent);
|
||||
event!(UncommitEvent);
|
||||
|
||||
@@ -94,5 +94,15 @@ pub fn process_commit(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResul
|
||||
// Update block.
|
||||
permit.amount += amount;
|
||||
|
||||
// Emit event.
|
||||
CommitEvent {
|
||||
authority: *signer_info.key,
|
||||
block_id: block.id,
|
||||
amount,
|
||||
commitment: permit.amount,
|
||||
ts: clock.unix_timestamp,
|
||||
}
|
||||
.log_return();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -63,5 +63,15 @@ pub fn process_deposit(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResu
|
||||
amount,
|
||||
)?;
|
||||
|
||||
// Emit event.
|
||||
DepositEvent {
|
||||
authority: *signer_info.key,
|
||||
block_id: block.id,
|
||||
amount,
|
||||
capacity: stake.capacity,
|
||||
ts: clock.unix_timestamp,
|
||||
}
|
||||
.log_return();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -59,5 +59,15 @@ pub fn process_uncommit(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRes
|
||||
permit_info.close(signer_info)?;
|
||||
}
|
||||
|
||||
// Emit event.
|
||||
UncommitEvent {
|
||||
authority: *signer_info.key,
|
||||
block_id: block.id,
|
||||
commitment: permit.amount,
|
||||
amount,
|
||||
ts: clock.unix_timestamp,
|
||||
}
|
||||
.log_return();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -53,5 +53,15 @@ pub fn process_withdraw(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRes
|
||||
stake_info.close(signer_info)?;
|
||||
}
|
||||
|
||||
// Emit event.
|
||||
WithdrawEvent {
|
||||
authority: *signer_info.key,
|
||||
block_id: stake.block_id,
|
||||
amount,
|
||||
capacity: stake.capacity,
|
||||
ts: clock.unix_timestamp,
|
||||
}
|
||||
.log_return();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user