This commit is contained in:
Hardhat Chad
2024-02-14 17:01:30 +00:00
parent f917e49b3f
commit bbc1d835ea
21 changed files with 248 additions and 171 deletions

View File

@@ -1,5 +1,7 @@
use bytemuck::{Pod, Zeroable};
use crate::impl_to_bytes;
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
pub struct Bus {
@@ -13,8 +15,4 @@ pub struct Bus {
pub available_rewards: u64,
}
impl Bus {
pub fn to_bytes(&self) -> &[u8] {
bytemuck::bytes_of(self)
}
}
impl_to_bytes!(Bus);

View File

@@ -3,6 +3,8 @@ use std::mem::transmute;
use bytemuck::{Pod, Zeroable};
use solana_program::keccak::{Hash as KeccakHash, HASH_BYTES};
use crate::impl_to_bytes;
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
pub struct Hash(pub [u8; HASH_BYTES]);
@@ -20,3 +22,5 @@ impl From<Hash> for KeccakHash {
unsafe { transmute(value) }
}
}
impl_to_bytes!(Hash);

View File

@@ -1,6 +1,8 @@
use bytemuck::{Pod, Zeroable};
use solana_program::pubkey::Pubkey;
use crate::impl_to_bytes;
use super::Hash;
#[repr(C)]
@@ -25,8 +27,4 @@ pub struct Proof {
pub total_rewards: u64,
}
impl Proof {
pub fn to_bytes(&self) -> &[u8] {
bytemuck::bytes_of(self)
}
}
impl_to_bytes!(Proof);

View File

@@ -1,6 +1,8 @@
use bytemuck::{Pod, Zeroable};
use solana_program::pubkey::Pubkey;
use crate::impl_to_bytes;
use super::Hash;
#[repr(C)]
@@ -25,8 +27,4 @@ pub struct Treasury {
pub total_claimed_rewards: u64,
}
impl Treasury {
pub fn to_bytes(&self) -> &[u8] {
bytemuck::bytes_of(self)
}
}
impl_to_bytes!(Treasury);