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

Publish batch validator entry events #403

Merged
merged 1 commit into from
Oct 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
25 changes: 25 additions & 0 deletions plugins/indexing/batching/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,31 @@ func ExtractUpdate(ctx *types.BlockContext, cdc codec.Codec, logger *log.Logger,
}

return types.NewMessage("batch-signatures", data, ctx), nil
} else if keyBytes, found := bytes.CutPrefix(change.Key, batchingtypes.TreeEntriesKeyPrefix); found {
_, key, err := collections.Uint64Key.Decode(keyBytes)
if err != nil {
return nil, err
}

val, err := codec.CollValue[batchingtypes.TreeEntries](cdc).Decode(change.Value)
if err != nil {
return nil, err
}

validatorTreeEntries := make([]string, len(val.ValidatorEntries))
for i, entry := range val.ValidatorEntries {
validatorTreeEntries[i] = hex.EncodeToString(entry)
}

data := struct {
BatchNumber string `json:"batch_number"`
ValidatorTreeEntries []string `json:"validator_tree_entries"`
}{
BatchNumber: strconv.FormatUint(key, 10),
ValidatorTreeEntries: validatorTreeEntries,
}

return types.NewMessage("batch-validator-entries", data, ctx), nil
} else if _, found := bytes.CutPrefix(change.Key, batchingtypes.ParamsKey); found {
val, err := codec.CollValue[batchingtypes.Params](cdc).Decode(change.Value)
if err != nil {
Expand Down
Loading