4 log "github.com/sirupsen/logrus"
6 "github.com/bytom/bytom/consensus"
7 "github.com/bytom/bytom/protocol/bc"
8 "github.com/bytom/bytom/protocol/bc/types"
11 func toBCTxs(txs []*types.Tx) []*bc.Tx {
13 for _, tx := range txs {
14 bcTxs = append(bcTxs, tx.Tx)
19 func mainNetGenesisBlock() *types.Block {
21 merkleRoot, err := types.TxMerkleRoot(toBCTxs(txs))
23 log.Panicf("fail on calc genesis tx merkel root")
26 block := &types.Block{
27 BlockHeader: types.BlockHeader{
30 Timestamp: 1524549600000,
31 BlockCommitment: types.BlockCommitment{
32 TransactionsMerkleRoot: merkleRoot,
40 func testNetGenesisBlock() *types.Block {
42 merkleRoot, err := types.TxMerkleRoot(toBCTxs(txs))
44 log.Panicf("fail on calc genesis tx merkel root")
47 block := &types.Block{
48 BlockHeader: types.BlockHeader{
51 Timestamp: 1528945000000,
52 BlockCommitment: types.BlockCommitment{
53 TransactionsMerkleRoot: merkleRoot,
61 func soloNetGenesisBlock() *types.Block {
63 merkleRoot, err := types.TxMerkleRoot(toBCTxs(txs))
65 log.Panicf("fail on calc genesis tx merkel root")
68 block := &types.Block{
69 BlockHeader: types.BlockHeader{
72 Timestamp: 1528945000000,
73 BlockCommitment: types.BlockCommitment{
74 TransactionsMerkleRoot: merkleRoot,
82 // GenesisBlock will return genesis block
83 func GenesisBlock() *types.Block {
84 return map[string]func() *types.Block{
85 "main": mainNetGenesisBlock,
86 "test": testNetGenesisBlock,
87 "solo": soloNetGenesisBlock,
88 }[consensus.ActiveNetParams.Name]()