Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Drop use of array_chunks feature from nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
tuommaki committed Jan 10, 2024
1 parent 2ce474f commit e18fb0b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 0 additions & 1 deletion crates/node/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(array_chunks)]

pub mod rpc_client;
pub mod types;
11 changes: 9 additions & 2 deletions crates/node/src/types/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,15 @@ impl From<&[u8]> for Hash {

impl From<Hash> for Message {
fn from(value: Hash) -> Self {
// Split [u8; 32] into 8 * [u8; 4]
let mut chunks = value.0.array_chunks::<4>();
let chunk_sz = HASH_SIZE/8;
let mut offset = 0;
let mut chunks = vec![];
for _ in 0..value.0.len()/chunk_sz {
chunks.push(<&[u8] as TryInto<[u8; 4]>>::try_into(&value.0[offset..offset+chunk_sz]).unwrap().clone());
offset += chunk_sz;
}

let mut chunks = chunks.iter_mut();
Message(libsecp256k1::curve::Scalar([
u32::from_be_bytes(*chunks.next().unwrap()),
u32::from_be_bytes(*chunks.next().unwrap()),
Expand Down

0 comments on commit e18fb0b

Please sign in to comment.