github.com/0chain/gosdk@v1.17.11/dev/blobber/model/reference_path_result.go (about) 1 package model 2 3 import "context" 4 5 type ReferencePathResult struct { 6 *ReferencePath 7 LatestWM *WriteMarker `json:"latest_write_marker"` 8 } 9 10 func BuildReferencePathResult(rootRef *Ref) *ReferencePathResult { 11 rootRef.CalculateHash(context.TODO()) //nolint 12 13 refPath := &ReferencePath{Ref: rootRef} 14 15 refsToProcess := []*ReferencePath{refPath} 16 17 //convert Ref tree to ReferencePath tree 18 for len(refsToProcess) > 0 { 19 refToProcess := refsToProcess[0] 20 refToProcess.Meta = refToProcess.Ref.GetListingData(context.TODO()) 21 if len(refToProcess.Ref.Children) > 0 { 22 refToProcess.List = make([]*ReferencePath, len(refToProcess.Ref.Children)) 23 } 24 for idx, child := range refToProcess.Ref.Children { 25 childRefPath := &ReferencePath{Ref: child} 26 refToProcess.List[idx] = childRefPath 27 refsToProcess = append(refsToProcess, childRefPath) 28 } 29 refsToProcess = refsToProcess[1:] 30 } 31 32 return &ReferencePathResult{ 33 ReferencePath: refPath, 34 } 35 }