github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/model/cluster/block.go (about) 1 // Package cluster contains models related to collection node cluster 2 // consensus. 3 package cluster 4 5 import ( 6 "github.com/onflow/flow-go/model/flow" 7 ) 8 9 func Genesis() *Block { 10 header := &flow.Header{ 11 View: 0, 12 ChainID: "cluster", 13 Timestamp: flow.GenesisTime, 14 ParentID: flow.ZeroID, 15 } 16 17 payload := EmptyPayload(flow.ZeroID) 18 19 block := &Block{ 20 Header: header, 21 } 22 block.SetPayload(payload) 23 24 return block 25 } 26 27 // Block represents a block in collection node cluster consensus. It contains 28 // a standard block header with a payload containing only a single collection. 29 type Block struct { 30 Header *flow.Header 31 Payload *Payload 32 } 33 34 // ID returns the ID of the underlying block header. 35 func (b Block) ID() flow.Identifier { 36 return b.Header.ID() 37 } 38 39 // SetPayload sets the payload and payload hash. 40 func (b *Block) SetPayload(payload Payload) { 41 b.Payload = &payload 42 b.Header.PayloadHash = payload.Hash() 43 }