more statticcheck!

This commit is contained in:
whyrusleeping 2019-12-04 21:14:19 -08:00
parent df069af5e5
commit b7a89b56b3
13 changed files with 23 additions and 11 deletions

View File

@ -67,7 +67,7 @@ func TestDealFlow(t *testing.T, b APIBuilder) {
time.Sleep(time.Second)
fmt.Println("mining a block now")
if err := sn[0].MineOne(ctx); err != nil {
t.Fatal(err)
t.Error(err)
}
}
}()

View File

@ -6,6 +6,7 @@ import (
"strings"
"github.com/filecoin-project/lotus/lib/addrutil"
"golang.org/x/xerrors"
rice "github.com/GeertJohan/go.rice"
"github.com/libp2p/go-libp2p-core/peer"
@ -16,6 +17,10 @@ func BuiltinBootstrap() ([]peer.AddrInfo, error) {
b := rice.MustFindBox("bootstrap")
err := b.Walk("", func(path string, info os.FileInfo, err error) error {
if err != nil {
return xerrors.Errorf("failed to walk box: %w", err)
}
if !strings.HasSuffix(path, ".pi") {
return nil
}

View File

@ -199,6 +199,9 @@ func (c *Client) Start(ctx context.Context, p ClientDealProposal) (cid.Cid, erro
}
commP, pieceSize, err := c.commP(ctx, p.Data)
if err != nil {
return cid.Undef, xerrors.Errorf("computing commP failed: %w", err)
}
dealProposal := &actors.StorageDealProposal{
PieceRef: commP,

View File

@ -80,7 +80,7 @@ type minerDealUpdate struct {
var (
// ErrDataTransferFailed means a data transfer for a deal failed
ErrDataTransferFailed = errors.New("Deal data transfer failed")
ErrDataTransferFailed = errors.New("deal data transfer failed")
)
func NewProvider(ds dtypes.MetadataDS, sminer *storage.Miner, secb *sectorblocks.SectorBlocks, dag dtypes.StagingDAG, dataTransfer dtypes.ProviderDataTransfer, fullNode api.FullNode) (*Provider, error) {

View File

@ -168,6 +168,9 @@ func (p *Provider) accept(ctx context.Context, deal MinerDeal) (func(*MinerDeal)
deal.Ref,
allSelector,
)
if err != nil {
return nil, xerrors.Errorf("failed to open pull data channel: %w", err)
}
return nil, nil
}

View File

@ -69,6 +69,9 @@ func newClientDeal(minerID peer.ID, state api.DealState) (deals.ClientDeal, erro
return deals.ClientDeal{}, err
}
minerAddr, err := address.NewIDAddress(uint64(rand.Int()))
if err != nil {
return deals.ClientDeal{}, err
}
return deals.ClientDeal{
Proposal: newProposal,

View File

@ -273,7 +273,7 @@ func (cs *ChainStore) reorgWorker(ctx context.Context) chan<- reorg {
}
func (cs *ChainStore) takeHeaviestTipSet(ctx context.Context, ts *types.TipSet) error {
ctx, span := trace.StartSpan(ctx, "takeHeaviestTipSet")
_, span := trace.StartSpan(ctx, "takeHeaviestTipSet")
defer span.End()
if cs.heaviest != nil { // buf

View File

@ -112,7 +112,7 @@ func (blk *BlockHeader) SigningBytes() ([]byte, error) {
}
func (blk *BlockHeader) CheckBlockSignature(ctx context.Context, worker address.Address) error {
ctx, span := trace.StartSpan(ctx, "checkBlockSignature")
_, span := trace.StartSpan(ctx, "checkBlockSignature")
defer span.End()
sigb, err := blk.SigningBytes()

View File

@ -23,6 +23,7 @@ var stateCmd = &cli.Command{
stateListMinersCmd,
stateGetActorCmd,
stateLookupIDCmd,
stateReplaySetCmd,
},
}

View File

@ -81,7 +81,8 @@ func toReadableFile(r io.Reader, n int64) (*os.File, func() error, error) {
go func() {
defer wait.Unlock()
copied, werr := io.CopyN(w, r, n)
var copied int64
copied, werr = io.CopyN(w, r, n)
if werr != nil {
log.Warnf("toReadableFile: copy error: %+v", werr)
}

View File

@ -6,15 +6,12 @@ import (
"io"
"net/http"
"strings"
"sync"
"github.com/gorilla/websocket"
"github.com/opentracing/opentracing-go/log"
)
type outmux struct {
lk sync.Mutex
errpw *io.PipeWriter
outpw *io.PipeWriter
@ -127,5 +124,4 @@ func (m *outmux) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
m.new <- c
return
}

View File

@ -12,7 +12,7 @@ import (
"github.com/libp2p/go-libp2p-core/host"
inet "github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
protocol "github.com/libp2p/go-libp2p-protocol"
protocol "github.com/libp2p/go-libp2p-core/protocol"
"github.com/filecoin-project/lotus/chain"
"github.com/filecoin-project/lotus/chain/store"

View File

@ -11,8 +11,8 @@ import (
"github.com/ipfs/go-datastore"
blockstore "github.com/ipfs/go-ipfs-blockstore"
"github.com/libp2p/go-libp2p-core/host"
peer "github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/routing"
peer "github.com/libp2p/go-libp2p-peer"
pubsub "github.com/libp2p/go-libp2p-pubsub"
"go.uber.org/fx"
"golang.org/x/xerrors"