github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/model/messages/synchronization.go (about)

     1  package messages
     2  
     3  import (
     4  	"github.com/onflow/flow-go/model/cluster"
     5  	"github.com/onflow/flow-go/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  // All SyncRequest messages are validated before being processed. If validation fails, then a misbehavior report is created.
    12  // See synchronization.validateSyncRequestForALSP for more details.
    13  type SyncRequest struct {
    14  	Nonce  uint64
    15  	Height uint64
    16  }
    17  
    18  // SyncResponse is part of the synchronization protocol and represents the reply
    19  // to a synchronization request that contains the latest finalized block height
    20  // of the responding node.
    21  type SyncResponse struct {
    22  	Nonce  uint64
    23  	Height uint64
    24  }
    25  
    26  // RangeRequest is part of the synchronization protocol and represents an active
    27  // (pulling) attempt to synchronize with the consensus state of the network. It
    28  // requests finalized blocks by a range of block heights, including from and to
    29  // heights.
    30  // All RangeRequest messages are validated before being processed. If validation fails, then a misbehavior report is created.
    31  // See synchronization.validateRangeRequestForALSP for more details.
    32  type RangeRequest struct {
    33  	Nonce      uint64
    34  	FromHeight uint64
    35  	ToHeight   uint64
    36  }
    37  
    38  // BatchRequest is part of the synchronization protocol and represents an active
    39  // (pulling) attempt to synchronize with the consensus state of the network. It
    40  // requests finalized or unfinalized blocks by a list of block IDs.
    41  // All BatchRequest messages are validated before being processed. If validation fails, then a misbehavior report is created.
    42  // See synchronization.validateBatchRequestForALSP for more details.
    43  type BatchRequest struct {
    44  	Nonce    uint64
    45  	BlockIDs []flow.Identifier
    46  }
    47  
    48  // BlockResponse is part of the synchronization protocol and represents the
    49  // reply to any active synchronization attempts. It contains a list of blocks
    50  // that should correspond to the request.
    51  type BlockResponse struct {
    52  	Nonce  uint64
    53  	Blocks []UntrustedBlock
    54  }
    55  
    56  func (br *BlockResponse) BlocksInternal() []*flow.Block {
    57  	internal := make([]*flow.Block, len(br.Blocks))
    58  	for i, block := range br.Blocks {
    59  		block := block
    60  		internal[i] = block.ToInternal()
    61  	}
    62  	return internal
    63  }
    64  
    65  // ClusterBlockResponse is the same thing as BlockResponse, but for cluster
    66  // consensus.
    67  type ClusterBlockResponse struct {
    68  	Nonce  uint64
    69  	Blocks []UntrustedClusterBlock
    70  }
    71  
    72  func (br *ClusterBlockResponse) BlocksInternal() []*cluster.Block {
    73  	internal := make([]*cluster.Block, len(br.Blocks))
    74  	for i, block := range br.Blocks {
    75  		block := block
    76  		internal[i] = block.ToInternal()
    77  	}
    78  	return internal
    79  }