github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/module/executiondatasync/execution_data/entity.go (about)

     1  package execution_data
     2  
     3  import (
     4  	"github.com/onflow/flow-go/model/flow"
     5  )
     6  
     7  // BlockExecutionDataEntity is a wrapper around BlockExecutionData that implements the flow.Entity
     8  // interface to support caching with Herocache
     9  type BlockExecutionDataEntity struct {
    10  	*BlockExecutionData
    11  
    12  	// id holds the cached BlockExecutionData ID. The ID generation process is expensive, so this
    13  	// entity interface exclusively uses a pre-calculated value.
    14  	id flow.Identifier
    15  }
    16  
    17  var _ flow.Entity = (*BlockExecutionDataEntity)(nil)
    18  
    19  func NewBlockExecutionDataEntity(id flow.Identifier, executionData *BlockExecutionData) *BlockExecutionDataEntity {
    20  	return &BlockExecutionDataEntity{
    21  		id:                 id,
    22  		BlockExecutionData: executionData,
    23  	}
    24  }
    25  
    26  func (c BlockExecutionDataEntity) ID() flow.Identifier {
    27  	return c.id
    28  }
    29  
    30  func (c BlockExecutionDataEntity) Checksum() flow.Identifier {
    31  	return c.id
    32  }