mirror of
https://github.com/0glabs/0g-storage-node.git
synced 2024-11-15 12:35:18 +00:00
4eb2a50b0e
* Use inner lock in storage.
* Remove mut.
* Remove async lock for storage.
* Fix tests and warnings.
* Use spawn_blocking for storage task.
* Fix clippy.
* Finalize the new tx at last.
* Revert "Finalize the new tx at last."
This reverts commit b56ad5582d
.
* Wait for old same-root txs to finalize.
* Use async storage in miner.
* Update rust version to 1.79.0.
* Use Vec to avoid stack overflow.
* Fix unused warning.
* Fix clippy.
* Fix test warning.
* Fix test.
* fmt.
* Use async storage in pruner.
* nit.
38 lines
720 B
Rust
38 lines
720 B
Rust
#![allow(unsafe_code)]
|
|
|
|
use crate::hash::{Algorithm, Hashable};
|
|
use std::slice;
|
|
|
|
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Default, Debug)]
|
|
pub struct Item(pub u64);
|
|
|
|
impl AsRef<[u8]> for Item {
|
|
fn as_ref(&self) -> &[u8] {
|
|
unsafe { slice::from_raw_parts(&self.0 as *const u64 as *const u8, 8) }
|
|
}
|
|
}
|
|
|
|
impl PartialEq<u64> for Item {
|
|
fn eq(&self, other: &u64) -> bool {
|
|
self.0 == *other
|
|
}
|
|
}
|
|
|
|
impl From<u64> for Item {
|
|
fn from(x: u64) -> Self {
|
|
Item(x)
|
|
}
|
|
}
|
|
|
|
impl From<Item> for u64 {
|
|
fn from(val: Item) -> Self {
|
|
val.0
|
|
}
|
|
}
|
|
|
|
impl<A: Algorithm<Item>> Hashable<A> for Item {
|
|
fn hash(&self, state: &mut A) {
|
|
state.write_u64(self.0)
|
|
}
|
|
}
|