Skip to content

Commit

Permalink
test fetch graph
Browse files Browse the repository at this point in the history
  • Loading branch information
nasdf committed Jun 14, 2024
1 parent b46c5ec commit 6c4eab1
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions net/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 6c4eab1

Please sign in to comment.