github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/engine/execution/collection_result.go (about)

     1  package execution
     2  
     3  import (
     4  	"github.com/onflow/flow-go/fvm/storage/snapshot"
     5  	"github.com/onflow/flow-go/model/flow"
     6  )
     7  
     8  // CollectionExecutionResult holds aggregated artifacts (events, tx resutls, ...)
     9  // generated during collection execution
    10  type CollectionExecutionResult struct {
    11  	events                 flow.EventsList
    12  	serviceEvents          flow.EventsList
    13  	convertedServiceEvents flow.ServiceEventList
    14  	transactionResults     flow.TransactionResults
    15  	executionSnapshot      *snapshot.ExecutionSnapshot
    16  }
    17  
    18  // NewEmptyCollectionExecutionResult constructs a new  CollectionExecutionResult
    19  func NewEmptyCollectionExecutionResult() *CollectionExecutionResult {
    20  	return &CollectionExecutionResult{
    21  		events:                 make(flow.EventsList, 0),
    22  		serviceEvents:          make(flow.EventsList, 0),
    23  		convertedServiceEvents: make(flow.ServiceEventList, 0),
    24  		transactionResults:     make(flow.TransactionResults, 0),
    25  	}
    26  }
    27  
    28  func (c *CollectionExecutionResult) AppendTransactionResults(
    29  	events flow.EventsList,
    30  	serviceEvents flow.EventsList,
    31  	convertedServiceEvents flow.ServiceEventList,
    32  	transactionResult flow.TransactionResult,
    33  ) {
    34  	c.events = append(c.events, events...)
    35  	c.serviceEvents = append(c.serviceEvents, serviceEvents...)
    36  	c.convertedServiceEvents = append(c.convertedServiceEvents, convertedServiceEvents...)
    37  	c.transactionResults = append(c.transactionResults, transactionResult)
    38  }
    39  
    40  func (c *CollectionExecutionResult) UpdateExecutionSnapshot(
    41  	executionSnapshot *snapshot.ExecutionSnapshot,
    42  ) {
    43  	c.executionSnapshot = executionSnapshot
    44  }
    45  
    46  func (c *CollectionExecutionResult) ExecutionSnapshot() *snapshot.ExecutionSnapshot {
    47  	return c.executionSnapshot
    48  }
    49  
    50  func (c *CollectionExecutionResult) Events() flow.EventsList {
    51  	return c.events
    52  }
    53  
    54  func (c *CollectionExecutionResult) ServiceEventList() flow.EventsList {
    55  	return c.serviceEvents
    56  }
    57  
    58  func (c *CollectionExecutionResult) ConvertedServiceEvents() flow.ServiceEventList {
    59  	return c.convertedServiceEvents
    60  }
    61  
    62  func (c *CollectionExecutionResult) TransactionResults() flow.TransactionResults {
    63  	return c.transactionResults
    64  }
    65  
    66  // CollectionAttestationResult holds attestations generated during post-processing
    67  // phase of collect execution.
    68  type CollectionAttestationResult struct {
    69  	startStateCommit flow.StateCommitment
    70  	endStateCommit   flow.StateCommitment
    71  	stateProof       flow.StorageProof
    72  	eventCommit      flow.Identifier
    73  }
    74  
    75  func NewCollectionAttestationResult(
    76  	startStateCommit flow.StateCommitment,
    77  	endStateCommit flow.StateCommitment,
    78  	stateProof flow.StorageProof,
    79  	eventCommit flow.Identifier,
    80  ) *CollectionAttestationResult {
    81  	return &CollectionAttestationResult{
    82  		startStateCommit: startStateCommit,
    83  		endStateCommit:   endStateCommit,
    84  		stateProof:       stateProof,
    85  		eventCommit:      eventCommit,
    86  	}
    87  }
    88  
    89  func (a *CollectionAttestationResult) StartStateCommitment() flow.StateCommitment {
    90  	return a.startStateCommit
    91  }
    92  
    93  func (a *CollectionAttestationResult) EndStateCommitment() flow.StateCommitment {
    94  	return a.endStateCommit
    95  }
    96  
    97  func (a *CollectionAttestationResult) StateProof() flow.StorageProof {
    98  	return a.stateProof
    99  }
   100  
   101  func (a *CollectionAttestationResult) EventCommitment() flow.Identifier {
   102  	return a.eventCommit
   103  }
   104  
   105  // TODO(ramtin): depricate in the future, temp method, needed for uploader for now
   106  func (a *CollectionAttestationResult) UpdateEndStateCommitment(endState flow.StateCommitment) {
   107  	a.endStateCommit = endState
   108  }