-
Notifications
You must be signed in to change notification settings - Fork 175
/
block.go
43 lines (35 loc) · 920 Bytes
/
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
43
// Package cluster contains models related to collection node cluster
// consensus.
package cluster
import (
"github.com/onflow/flow-go/model/flow"
)
func Genesis() *Block {
header := &flow.Header{
View: 0,
ChainID: "cluster",
Timestamp: flow.GenesisTime,
ParentID: flow.ZeroID,
}
payload := EmptyPayload(flow.ZeroID)
block := &Block{
Header: header,
}
block.SetPayload(payload)
return block
}
// Block represents a block in collection node cluster consensus. It contains
// a standard block header with a payload containing only a single collection.
type Block struct {
Header *flow.Header
Payload *Payload
}
// ID returns the ID of the underlying block header.
func (b Block) ID() flow.Identifier {
return b.Header.ID()
}
// SetPayload sets the payload and payload hash.
func (b *Block) SetPayload(payload Payload) {
b.Payload = &payload
b.Header.PayloadHash = payload.Hash()
}