mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-31 23:26:47 +00:00
le_bytes
This commit is contained in:
@@ -97,7 +97,7 @@ pub(crate) fn validate_hash(
|
|||||||
let hash_ = hashv(&[
|
let hash_ = hashv(&[
|
||||||
current_hash.as_ref(),
|
current_hash.as_ref(),
|
||||||
signer.as_ref(),
|
signer.as_ref(),
|
||||||
nonce.to_be_bytes().as_slice(),
|
nonce.to_le_bytes().as_slice(),
|
||||||
]);
|
]);
|
||||||
if sol_memcmp(hash.as_ref(), hash_.as_ref(), 32) != 0 {
|
if sol_memcmp(hash.as_ref(), hash_.as_ref(), 32) != 0 {
|
||||||
return Err(OreError::InvalidHash.into());
|
return Err(OreError::InvalidHash.into());
|
||||||
@@ -129,7 +129,7 @@ mod tests {
|
|||||||
let h2 = hashv(&[
|
let h2 = hashv(&[
|
||||||
h1.to_bytes().as_slice(),
|
h1.to_bytes().as_slice(),
|
||||||
signer.to_bytes().as_slice(),
|
signer.to_bytes().as_slice(),
|
||||||
nonce.to_be_bytes().as_slice(),
|
nonce.to_le_bytes().as_slice(),
|
||||||
]);
|
]);
|
||||||
let res = validate_hash(h1, h2, signer, nonce, difficulty);
|
let res = validate_hash(h1, h2, signer, nonce, difficulty);
|
||||||
assert!(res.is_ok());
|
assert!(res.is_ok());
|
||||||
@@ -155,7 +155,7 @@ mod tests {
|
|||||||
let h2 = hashv(&[
|
let h2 = hashv(&[
|
||||||
h1.to_bytes().as_slice(),
|
h1.to_bytes().as_slice(),
|
||||||
signer.to_bytes().as_slice(),
|
signer.to_bytes().as_slice(),
|
||||||
nonce.to_be_bytes().as_slice(),
|
nonce.to_le_bytes().as_slice(),
|
||||||
]);
|
]);
|
||||||
let res = validate_hash(h1, h2, signer, nonce, difficulty);
|
let res = validate_hash(h1, h2, signer, nonce, difficulty);
|
||||||
assert!(res.is_err());
|
assert!(res.is_err());
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ fn find_next_hash(hash: KeccakHash, difficulty: KeccakHash, signer: Pubkey) -> (
|
|||||||
next_hash = hashv(&[
|
next_hash = hashv(&[
|
||||||
hash.to_bytes().as_slice(),
|
hash.to_bytes().as_slice(),
|
||||||
signer.to_bytes().as_slice(),
|
signer.to_bytes().as_slice(),
|
||||||
nonce.to_be_bytes().as_slice(),
|
nonce.to_le_bytes().as_slice(),
|
||||||
]);
|
]);
|
||||||
if next_hash.le(&difficulty) {
|
if next_hash.le(&difficulty) {
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user