github.com/koko1123/flow-go-1@v0.29.6/model/messages/synchronization.go (about) 1 package messages 2 3 import ( 4 "github.com/koko1123/flow-go-1/model/cluster" 5 "github.com/koko1123/flow-go-1/model/flow" 6 ) 7 8 // SyncRequest is part of the synchronization protocol and represents a node on 9 // the network sharing the height of its latest finalized block and requesting 10 // the same information from the recipient. 11 type SyncRequest struct { 12 Nonce uint64 13 Height uint64 14 } 15 16 // SyncResponse is part of the synchronization protocol and represents the reply 17 // to a synchronization request that contains the latest finalized block height 18 // of the responding node. 19 type SyncResponse struct { 20 Nonce uint64 21 Height uint64 22 } 23 24 // RangeRequest is part of the synchronization protocol and represents an active 25 // (pulling) attempt to synchronize with the consensus state of the network. It 26 // requests finalized blocks by a range of block heights, including from and to 27 // heights. 28 type RangeRequest struct { 29 Nonce uint64 30 FromHeight uint64 31 ToHeight uint64 32 } 33 34 // BatchRequest is part of the sychronization protocol and represents an active 35 // (pulling) attempt to synchronize with the consensus state of the network. It 36 // requests finalized or unfinalized blocks by a list of block IDs. 37 type BatchRequest struct { 38 Nonce uint64 39 BlockIDs []flow.Identifier 40 } 41 42 // BlockResponse is part of the synchronization protocol and represents the 43 // reply to any active synchronization attempts. It contains a list of blocks 44 // that should correspond to the request. 45 type BlockResponse struct { 46 Nonce uint64 47 Blocks []UntrustedBlock 48 } 49 50 func (br *BlockResponse) BlocksInternal() []*flow.Block { 51 internal := make([]*flow.Block, len(br.Blocks)) 52 for i, block := range br.Blocks { 53 block := block 54 internal[i] = block.ToInternal() 55 } 56 return internal 57 } 58 59 // ClusterBlockResponse is the same thing as BlockResponse, but for cluster 60 // consensus. 61 type ClusterBlockResponse struct { 62 Nonce uint64 63 Blocks []UntrustedClusterBlock 64 } 65 66 func (br *ClusterBlockResponse) BlocksInternal() []*cluster.Block { 67 internal := make([]*cluster.Block, len(br.Blocks)) 68 for i, block := range br.Blocks { 69 block := block 70 internal[i] = block.ToInternal() 71 } 72 return internal 73 }