Last active
May 17, 2021 04:28
-
-
Save bluepnume/0d4386eff538d88098b92132db75ee85 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const addBlock = async (hashedBlock : string) => { | |
const verifiedBlock = await verifyHashAndUnpack(hashedBlock); | |
const verifiedTransactions = await asyncMap(verifiedBlock.transactions, verifySignatureAndUnpack); | |
const fullyVerifiedBlock = { | |
...verifiedBlock, | |
transactions: verifiedTransactions | |
}; | |
const headNode = root.findValueByID(fullyVerifiedBlock.parentid); | |
const hash = unpackHash(hashedBlock); | |
if (headNode && divisibleBy(hash, headNode.getValue().difficulty)) { | |
headNode.addChildNodeValue(fullyVerifiedBlock); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment