Skip to content

refactor(x/sync): remove need for passing proof nodes to completeWorkItem #4064

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
27 changes: 19 additions & 8 deletions x/sync/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,23 @@

package sync

import "github.com/ava-labs/avalanchego/x/merkledb"

type DB interface {
merkledb.Clearer
merkledb.MerkleRootGetter
merkledb.ProofGetter
merkledb.ChangeProofer
merkledb.RangeProofer
import (
"context"

"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/utils/maybe"

pb "github.com/ava-labs/avalanchego/proto/pb/sync"
)

type DBSyncClient interface {
GetRootHash(ctx context.Context) (ids.ID, error)
HandleRangeProofResponse(ctx context.Context, request *pb.SyncGetRangeProofRequest, responseBytes []byte) (maybe.Maybe[[]byte], error)
HandleChangeProofResponse(
ctx context.Context,
request *pb.SyncGetChangeProofRequest,
responseBytes []byte,
) (maybe.Maybe[[]byte], error)
Error() error
Clear() error
}
Comment on lines +15 to 25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on this interface are:

  1. The abstraction boundary isn't clear, we couple the database w/ how responses are handled
  2. Error is interesting, we're expecting our sync package to just keep checking this return value. We could probably get rid of this from the interface if we moved this information somewhere else... we would only fatal during response handling so does it seem reasonable to see if it's possible to expose that information to that API?

Loading