Skip to content

A confused point about function "mine" #8

@jie170601

Description

@jie170601

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);
    }
    ....
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions