-
Notifications
You must be signed in to change notification settings - Fork 178
/
root_block.go
42 lines (35 loc) · 1.23 KB
/
root_block.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
39
40
41
42
package cluster
import (
"fmt"
"github.com/onflow/flow-go/model/cluster"
"github.com/onflow/flow-go/model/flow"
)
// CanonicalClusterID returns the canonical chain ID for the given cluster in
// the given epoch.
func CanonicalClusterID(epoch uint64, participants flow.IdentityList) flow.ChainID {
return flow.ChainID(fmt.Sprintf("cluster-%d-%s", epoch, participants.Fingerprint()))
}
// these globals are filled by the static initializer
var rootBlockPayload = cluster.EmptyPayload(flow.ZeroID)
var rootBlockPayloadHash = rootBlockPayload.Hash()
// CanonicalRootBlock returns the canonical root block for the given
// cluster in the given epoch. It contains an empty collection referencing
func CanonicalRootBlock(epoch uint64, participants flow.IdentityList) *cluster.Block {
chainID := CanonicalClusterID(epoch, participants)
header := &flow.Header{
ChainID: chainID,
ParentID: flow.ZeroID,
Height: 0,
PayloadHash: rootBlockPayloadHash,
Timestamp: flow.GenesisTime,
View: 0,
ParentVoterIndices: nil,
ParentVoterSigData: nil,
ProposerID: flow.ZeroID,
ProposerSigData: nil,
}
return &cluster.Block{
Header: header,
Payload: &rootBlockPayload,
}
}