-
Notifications
You must be signed in to change notification settings - Fork 209
Expand file tree
/
Copy pathmessages.go
More file actions
40 lines (35 loc) · 1.44 KB
/
messages.go
File metadata and controls
40 lines (35 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package execution
import (
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/module/mempool/entity"
)
// ComputationResult captures artifacts of execution of block collections, collection attestation results and
// the full execution receipt, as sent by the Execution Node.
// CAUTION: This type is used to represent both a complete ComputationResult and a partially constructed ComputationResult.
// TODO: Consider using a Builder type to represent the partially constructed model.
type ComputationResult struct {
*BlockExecutionResult
*BlockAttestationResult
ExecutionReceipt *flow.ExecutionReceipt
}
// NewEmptyComputationResult creates an empty ComputationResult.
// Construction ComputationResult allowed only within the constructor.
func NewEmptyComputationResult(
block *entity.ExecutableBlock,
) *ComputationResult {
ber := NewPopulatedBlockExecutionResult(block)
aer := NewEmptyBlockAttestationResult(ber)
return &ComputationResult{
BlockExecutionResult: ber,
BlockAttestationResult: aer,
}
}
// CurrentEndState returns the most recent end state
// if no attestation appended yet, it returns start state of block
// TODO(ramtin): we probably don't need this long term as part of this method
func (cr *ComputationResult) CurrentEndState() flow.StateCommitment {
if len(cr.collectionAttestationResults) == 0 {
return *cr.StartState
}
return cr.collectionAttestationResults[len(cr.collectionAttestationResults)-1].endStateCommit
}