github.com/koko1123/flow-go-1@v0.29.6/engine/access/rest/models/execution_result.go (about)

     1  package models
     2  
     3  import (
     4  	"github.com/koko1123/flow-go-1/engine/access/rest/util"
     5  	"github.com/koko1123/flow-go-1/model/flow"
     6  )
     7  
     8  func (e *ExecutionResult) Build(exeResult *flow.ExecutionResult, link LinkGenerator) error {
     9  	self, err := SelfLink(exeResult.ID(), link.ExecutionResultLink)
    10  	if err != nil {
    11  		return err
    12  	}
    13  
    14  	events := make([]Event, len(exeResult.ServiceEvents))
    15  	for i, e := range exeResult.ServiceEvents {
    16  		events[i] = Event{
    17  			Type_: e.Type,
    18  		}
    19  	}
    20  
    21  	e.Id = exeResult.ID().String()
    22  	e.BlockId = exeResult.BlockID.String()
    23  	e.Events = events
    24  	e.Links = self
    25  
    26  	e.PreviousResultId = exeResult.PreviousResultID.String()
    27  
    28  	chunks := make([]Chunk, len(exeResult.Chunks))
    29  
    30  	for i, flowChunk := range exeResult.Chunks {
    31  		var chunk Chunk
    32  		chunk.Build(flowChunk)
    33  		chunks[i] = chunk
    34  	}
    35  	e.Chunks = chunks
    36  	return nil
    37  }
    38  
    39  func (c *Chunk) Build(chunk *flow.Chunk) {
    40  	c.BlockId = chunk.BlockID.String()
    41  	c.Index = util.FromUint64(chunk.Index)
    42  	c.CollectionIndex = util.FromUint64(uint64(chunk.CollectionIndex))
    43  	c.StartState = util.ToBase64(chunk.StartState[:])
    44  	c.EndState = util.ToBase64(chunk.EndState[:])
    45  	c.NumberOfTransactions = util.FromUint64(chunk.NumberOfTransactions)
    46  	c.EventCollection = chunk.EventCollection.String()
    47  	c.TotalComputationUsed = util.FromUint64(chunk.TotalComputationUsed)
    48  }