mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-14 07:26:51 +00:00
secure logs
This commit is contained in:
@@ -48,7 +48,9 @@ pub struct Deposit {
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
|
||||
pub struct Log {}
|
||||
pub struct Log {
|
||||
pub block_id: [u8; 8],
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
|
||||
|
||||
@@ -91,12 +91,15 @@ pub fn close(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn log(signer: Pubkey, msg: &[u8]) -> Instruction {
|
||||
let mut data = Log {}.to_bytes();
|
||||
pub fn log(signer: Pubkey, block_id: u64, msg: &[u8]) -> Instruction {
|
||||
let mut data = Log {
|
||||
block_id: block_id.to_le_bytes(),
|
||||
}
|
||||
.to_bytes();
|
||||
data.extend_from_slice(msg);
|
||||
Instruction {
|
||||
program_id: crate::ID,
|
||||
accounts: vec![AccountMeta::new(signer, false)],
|
||||
accounts: vec![AccountMeta::new(signer, true)],
|
||||
data: data,
|
||||
}
|
||||
}
|
||||
@@ -107,7 +110,7 @@ pub fn program_log(
|
||||
msg: &[u8],
|
||||
) -> Result<(), ProgramError> {
|
||||
invoke_signed(
|
||||
&log(*accounts[0].key, msg),
|
||||
&log(*accounts[0].key, block_id, msg),
|
||||
accounts,
|
||||
&crate::ID,
|
||||
&[BLOCK, &block_id.to_le_bytes()],
|
||||
|
||||
Reference in New Issue
Block a user