-
Notifications
You must be signed in to change notification settings - Fork 179
/
root_block.go
40 lines (34 loc) · 1.1 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
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()))
}
// 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)
payload := cluster.EmptyPayload(flow.ZeroID)
payload.ReferenceEpoch = epoch
header := &flow.Header{
ChainID: chainID,
ParentID: flow.ZeroID,
Height: 0,
PayloadHash: payload.Hash(),
Timestamp: flow.GenesisTime,
View: 0,
ParentVoterIDs: nil,
ParentVoterSig: nil,
ProposerID: flow.ZeroID,
ProposerSig: nil,
}
return &cluster.Block{
Header: header,
Payload: &payload,
}
}