node-blockchain
node-blockchain copied to clipboard
A confused point about function "mine"
It's a good project for me who want to learn the block chain.But there's a confused point that I can't figure out,the function "mine" seems no meanings when we use the addBlock.It does not reflect the relationship between mining and block.Then I think the return value of "mine" should be nonce+solution,and assign the return value to the nonce of block.
mine(nonce: number) {
...
return nonce+solution;
...
}
addBlock(transaction: Transaction, senderPublicKey: string, signature: Buffer) {
...
if (isValid) {
const newBlock = new Block(this.lastBlock.hash, transaction);
newBlock.nonce = this.mine(newBlock.nonce);
this.chain.push(newBlock);
}
....
}