Skip to content
This repository has been archived by the owner on Oct 1, 2018. It is now read-only.

Commit

Permalink
added scrypt PoW support
Browse files Browse the repository at this point in the history
  • Loading branch information
gto90 committed Dec 13, 2017
1 parent 676247b commit c01ff88
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions BRMerkleBlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ BRMerkleBlock *BRMerkleBlockParse(const uint8_t *buf, size_t bufLen)
}

BRSHA256_2(&block->blockHash, buf, 80);
BRScrypt(&block->powHash, sizeof(block->powHash), buf, 80, buf, 80, 1024, 1, 1);
}

return block;
Expand Down Expand Up @@ -290,11 +291,11 @@ int BRMerkleBlockIsValid(const BRMerkleBlock *block, uint32_t currentTime)
else UInt32SetLE(t.u8, target >> (3 - size)*8);

for (int i = sizeof(t) - 1; r && i >= 0; i--) { // check proof-of-work
if (block->blockHash.u8[i] < t.u8[i]) break;
if (block->blockHash.u8[i] > t.u8[i]) {
if (block->powHash.u8[i] < t.u8[i]) break;
if (block->powHash.u8[i] > t.u8[i]) {
r = 0;

digi_log("invalid blockHash[%d]: %x - %x", i, block->blockHash.u8[i], t.u8[i]);
digi_log("invalid blockHash[%d]: %x - %x", i, block->powHash.u8[i], t.u8[i]);
}
}

Expand Down
1 change: 1 addition & 0 deletions BRMerkleBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ extern "C" {

typedef struct {
UInt256 blockHash;
UInt256 powHash;
uint32_t version;
UInt256 prevBlock;
UInt256 merkleRoot;
Expand Down

0 comments on commit c01ff88

Please sign in to comment.