/
genesis.go
38 lines (35 loc) · 1.06 KB
/
genesis.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package blockchain
import (
"github.com/LiskHQ/lisk-engine/pkg/codec"
"github.com/LiskHQ/lisk-engine/pkg/collection/bytes"
"github.com/LiskHQ/lisk-engine/pkg/crypto"
)
const (
GenesisBlockVersion = 0
)
// NewGenesisBlock returns a valid genesis block but without validatorsHash and stateRoot.
func NewGenesisBlock(height, timestamp uint32, previoudBlockID codec.Hex, assets BlockAssets) *Block {
assets.Sort()
assetRoot := assets.GetRoot()
return &Block{
Header: &BlockHeader{
Version: GenesisBlockVersion,
PreviousBlockID: previoudBlockID,
Height: height,
Timestamp: timestamp,
GeneratorAddress: bytes.Repeat([]byte{0}, AddressLength),
MaxHeightGenerated: 0,
MaxHeightPrevoted: height,
Signature: []byte{},
TransactionRoot: crypto.Hash([]byte{}),
AssetRoot: assetRoot,
AggregateCommit: &AggregateCommit{
Height: 0,
AggregationBits: []byte{},
CertificateSignature: []byte{},
},
},
Assets: assets,
Transactions: []*Transaction{},
}
}