From eed1e2b647b6f2bf87aa360536e6692e467050bf Mon Sep 17 00:00:00 2001 From: tanlang Date: Thu, 20 Apr 2023 16:31:46 +0800 Subject: [PATCH] feat: set address.CurrentNetwork when launch up --- api/clients/node_client.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/api/clients/node_client.go b/api/clients/node_client.go index 62e7c682..5a478ef8 100644 --- a/api/clients/node_client.go +++ b/api/clients/node_client.go @@ -5,6 +5,7 @@ import ( "go.uber.org/fx" + "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-jsonrpc" "github.com/filecoin-project/venus-market/v2/config" @@ -12,6 +13,7 @@ import ( "github.com/filecoin-project/venus/venus-shared/api" v1api "github.com/filecoin-project/venus/venus-shared/api/chain/v1" + "github.com/filecoin-project/venus/venus-shared/types" "github.com/ipfs-force-community/metrics" ) @@ -26,6 +28,17 @@ func NodeClient(mctx metrics.MetricsCtx, lc fx.Lifecycle, nodeCfg *config.Node) } closer, err := jsonrpc.NewMergeClient(mctx, addr, "Filecoin", utils.GetInternalStructs(&fullNode), aInfo.AuthHeader()) + if err != nil { + return nil, err + } + + netName, err := fullNode.StateNetworkName(mctx) + if err != nil { + return nil, err + } + if netName == types.NetworkNameMain { + address.CurrentNetwork = address.Mainnet + } lc.Append(fx.Hook{ OnStop: func(_ context.Context) error {