Rewrite chain export walker function to actually do the right thing

This commit is contained in:
Jeromy
2020-03-20 17:18:57 -07:00
parent aad449f28a
commit 921f11db34
4 changed files with 82 additions and 31 deletions
+7 -2
View File
@@ -20,11 +20,11 @@ import (
offline "github.com/ipfs/go-ipfs-exchange-offline"
cbor "github.com/ipfs/go-ipld-cbor"
ipld "github.com/ipfs/go-ipld-format"
logging "github.com/ipfs/go-log"
"github.com/ipfs/go-merkledag"
"github.com/ipfs/go-path"
"github.com/ipfs/go-path/resolver"
mh "github.com/multiformats/go-multihash"
"github.com/prometheus/common/log"
"go.uber.org/fx"
"golang.org/x/xerrors"
@@ -35,6 +35,8 @@ import (
"github.com/filecoin-project/lotus/chain/types"
)
var log = logging.Logger("fullnode")
type ChainAPI struct {
fx.In
@@ -424,7 +426,7 @@ func (a *ChainAPI) ChainExport(ctx context.Context, tsk types.TipSetKey) (<-chan
for {
buf := make([]byte, 4096)
n, err := r.Read(buf)
if err != nil {
if err != nil && err != io.EOF {
log.Errorf("chain export pipe read failed: %s", err)
return
}
@@ -433,6 +435,9 @@ func (a *ChainAPI) ChainExport(ctx context.Context, tsk types.TipSetKey) (<-chan
case <-ctx.Done():
log.Warnf("export writer failed: %s", ctx.Err())
}
if err == io.EOF {
return
}
}
}()
-1
View File
@@ -10,7 +10,6 @@ import (
"github.com/ipfs/go-hamt-ipld"
cbor "github.com/ipfs/go-ipld-cbor"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/prometheus/common/log"
cbg "github.com/whyrusleeping/cbor-gen"
"go.uber.org/fx"
"golang.org/x/xerrors"
-1
View File
@@ -8,7 +8,6 @@ import (
"github.com/filecoin-project/lotus/chain"
"github.com/filecoin-project/lotus/chain/types"
cid "github.com/ipfs/go-cid"
"github.com/prometheus/common/log"
pubsub "github.com/libp2p/go-libp2p-pubsub"
"go.uber.org/fx"