From b3b2547b2c045334b2bd2bef2bf306f7ec46dd8f Mon Sep 17 00:00:00 2001 From: zhaobo Date: Fri, 9 Apr 2021 16:27:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EMpoolGetNonce=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mpool.go | 6 ++++++ state_test.go | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/mpool.go b/mpool.go index f788b3e..3e6e177 100644 --- a/mpool.go +++ b/mpool.go @@ -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" ) @@ -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) +} diff --git a/state_test.go b/state_test.go index fcc9787..4132883 100644 --- a/state_test.go +++ b/state_test.go @@ -2,6 +2,7 @@ package filecoin import ( "context" + "github.com/filecoin-project/go-address" "github.com/ipfs/go-cid" "testing" ) @@ -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) +}