Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix empty tick checks #47

Merged
merged 4 commits into from
Jul 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions validator/tick/empty_tick.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ import (
"github.com/qubic/go-archiver/protobuff"
"github.com/qubic/go-archiver/store"
"github.com/qubic/go-node-connector/types"
"google.golang.org/protobuf/proto"
)

var emptyTickData = &protobuff.TickData{}

func CalculateEmptyTicksForEpoch(ctx context.Context, ps *store.PebbleStore, epoch uint32) (uint32, error) {

epochs, err := ps.GetProcessedTickIntervals(ctx)
Expand All @@ -24,6 +27,7 @@ func CalculateEmptyTicksForEpoch(ctx context.Context, ps *store.PebbleStore, epo
var emptyTicks uint32

for _, interval := range e.Intervals {
fmt.Printf("Interval: %d -> %d\n", interval.InitialProcessedTick, interval.LastProcessedTick)
for tickOffset := range interval.LastProcessedTick - interval.InitialProcessedTick + 1 {
tickNumber := tickOffset + interval.InitialProcessedTick

Expand All @@ -33,7 +37,7 @@ func CalculateEmptyTicksForEpoch(ctx context.Context, ps *store.PebbleStore, epo
}

if CheckIfTickIsEmptyProto(tickData) {
fmt.Printf("Found empty tick.\n")
fmt.Printf("Found empty tick: %d\n", tickNumber)
emptyTicks += 1
continue
}
Expand All @@ -45,7 +49,8 @@ func CalculateEmptyTicksForEpoch(ctx context.Context, ps *store.PebbleStore, epo
}

func CheckIfTickIsEmptyProto(tickData *protobuff.TickData) bool {
if tickData == nil {

if tickData == nil || proto.Equal(tickData, emptyTickData) {
return true
}

Expand Down
Loading