Skip to content

Instantly share code, notes, and snippets.

@ssbb
Created June 11, 2017 20:14
Show Gist options
  • Save ssbb/ad686284cf0344551df05f01395757f1 to your computer and use it in GitHub Desktop.
Save ssbb/ad686284cf0344551df05f01395757f1 to your computer and use it in GitHub Desktop.
fn verify<'a>(env: NifEnv<'a>, args: &[NifTerm<'a>]) -> NifResult<NifTerm<'a>> {
let block_number: u64 = try!(args[0].decode());
let header_hash: &'a str = try!(args[1].decode());
let nonce: u64 = try!(args[2].decode());
let ethash = EthashManager::new();
let result = ethash.compute_light(block_number, get_bytes_ref(header_hash), nonce);
Ok((atoms::ok(), result).encode(env))
}
fn get_bytes_ref(s: &str) -> &[u8; 32] { assert!(s.len() == 32); unsafe { &*(s.as_ptr() as *const [u8; 32]) }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment