mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-28 15:11:04 +00:00
cleanup
This commit is contained in:
@@ -1,47 +0,0 @@
|
||||
use std::{fmt, mem::transmute};
|
||||
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use solana_program::keccak::{Hash as KeccakHash, HASH_BYTES};
|
||||
|
||||
use crate::impl_to_bytes;
|
||||
|
||||
/// Hash is an equivalent type to solana_program::keccak::Hash which supports bytemuck serialization.
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
|
||||
pub struct Hash(pub [u8; HASH_BYTES]);
|
||||
|
||||
impl From<KeccakHash> for Hash {
|
||||
#[inline(always)]
|
||||
fn from(value: KeccakHash) -> Self {
|
||||
unsafe { transmute(value) }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Hash> for KeccakHash {
|
||||
#[inline(always)]
|
||||
fn from(value: Hash) -> Self {
|
||||
unsafe { transmute(value) }
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Hash {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", bs58::encode(self.0).into_string())
|
||||
}
|
||||
}
|
||||
|
||||
// impl Hash {
|
||||
// pub fn difficulty(&self) -> u32 {
|
||||
// let mut count = 0;
|
||||
// for &byte in &self.0 {
|
||||
// let lz = byte.leading_zeros();
|
||||
// count += lz;
|
||||
// if lz < 8 {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// count
|
||||
// }
|
||||
// }
|
||||
|
||||
impl_to_bytes!(Hash);
|
||||
@@ -1,11 +1,9 @@
|
||||
mod bus;
|
||||
mod config;
|
||||
// mod hash;
|
||||
mod proof;
|
||||
mod treasury;
|
||||
|
||||
pub use bus::*;
|
||||
pub use config::*;
|
||||
// pub use hash::*;
|
||||
pub use proof::*;
|
||||
pub use treasury::*;
|
||||
|
||||
Reference in New Issue
Block a user