Merge pull request #1336 from filecoin-project/vet/some-go-vet-fixes

some go vet fixes
This commit is contained in:
Whyrusleeping 2020-03-06 00:11:13 -08:00 committed by GitHub
commit 05a95cace5
8 changed files with 17 additions and 19 deletions

View File

@ -18,7 +18,7 @@ var EmptyInt = BigInt{}
type BigInt = big2.Int
func NewInt(i uint64) BigInt {
return BigInt{big.NewInt(0).SetUint64(i)}
return BigInt{Int: big.NewInt(0).SetUint64(i)}
}
func FromFil(i uint64) BigInt {
@ -27,7 +27,7 @@ func FromFil(i uint64) BigInt {
func BigFromBytes(b []byte) BigInt {
i := big.NewInt(0).SetBytes(b)
return BigInt{i}
return BigInt{Int: i}
}
func BigFromString(s string) (BigInt, error) {
@ -36,27 +36,27 @@ func BigFromString(s string) (BigInt, error) {
return BigInt{}, fmt.Errorf("failed to parse string as a big int")
}
return BigInt{v}, nil
return BigInt{Int: v}, nil
}
func BigMul(a, b BigInt) BigInt {
return BigInt{big.NewInt(0).Mul(a.Int, b.Int)}
return BigInt{Int: big.NewInt(0).Mul(a.Int, b.Int)}
}
func BigDiv(a, b BigInt) BigInt {
return BigInt{big.NewInt(0).Div(a.Int, b.Int)}
return BigInt{Int: big.NewInt(0).Div(a.Int, b.Int)}
}
func BigMod(a, b BigInt) BigInt {
return BigInt{big.NewInt(0).Mod(a.Int, b.Int)}
return BigInt{Int: big.NewInt(0).Mod(a.Int, b.Int)}
}
func BigAdd(a, b BigInt) BigInt {
return BigInt{big.NewInt(0).Add(a.Int, b.Int)}
return BigInt{Int: big.NewInt(0).Add(a.Int, b.Int)}
}
func BigSub(a, b BigInt) BigInt {
return BigInt{big.NewInt(0).Sub(a.Int, b.Int)}
return BigInt{Int: big.NewInt(0).Sub(a.Int, b.Int)}
}
func BigCmp(a, b BigInt) int {

View File

@ -124,8 +124,8 @@ func toLotusMsg(msg *vtypes.Message) *types.Message {
Nonce: uint64(msg.CallSeqNum),
Method: msg.Method,
Value: types.BigInt{msg.Value.Int},
GasPrice: types.BigInt{msg.GasPrice.Int},
Value: types.BigInt{Int: msg.Value.Int},
GasPrice: types.BigInt{Int: msg.GasPrice.Int},
GasLimit: types.NewInt(uint64(msg.GasLimit)),
Params: msg.Params,

View File

@ -494,7 +494,6 @@ func (vm *VM) ApplyMessage(ctx context.Context, msg *types.Message) (*ApplyRet,
return nil, xerrors.Errorf("failed to look up from actor: %w", err)
}
gascost := types.BigMul(msg.GasLimit, msg.GasPrice)
totalCost := types.BigAdd(gascost, msg.Value)
if fromActor.Balance.LessThan(totalCost) {
@ -787,5 +786,5 @@ func MiningReward(remainingReward types.BigInt) types.BigInt {
res := ci.Mul(ci, build.InitialReward)
res = res.Div(res, miningRewardTotal.Int)
res = res.Div(res, blocksPerEpoch.Int)
return types.BigInt{res}
return types.BigInt{Int: res}
}

View File

@ -35,14 +35,10 @@ func (ks *keystore) Get(name string) (types.KeyInfo, error) {
func (ks *keystore) Delete(name string) error {
panic("Implement me")
return nil
}
func (ks *keystore) List() ([]string, error) {
panic("Implement me")
return []string{}, nil
}
var peerkeyCmd = &cli.Command{

View File

@ -409,7 +409,8 @@ func testControlChanDeadlock(t *testing.T) {
serverHandler.wait <- struct{}{}
}
ctx, _ := context.WithCancel(context.Background())
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
sub, err := client.Sub(ctx, 1, -1)
require.NoError(t, err)

View File

@ -116,7 +116,6 @@ func logHandler(api *api) func(http.ResponseWriter, *http.Request) {
id, err := strconv.ParseInt(path.Base(req.URL.Path), 10, 32)
if err != nil {
panic(err)
return
}
api.runningLk.Lock()

View File

@ -27,7 +27,8 @@ func (a *SyncAPI) SyncState(ctx context.Context) (*api.SyncState, error) {
out := &api.SyncState{}
for _, ss := range states {
for i := range states {
ss := &states[i]
out.ActiveSyncs = append(out.ActiveSyncs, api.ActiveSync{
Base: ss.Base,
Target: ss.Target,

View File

@ -159,8 +159,10 @@ func GetTips(ctx context.Context, api api.FullNode, lastHeight abi.ChainEpoch) (
log.Info("Running health check")
cctx, cancel := context.WithTimeout(ctx, 5*time.Second)
if _, err := api.ID(cctx); err != nil {
log.Error("Health check failed")
cancel()
return
}