基于以太坊发主链

视频一

视频二

视频三

 

一更改core/genesis_alloc的mainnetAllocData为想要预制的钱包余额

const mainnetAllocData = "\xf8c\xe0\x94\tq\xff3\x18\x8d@v\x8b^\x81B^\xed\xcf\xf5\xac*\xee\f\x8a\x10\xf0\xc1%\x97!\xea\x9c\x00\x00\xe0\x94\xbb\xa8\xeb,q\u028e\x87N\x1c\x8f`:\xde\f\u01830\xf2\u050a\x13\x0e\xdb\x06`\u071c\xdc\x00\x00\xe0\x94\xf5\x84\xa6\xe8\u06d2\x80\x9d\u015c\x82\x01\xd07\r\xe8{[\xd1\u058a\x15,\xf4\xe7*\x97O\x1c\x00\x00"
 
mainnetAllocData的生成是通过mkalloc读取json生成
json{格式"nonce":"0x0000000000000042","difficulty":"0x40000000","alloc":{
"f584a6e8db92809dc59c8201d0370de87b5bd1d6":{"balance":"99999000000000000000000"},"bba8eb2c71ca8e874e1c8f603ade0cc68330f2d4":{"balance":"89999000000000000000000"},"0971ff33188d40768b5e81425eedcff5ac2aee0c":{"balance":"79999000000000000000000"}
},"mixhash":"0x0000000000000000000000000000000000000000000000000000000000000000","coinbase":"0x0000000000000000000000000000000000000000","timestamp":"0x00","parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000","extraData":"0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa","gasLimit":"0x1388"}
二更改端口
1   internal/jsre/web3.js 的HttpProvider端口,rpc通信
2   cmd/utils/flags.go  的ListenPortFlag端口,p2p通信
3   node/defaults.go  的DefaultHTTPPort和DefaultWSPort 和p2p ListenAddr端口
三 更改挖矿收益 consensus/ethash/consensus.go FrontierBlockReward 和ByzantiumBlockReward 

四 清除params/bootnodes.go里面的enode

五在 core/genesis.go SetupGenesisBlock方法里打印stored
六编译执行
七 运行geth获取enode粘贴到params/bootnodes.go里面
八通过geth打印获取stored,替换params/config.go 的MainnetGenesisHash

你可能感兴趣的:(以太坊源码阅读)