-
Notifications
You must be signed in to change notification settings - Fork 41
/
utils.go
27 lines (22 loc) · 933 Bytes
/
utils.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
package service
import (
"sort"
"github.com/streamingfast/bstream"
pbsubstreams "github.com/streamingfast/substreams/pb/sf/substreams/v1"
)
func sortClocksDistributor(clockDistributor map[uint64]*pbsubstreams.Clock) (sortedClockDistributor []*pbsubstreams.Clock) {
sortedClockDistributor = make([]*pbsubstreams.Clock, 0, len(clockDistributor))
for _, clock := range clockDistributor {
sortedClockDistributor = append(sortedClockDistributor, clock)
}
sort.Slice(sortedClockDistributor, func(i, j int) bool { return sortedClockDistributor[i].Number < sortedClockDistributor[j].Number })
return
}
func irreversibleCursorFromClock(clock *pbsubstreams.Clock) *bstream.Cursor {
return &bstream.Cursor{
Step: bstream.StepNewIrreversible,
Block: bstream.NewBlockRef(clock.Id, clock.Number),
LIB: bstream.NewBlockRef(clock.Id, clock.Number),
HeadBlock: bstream.NewBlockRef(clock.Id, clock.Number),
}
}