Skip to content

Commit

Permalink
新增MpoolGetNonce方法
Browse files Browse the repository at this point in the history
  • Loading branch information
myxtype committed Apr 9, 2021
1 parent 6ebf482 commit b3b2547
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package filecoin

import (
"context"
"github.com/filecoin-project/go-address"
"github.com/ipfs/go-cid"
"github.com/myxtype/filecoin-client/types"
)
Expand All @@ -11,3 +12,8 @@ func (c *Client) MpoolPush(ctx context.Context, sm *types.SignedMessage) (cid.Ci
var id cid.Cid
return id, c.Request(ctx, c.FilecoinMethod("MpoolPush"), &id, sm)
}

// MpoolGetNonce 获取指定发送账号的下一个nonce值
func (c *Client) MpoolGetNonce(ctx context.Context, address address.Address) (nonce uint64, err error) {
return nonce, c.Request(ctx, c.FilecoinMethod("MpoolGetNonce"), &nonce, address)
}
23 changes: 23 additions & 0 deletions state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package filecoin

import (
"context"
"github.com/filecoin-project/go-address"
"github.com/ipfs/go-cid"
"testing"
)
Expand Down Expand Up @@ -44,3 +45,25 @@ func TestClient_StateSearchMsg(t *testing.T) {
t.Log(msg)
}
}

func TestClient_StateGetActor(t *testing.T) {
c := testClient()

address.CurrentNetwork = address.Mainnet

addr, _ := address.NewFromString("f3qx3jo74v6d6z35qhfeax3xozsegzliowrrchuyumshnwb2kz66xajhl55pxjr5xvvpeggioytv7uko5hpzga")

actor, err := c.StateGetActor(context.Background(), addr, nil)
if err != nil {
t.Error(err)
}

t.Log(actor.Nonce)

nonce, err := c.MpoolGetNonce(context.Background(), addr)
if err != nil {
t.Error(err)
}

t.Log(nonce)
}

0 comments on commit b3b2547

Please sign in to comment.