github.com/koko1123/flow-go-1@v0.29.6/model/messages/collection.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 // SubmitCollectionGuarantee is a request to submit the given collection 9 // guarantee to consensus nodes. Only valid as a node-local message. 10 type SubmitCollectionGuarantee struct { 11 Guarantee flow.CollectionGuarantee 12 } 13 14 // CollectionRequest request all transactions from a collection with the given 15 // fingerprint. 16 type CollectionRequest struct { 17 ID flow.Identifier 18 Nonce uint64 // so that we aren't deduplicated by the network layer 19 } 20 21 // CollectionResponse is a response to a request for a collection. 22 type CollectionResponse struct { 23 Collection flow.Collection 24 Nonce uint64 // so that we aren't deduplicated by the network layer 25 } 26 27 // UntrustedClusterBlockPayload is a duplicate of cluster.Payload used within 28 // untrusted messages. It exists only to provide a memory-safe structure for 29 // decoding messages and should be replaced in the future by updating the core 30 // cluster.Payload type. 31 // Deprecated: Please update cluster.Payload.Collection to use []flow.TransactionBody, 32 // then replace instances of this type with cluster.Payload 33 type UntrustedClusterBlockPayload struct { 34 Collection []flow.TransactionBody 35 ReferenceBlockID flow.Identifier 36 } 37 38 // UntrustedClusterBlock is a duplicate of cluster.Block used within 39 // untrusted messages. It exists only to provide a memory-safe structure for 40 // decoding messages and should be replaced in the future by updating the core 41 // cluster.Block type. 42 // Deprecated: Please update cluster.Payload.Collection to use []flow.TransactionBody, 43 // then replace instances of this type with cluster.Block 44 type UntrustedClusterBlock struct { 45 Header flow.Header 46 Payload UntrustedClusterBlockPayload 47 } 48 49 // ToInternal returns the internal representation of the type. 50 func (ub *UntrustedClusterBlock) ToInternal() *cluster.Block { 51 block := &cluster.Block{ 52 Header: &ub.Header, 53 Payload: &cluster.Payload{ 54 ReferenceBlockID: ub.Payload.ReferenceBlockID, 55 }, 56 } 57 for _, tx := range ub.Payload.Collection { 58 tx := tx 59 block.Payload.Collection.Transactions = append(block.Payload.Collection.Transactions, &tx) 60 } 61 return block 62 } 63 64 // UntrustedClusterBlockFromInternal converts the internal cluster.Block representation 65 // to the representation used in untrusted messages. 66 func UntrustedClusterBlockFromInternal(clusterBlock *cluster.Block) UntrustedClusterBlock { 67 block := UntrustedClusterBlock{ 68 Header: *clusterBlock.Header, 69 Payload: UntrustedClusterBlockPayload{ 70 ReferenceBlockID: clusterBlock.Payload.ReferenceBlockID, 71 Collection: make([]flow.TransactionBody, 0, clusterBlock.Payload.Collection.Len()), 72 }, 73 } 74 for _, tx := range clusterBlock.Payload.Collection.Transactions { 75 block.Payload.Collection = append(block.Payload.Collection, *tx) 76 } 77 return block 78 } 79 80 // ClusterBlockProposal is a proposal for a block in collection node cluster 81 // consensus. The header contains information about consensus state and the 82 // payload contains the proposed collection (may be empty). 83 type ClusterBlockProposal struct { 84 Block UntrustedClusterBlock 85 } 86 87 func NewClusterBlockProposal(internal *cluster.Block) *ClusterBlockProposal { 88 return &ClusterBlockProposal{ 89 Block: UntrustedClusterBlockFromInternal(internal), 90 } 91 } 92 93 // ClusterBlockVote is a vote for a proposed block in collection node cluster 94 // consensus; effectively a vote for a particular collection. 95 type ClusterBlockVote struct { 96 BlockID flow.Identifier 97 View uint64 98 SigData []byte 99 }