Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Genesis block doesn't follow the difficulty #53

Closed
Aminnnnn123 opened this issue Jan 3, 2022 · 2 comments
Closed

Genesis block doesn't follow the difficulty #53

Aminnnnn123 opened this issue Jan 3, 2022 · 2 comments

Comments

@Aminnnnn123
Copy link

Hey, I just wanted to test the blockchain but then I realized the genesis block's hash doesn't follow the difficulty. I tried solving it by adding this code to the createGenesisBlock() function in line 139 of blockchain.js file:
const genblock = new Block(Date.parse('2017-01-01'), [], '0');
genblock.mineBlock(this.difficulty);
return genblock;

but it didn't work. Can someone please help.

@csjoshi04
Copy link

Genesis block doesn't have to follow the difficulty, as it is the first block in the chain. Without it, a chain doesn't exist. The difficulty is to ensure that on average every 10 minutes a new block should get mined. Difficulty helps in achieving it.

@Savjee
Copy link
Owner

Savjee commented Jan 7, 2022

I agree with @csjoshi04 the genesis block shouldn't follow the current difficulty.
The Bitcoin codebase does something similar: https://github.com/bitcoin/bitcoin/blob/623745ca74cf3f54b474dac106f5802b7929503f/src/chainparams.cpp#L51

I'm closing this issue for now, but feel to reply if you have additional questions or suggestions.

@Savjee Savjee closed this as completed Jan 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants