Skip to main content

heika_harvesting/
lib.rs

1//! Symbol のノードへの委任ハーベスト。合意形成には関わらない、ノードの運営のためのもの。
2
3pub mod delegation;
4pub mod harvesters_dat;
5pub mod unlocked;
6
7#[cfg(test)]
8mod testing {
9    /// 決まったバイト列を返すだけの乱数。委任の要求の使い捨ての鍵と初期化ベクトルを固定する
10    pub struct Replay<'a>(pub &'a [u8]);
11
12    impl rand_core::TryRng for Replay<'_> {
13        type Error = core::convert::Infallible;
14
15        fn try_next_u32(&mut self) -> Result<u32, Self::Error> {
16            unimplemented!("only fill_bytes is used")
17        }
18
19        fn try_next_u64(&mut self) -> Result<u64, Self::Error> {
20            unimplemented!("only fill_bytes is used")
21        }
22
23        fn try_fill_bytes(&mut self, dst: &mut [u8]) -> Result<(), Self::Error> {
24            let (head, rest) = self.0.split_at(dst.len());
25            dst.copy_from_slice(head);
26            self.0 = rest;
27            Ok(())
28        }
29    }
30
31    impl rand_core::TryCryptoRng for Replay<'_> {}
32}