-
Notifications
You must be signed in to change notification settings - Fork 207
Expand file tree
/
Copy pathexecution_data.go
More file actions
87 lines (72 loc) · 2.6 KB
/
execution_data.go
File metadata and controls
87 lines (72 loc) · 2.6 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package execution_data
import (
"errors"
"github.com/onflow/flow-go/ledger"
"github.com/onflow/flow-go/model/flow"
)
// ExecutionDataDBMode controls which db type to use.
type ExecutionDataDBMode int
const (
// ExecutionDataDBModeBadger uses badger db
ExecutionDataDBModeBadger ExecutionDataDBMode = iota + 1
// ExecutionDataDBModePebble uses pebble db
ExecutionDataDBModePebble
)
func ParseExecutionDataDBMode(s string) (ExecutionDataDBMode, error) {
switch s {
case ExecutionDataDBModeBadger.String():
return ExecutionDataDBModeBadger, nil
case ExecutionDataDBModePebble.String():
return ExecutionDataDBModePebble, nil
default:
return 0, errors.New("invalid execution data DB mode")
}
}
func (m ExecutionDataDBMode) String() string {
switch m {
case ExecutionDataDBModeBadger:
return "badger"
case ExecutionDataDBModePebble:
return "pebble"
default:
return ""
}
}
// DefaultMaxBlobSize is the default maximum size of a blob.
// This is calibrated to fit within a libp2p message and not exceed the max size recommended by bitswap.
const DefaultMaxBlobSize = 1 << 20 // 1MiB
// ChunkExecutionData represents the execution data of a chunk
type ChunkExecutionData struct {
// Collection is the collection for which this chunk was executed
Collection *flow.Collection
// Events are the events generated by executing the collection
Events flow.EventsList
// TrieUpdate is the trie update generated by executing the collection
// This includes a list of all registers updated during the execution
TrieUpdate *ledger.TrieUpdate
// TransactionResults are the results of executing the transactions in the collection
// This includes all of the data from flow.TransactionResult, except that it uses a boolean
// value to indicate if an error occurred instead of a full error message.
TransactionResults []flow.LightTransactionResult
}
// BlockExecutionData represents the execution data of a block.
type BlockExecutionData struct {
BlockID flow.Identifier
ChunkExecutionDatas []*ChunkExecutionData
}
// ConvertTransactionResults converts a list of flow.TransactionResults into a list of
// flow.LightTransactionResults to be included in a ChunkExecutionData.
func ConvertTransactionResults(results flow.TransactionResults) []flow.LightTransactionResult {
if len(results) == 0 {
return nil
}
converted := make([]flow.LightTransactionResult, len(results))
for i, txResult := range results {
converted[i] = flow.LightTransactionResult{
TransactionID: txResult.TransactionID,
ComputationUsed: txResult.ComputationUsed,
Failed: txResult.ErrorMessage != "",
}
}
return converted
}