-
Notifications
You must be signed in to change notification settings - Fork 179
/
execution_result.go
51 lines (43 loc) · 1.28 KB
/
execution_result.go
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
package models
import (
"github.com/onflow/flow-go/engine/access/rest/util"
"github.com/onflow/flow-go/model/flow"
)
func (e *ExecutionResult) Build(
exeResult *flow.ExecutionResult,
link LinkGenerator,
) error {
self, err := SelfLink(exeResult.ID(), link.ExecutionResultLink)
if err != nil {
return err
}
events := make([]Event, len(exeResult.ServiceEvents))
for i, e := range exeResult.ServiceEvents {
events[i] = Event{
Type_: e.Type.String(),
}
}
e.Id = exeResult.ID().String()
e.BlockId = exeResult.BlockID.String()
e.Events = events
e.Links = self
e.PreviousResultId = exeResult.PreviousResultID.String()
chunks := make([]Chunk, len(exeResult.Chunks))
for i, flowChunk := range exeResult.Chunks {
var chunk Chunk
chunk.Build(flowChunk)
chunks[i] = chunk
}
e.Chunks = chunks
return nil
}
func (c *Chunk) Build(chunk *flow.Chunk) {
c.BlockId = chunk.BlockID.String()
c.Index = util.FromUint64(chunk.Index)
c.CollectionIndex = util.FromUint64(uint64(chunk.CollectionIndex))
c.StartState = util.ToBase64(chunk.StartState[:])
c.EndState = util.ToBase64(chunk.EndState[:])
c.NumberOfTransactions = util.FromUint64(chunk.NumberOfTransactions)
c.EventCollection = chunk.EventCollection.String()
c.TotalComputationUsed = util.FromUint64(chunk.TotalComputationUsed)
}