-
Notifications
You must be signed in to change notification settings - Fork 178
/
block.go
52 lines (43 loc) · 1.19 KB
/
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
44
45
46
47
48
49
50
51
52
// 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()
}
// PendingBlock is a wrapper type representing a block that cannot yet be
// processed. The block header, payload, and sender ID are stored together
// while waiting for the block to become processable.
type PendingBlock struct {
OriginID flow.Identifier
Header *flow.Header
Payload *Payload
}