some go vet fixes
This commit is contained in:
parent
56cb88819c
commit
16096e2c71
@ -18,7 +18,7 @@ var EmptyInt = BigInt{}
|
|||||||
type BigInt = big2.Int
|
type BigInt = big2.Int
|
||||||
|
|
||||||
func NewInt(i uint64) BigInt {
|
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 {
|
func FromFil(i uint64) BigInt {
|
||||||
@ -27,7 +27,7 @@ func FromFil(i uint64) BigInt {
|
|||||||
|
|
||||||
func BigFromBytes(b []byte) BigInt {
|
func BigFromBytes(b []byte) BigInt {
|
||||||
i := big.NewInt(0).SetBytes(b)
|
i := big.NewInt(0).SetBytes(b)
|
||||||
return BigInt{i}
|
return BigInt{Int: i}
|
||||||
}
|
}
|
||||||
|
|
||||||
func BigFromString(s string) (BigInt, error) {
|
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{}, 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 {
|
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 {
|
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 {
|
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 {
|
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 {
|
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 {
|
func BigCmp(a, b BigInt) int {
|
||||||
|
@ -124,8 +124,8 @@ func toLotusMsg(msg *vtypes.Message) *types.Message {
|
|||||||
Nonce: uint64(msg.CallSeqNum),
|
Nonce: uint64(msg.CallSeqNum),
|
||||||
Method: msg.Method,
|
Method: msg.Method,
|
||||||
|
|
||||||
Value: types.BigInt{msg.Value.Int},
|
Value: types.BigInt{Int: msg.Value.Int},
|
||||||
GasPrice: types.BigInt{msg.GasPrice.Int},
|
GasPrice: types.BigInt{Int: msg.GasPrice.Int},
|
||||||
GasLimit: types.NewInt(uint64(msg.GasLimit)),
|
GasLimit: types.NewInt(uint64(msg.GasLimit)),
|
||||||
|
|
||||||
Params: msg.Params,
|
Params: msg.Params,
|
||||||
|
@ -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)
|
return nil, xerrors.Errorf("failed to look up from actor: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gascost := types.BigMul(msg.GasLimit, msg.GasPrice)
|
gascost := types.BigMul(msg.GasLimit, msg.GasPrice)
|
||||||
totalCost := types.BigAdd(gascost, msg.Value)
|
totalCost := types.BigAdd(gascost, msg.Value)
|
||||||
if fromActor.Balance.LessThan(totalCost) {
|
if fromActor.Balance.LessThan(totalCost) {
|
||||||
@ -787,5 +786,5 @@ func MiningReward(remainingReward types.BigInt) types.BigInt {
|
|||||||
res := ci.Mul(ci, build.InitialReward)
|
res := ci.Mul(ci, build.InitialReward)
|
||||||
res = res.Div(res, miningRewardTotal.Int)
|
res = res.Div(res, miningRewardTotal.Int)
|
||||||
res = res.Div(res, blocksPerEpoch.Int)
|
res = res.Div(res, blocksPerEpoch.Int)
|
||||||
return types.BigInt{res}
|
return types.BigInt{Int: res}
|
||||||
}
|
}
|
||||||
|
@ -35,14 +35,10 @@ func (ks *keystore) Get(name string) (types.KeyInfo, error) {
|
|||||||
|
|
||||||
func (ks *keystore) Delete(name string) error {
|
func (ks *keystore) Delete(name string) error {
|
||||||
panic("Implement me")
|
panic("Implement me")
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ks *keystore) List() ([]string, error) {
|
func (ks *keystore) List() ([]string, error) {
|
||||||
panic("Implement me")
|
panic("Implement me")
|
||||||
|
|
||||||
return []string{}, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var peerkeyCmd = &cli.Command{
|
var peerkeyCmd = &cli.Command{
|
||||||
|
@ -409,7 +409,8 @@ func testControlChanDeadlock(t *testing.T) {
|
|||||||
serverHandler.wait <- struct{}{}
|
serverHandler.wait <- struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, _ := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
sub, err := client.Sub(ctx, 1, -1)
|
sub, err := client.Sub(ctx, 1, -1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -116,7 +116,6 @@ func logHandler(api *api) func(http.ResponseWriter, *http.Request) {
|
|||||||
id, err := strconv.ParseInt(path.Base(req.URL.Path), 10, 32)
|
id, err := strconv.ParseInt(path.Base(req.URL.Path), 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
api.runningLk.Lock()
|
api.runningLk.Lock()
|
||||||
|
@ -27,7 +27,8 @@ func (a *SyncAPI) SyncState(ctx context.Context) (*api.SyncState, error) {
|
|||||||
|
|
||||||
out := &api.SyncState{}
|
out := &api.SyncState{}
|
||||||
|
|
||||||
for _, ss := range states {
|
for i := range states {
|
||||||
|
ss := &states[i]
|
||||||
out.ActiveSyncs = append(out.ActiveSyncs, api.ActiveSync{
|
out.ActiveSyncs = append(out.ActiveSyncs, api.ActiveSync{
|
||||||
Base: ss.Base,
|
Base: ss.Base,
|
||||||
Target: ss.Target,
|
Target: ss.Target,
|
||||||
|
@ -159,8 +159,10 @@ func GetTips(ctx context.Context, api api.FullNode, lastHeight abi.ChainEpoch) (
|
|||||||
log.Info("Running health check")
|
log.Info("Running health check")
|
||||||
|
|
||||||
cctx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
cctx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
||||||
|
|
||||||
if _, err := api.ID(cctx); err != nil {
|
if _, err := api.ID(cctx); err != nil {
|
||||||
log.Error("Health check failed")
|
log.Error("Health check failed")
|
||||||
|
cancel()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user