From 6c4eab114b5f0af5594505f09f31b0e92c225c6c Mon Sep 17 00:00:00 2001 From: Keenan Nemetz Date: Thu, 13 Jun 2024 19:48:45 -0700 Subject: [PATCH] test fetch graph --- net/server.go | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/net/server.go b/net/server.go index 890f09aeea..9c9bbdc9b8 100644 --- a/net/server.go +++ b/net/server.go @@ -29,7 +29,6 @@ import ( "google.golang.org/protobuf/proto" "github.com/sourcenetwork/defradb/client" - "github.com/sourcenetwork/defradb/datastore/badger/v4" "github.com/sourcenetwork/defradb/errors" "github.com/sourcenetwork/defradb/events" pb "github.com/sourcenetwork/defradb/net/pb" @@ -178,19 +177,10 @@ func (s *server) PushLog(ctx context.Context, req *pb.PushLogRequest) (*pb.PushL } }() - onError := merkledag.OnError(func(c cid.Cid, err error) error { - if errors.Is(err, badger.ErrTxnConflict) { - return nil // transaction conflicts are fine to ignore - } - return err - }) - visit := func(c cid.Cid) bool { - has, _ := s.peer.db.Blockstore().Has(ctx, c) - return !has - } + // the merkledag must be fetched every time + // to ensure we have all of the child blocks dagServ := merkledag.NewDAGService(s.peer.bserv) - walkOpts := []merkledag.WalkOption{onError, merkledag.Concurrent()} - err = merkledag.Walk(ctx, dagServ.GetLinks, headCID, visit, walkOpts...) + err = merkledag.FetchGraph(ctx, headCID, dagServ) if err != nil { return nil, err }