Make gateway work with v1 api
This commit is contained in:
parent
deb2b90b6a
commit
d8bff4d19f
@ -31,7 +31,6 @@ type Gateway interface {
|
||||
StateAccountKey(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error)
|
||||
StateDealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, verified bool, tsk types.TipSetKey) (DealCollateralBounds, error)
|
||||
StateGetActor(ctx context.Context, actor address.Address, ts types.TipSetKey) (*types.Actor, error)
|
||||
StateGetReceipt(context.Context, cid.Cid, types.TipSetKey) (*types.MessageReceipt, error)
|
||||
StateListMiners(ctx context.Context, tsk types.TipSetKey) ([]address.Address, error)
|
||||
StateLookupID(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error)
|
||||
StateMarketBalance(ctx context.Context, addr address.Address, tsk types.TipSetKey) (MarketBalance, error)
|
||||
@ -40,8 +39,8 @@ type Gateway interface {
|
||||
StateMinerProvingDeadline(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*dline.Info, error)
|
||||
StateMinerPower(context.Context, address.Address, types.TipSetKey) (*MinerPower, error)
|
||||
StateNetworkVersion(context.Context, types.TipSetKey) (apitypes.NetworkVersion, error)
|
||||
StateSearchMsg(ctx context.Context, msg cid.Cid) (*MsgLookup, error)
|
||||
StateSectorGetInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (*miner.SectorOnChainInfo, error)
|
||||
StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*abi.StoragePower, error)
|
||||
StateWaitMsg(ctx context.Context, msg cid.Cid, confidence uint64) (*MsgLookup, error)
|
||||
StateSearchMsg(ctx context.Context, from types.TipSetKey, msg cid.Cid, limit abi.ChainEpoch, allowReplaced bool) (*MsgLookup, error)
|
||||
StateWaitMsg(ctx context.Context, cid cid.Cid, confidence uint64, limit abi.ChainEpoch, allowReplaced bool) (*MsgLookup, error)
|
||||
}
|
||||
|
@ -2095,21 +2095,6 @@ func (mr *MockFullNodeMockRecorder) StateGetActor(arg0, arg1, arg2 interface{})
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetActor", reflect.TypeOf((*MockFullNode)(nil).StateGetActor), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// StateGetReceipt mocks base method
|
||||
func (m *MockFullNode) StateGetReceipt(arg0 context.Context, arg1 cid.Cid, arg2 types.TipSetKey) (*types.MessageReceipt, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "StateGetReceipt", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(*types.MessageReceipt)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// StateGetReceipt indicates an expected call of StateGetReceipt
|
||||
func (mr *MockFullNodeMockRecorder) StateGetReceipt(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetReceipt", reflect.TypeOf((*MockFullNode)(nil).StateGetReceipt), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// StateListActors mocks base method
|
||||
func (m *MockFullNode) StateListActors(arg0 context.Context, arg1 types.TipSetKey) ([]address.Address, error) {
|
||||
m.ctrl.T.Helper()
|
||||
@ -2501,33 +2486,18 @@ func (mr *MockFullNodeMockRecorder) StateReplay(arg0, arg1, arg2 interface{}) *g
|
||||
}
|
||||
|
||||
// StateSearchMsg mocks base method
|
||||
func (m *MockFullNode) StateSearchMsg(arg0 context.Context, arg1 cid.Cid) (*api.MsgLookup, error) {
|
||||
func (m *MockFullNode) StateSearchMsg(arg0 context.Context, arg1 types.TipSetKey, arg2 cid.Cid, arg3 abi.ChainEpoch, arg4 bool) (*api.MsgLookup, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "StateSearchMsg", arg0, arg1)
|
||||
ret := m.ctrl.Call(m, "StateSearchMsg", arg0, arg1, arg2, arg3, arg4)
|
||||
ret0, _ := ret[0].(*api.MsgLookup)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// StateSearchMsg indicates an expected call of StateSearchMsg
|
||||
func (mr *MockFullNodeMockRecorder) StateSearchMsg(arg0, arg1 interface{}) *gomock.Call {
|
||||
func (mr *MockFullNodeMockRecorder) StateSearchMsg(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateSearchMsg", reflect.TypeOf((*MockFullNode)(nil).StateSearchMsg), arg0, arg1)
|
||||
}
|
||||
|
||||
// StateSearchMsgLimited mocks base method
|
||||
func (m *MockFullNode) StateSearchMsgLimited(arg0 context.Context, arg1 cid.Cid, arg2 abi.ChainEpoch) (*api.MsgLookup, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "StateSearchMsgLimited", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(*api.MsgLookup)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// StateSearchMsgLimited indicates an expected call of StateSearchMsgLimited
|
||||
func (mr *MockFullNodeMockRecorder) StateSearchMsgLimited(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateSearchMsgLimited", reflect.TypeOf((*MockFullNode)(nil).StateSearchMsgLimited), arg0, arg1, arg2)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateSearchMsg", reflect.TypeOf((*MockFullNode)(nil).StateSearchMsg), arg0, arg1, arg2, arg3, arg4)
|
||||
}
|
||||
|
||||
// StateSectorExpiration mocks base method
|
||||
@ -2651,33 +2621,18 @@ func (mr *MockFullNodeMockRecorder) StateVerifierStatus(arg0, arg1, arg2 interfa
|
||||
}
|
||||
|
||||
// StateWaitMsg mocks base method
|
||||
func (m *MockFullNode) StateWaitMsg(arg0 context.Context, arg1 cid.Cid, arg2 uint64) (*api.MsgLookup, error) {
|
||||
func (m *MockFullNode) StateWaitMsg(arg0 context.Context, arg1 cid.Cid, arg2 uint64, arg3 abi.ChainEpoch, arg4 bool) (*api.MsgLookup, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "StateWaitMsg", arg0, arg1, arg2)
|
||||
ret := m.ctrl.Call(m, "StateWaitMsg", arg0, arg1, arg2, arg3, arg4)
|
||||
ret0, _ := ret[0].(*api.MsgLookup)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// StateWaitMsg indicates an expected call of StateWaitMsg
|
||||
func (mr *MockFullNodeMockRecorder) StateWaitMsg(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
func (mr *MockFullNodeMockRecorder) StateWaitMsg(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateWaitMsg", reflect.TypeOf((*MockFullNode)(nil).StateWaitMsg), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// StateWaitMsgLimited mocks base method
|
||||
func (m *MockFullNode) StateWaitMsgLimited(arg0 context.Context, arg1 cid.Cid, arg2 uint64, arg3 abi.ChainEpoch) (*api.MsgLookup, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "StateWaitMsgLimited", arg0, arg1, arg2, arg3)
|
||||
ret0, _ := ret[0].(*api.MsgLookup)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// StateWaitMsgLimited indicates an expected call of StateWaitMsgLimited
|
||||
func (mr *MockFullNodeMockRecorder) StateWaitMsgLimited(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateWaitMsgLimited", reflect.TypeOf((*MockFullNode)(nil).StateWaitMsgLimited), arg0, arg1, arg2, arg3)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateWaitMsg", reflect.TypeOf((*MockFullNode)(nil).StateWaitMsg), arg0, arg1, arg2, arg3, arg4)
|
||||
}
|
||||
|
||||
// SyncCheckBad mocks base method
|
||||
|
@ -493,8 +493,6 @@ type GatewayStruct struct {
|
||||
|
||||
StateGetActor func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*types.Actor, error) ``
|
||||
|
||||
StateGetReceipt func(p0 context.Context, p1 cid.Cid, p2 types.TipSetKey) (*types.MessageReceipt, error) ``
|
||||
|
||||
StateListMiners func(p0 context.Context, p1 types.TipSetKey) ([]address.Address, error) ``
|
||||
|
||||
StateLookupID func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (address.Address, error) ``
|
||||
@ -511,13 +509,13 @@ type GatewayStruct struct {
|
||||
|
||||
StateNetworkVersion func(p0 context.Context, p1 types.TipSetKey) (apitypes.NetworkVersion, error) ``
|
||||
|
||||
StateSearchMsg func(p0 context.Context, p1 cid.Cid) (*MsgLookup, error) ``
|
||||
StateSearchMsg func(p0 context.Context, p1 types.TipSetKey, p2 cid.Cid, p3 abi.ChainEpoch, p4 bool) (*MsgLookup, error) ``
|
||||
|
||||
StateSectorGetInfo func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorOnChainInfo, error) ``
|
||||
|
||||
StateVerifiedClientStatus func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*abi.StoragePower, error) ``
|
||||
|
||||
StateWaitMsg func(p0 context.Context, p1 cid.Cid, p2 uint64) (*MsgLookup, error) ``
|
||||
StateWaitMsg func(p0 context.Context, p1 cid.Cid, p2 uint64, p3 abi.ChainEpoch, p4 bool) (*MsgLookup, error) ``
|
||||
}
|
||||
}
|
||||
|
||||
@ -2507,14 +2505,6 @@ func (s *GatewayStub) StateGetActor(p0 context.Context, p1 address.Address, p2 t
|
||||
return nil, xerrors.New("method not supported")
|
||||
}
|
||||
|
||||
func (s *GatewayStruct) StateGetReceipt(p0 context.Context, p1 cid.Cid, p2 types.TipSetKey) (*types.MessageReceipt, error) {
|
||||
return s.Internal.StateGetReceipt(p0, p1, p2)
|
||||
}
|
||||
|
||||
func (s *GatewayStub) StateGetReceipt(p0 context.Context, p1 cid.Cid, p2 types.TipSetKey) (*types.MessageReceipt, error) {
|
||||
return nil, xerrors.New("method not supported")
|
||||
}
|
||||
|
||||
func (s *GatewayStruct) StateListMiners(p0 context.Context, p1 types.TipSetKey) ([]address.Address, error) {
|
||||
return s.Internal.StateListMiners(p0, p1)
|
||||
}
|
||||
@ -2579,11 +2569,11 @@ func (s *GatewayStub) StateNetworkVersion(p0 context.Context, p1 types.TipSetKey
|
||||
return *new(apitypes.NetworkVersion), xerrors.New("method not supported")
|
||||
}
|
||||
|
||||
func (s *GatewayStruct) StateSearchMsg(p0 context.Context, p1 cid.Cid) (*MsgLookup, error) {
|
||||
return s.Internal.StateSearchMsg(p0, p1)
|
||||
func (s *GatewayStruct) StateSearchMsg(p0 context.Context, p1 types.TipSetKey, p2 cid.Cid, p3 abi.ChainEpoch, p4 bool) (*MsgLookup, error) {
|
||||
return s.Internal.StateSearchMsg(p0, p1, p2, p3, p4)
|
||||
}
|
||||
|
||||
func (s *GatewayStub) StateSearchMsg(p0 context.Context, p1 cid.Cid) (*MsgLookup, error) {
|
||||
func (s *GatewayStub) StateSearchMsg(p0 context.Context, p1 types.TipSetKey, p2 cid.Cid, p3 abi.ChainEpoch, p4 bool) (*MsgLookup, error) {
|
||||
return nil, xerrors.New("method not supported")
|
||||
}
|
||||
|
||||
@ -2603,11 +2593,11 @@ func (s *GatewayStub) StateVerifiedClientStatus(p0 context.Context, p1 address.A
|
||||
return nil, xerrors.New("method not supported")
|
||||
}
|
||||
|
||||
func (s *GatewayStruct) StateWaitMsg(p0 context.Context, p1 cid.Cid, p2 uint64) (*MsgLookup, error) {
|
||||
return s.Internal.StateWaitMsg(p0, p1, p2)
|
||||
func (s *GatewayStruct) StateWaitMsg(p0 context.Context, p1 cid.Cid, p2 uint64, p3 abi.ChainEpoch, p4 bool) (*MsgLookup, error) {
|
||||
return s.Internal.StateWaitMsg(p0, p1, p2, p3, p4)
|
||||
}
|
||||
|
||||
func (s *GatewayStub) StateWaitMsg(p0 context.Context, p1 cid.Cid, p2 uint64) (*MsgLookup, error) {
|
||||
func (s *GatewayStub) StateWaitMsg(p0 context.Context, p1 cid.Cid, p2 uint64, p3 abi.ChainEpoch, p4 bool) (*MsgLookup, error) {
|
||||
return nil, xerrors.New("method not supported")
|
||||
}
|
||||
|
||||
|
@ -18,4 +18,4 @@ func Wrap(proxyT, wrapperT, impl interface{}) interface{} {
|
||||
wp := reflect.New(reflect.TypeOf(wrapperT).Elem())
|
||||
wp.Field(0).Set(proxy)
|
||||
return wp.Interface()
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -50,6 +50,7 @@ var DaemonContext = cliutil.DaemonContext
|
||||
var ReqContext = cliutil.ReqContext
|
||||
|
||||
var GetFullNodeAPI = cliutil.GetFullNodeAPI
|
||||
var GetFullNodeAPIV1 = cliutil.GetFullNodeAPIV1
|
||||
var GetGatewayAPI = cliutil.GetGatewayAPI
|
||||
|
||||
var GetStorageMinerAPI = cliutil.GetStorageMinerAPI
|
||||
|
@ -6,12 +6,11 @@ package cli
|
||||
|
||||
import (
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
|
||||
go_address "github.com/filecoin-project/go-address"
|
||||
abi "github.com/filecoin-project/go-state-types/abi"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
go_cid "github.com/ipfs/go-cid"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
||||
// MockServicesAPI is a mock of ServicesAPI interface
|
||||
|
@ -3,6 +3,7 @@ package cliutil
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/filecoin-project/lotus/api/v1api"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
@ -187,6 +188,19 @@ func GetFullNodeAPI(ctx *cli.Context) (v0api.FullNode, jsonrpc.ClientCloser, err
|
||||
return client.NewFullNodeRPCV0(ctx.Context, addr, headers)
|
||||
}
|
||||
|
||||
func GetFullNodeAPIV1(ctx *cli.Context) (v1api.FullNode, jsonrpc.ClientCloser, error) {
|
||||
if tn, ok := ctx.App.Metadata["testnode-full"]; ok {
|
||||
return tn.(v1api.FullNode), func() {}, nil
|
||||
}
|
||||
|
||||
addr, headers, err := GetRawAPI(ctx, repo.FullNode, "v1")
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return client.NewFullNodeRPCV1(ctx.Context, addr, headers)
|
||||
}
|
||||
|
||||
type GetStorageMinerOptions struct {
|
||||
PreferHttp bool
|
||||
}
|
||||
|
@ -52,14 +52,13 @@ type gatewayDepsAPI interface {
|
||||
StateAccountKey(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error)
|
||||
StateDealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, verified bool, tsk types.TipSetKey) (api.DealCollateralBounds, error)
|
||||
StateGetActor(ctx context.Context, actor address.Address, ts types.TipSetKey) (*types.Actor, error)
|
||||
StateGetReceipt(context.Context, cid.Cid, types.TipSetKey) (*types.MessageReceipt, error)
|
||||
StateLookupID(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error)
|
||||
StateListMiners(ctx context.Context, tsk types.TipSetKey) ([]address.Address, error)
|
||||
StateMarketBalance(ctx context.Context, addr address.Address, tsk types.TipSetKey) (api.MarketBalance, error)
|
||||
StateMarketStorageDeal(ctx context.Context, dealId abi.DealID, tsk types.TipSetKey) (*api.MarketDeal, error)
|
||||
StateNetworkVersion(context.Context, types.TipSetKey) (network.Version, error)
|
||||
StateSearchMsgLimited(ctx context.Context, msg cid.Cid, lookbackLimit abi.ChainEpoch) (*api.MsgLookup, error)
|
||||
StateWaitMsgLimited(ctx context.Context, msg cid.Cid, confidence uint64, h abi.ChainEpoch) (*api.MsgLookup, error)
|
||||
StateSearchMsg(ctx context.Context, from types.TipSetKey, msg cid.Cid, limit abi.ChainEpoch, allowReplaced bool) (*api.MsgLookup, error)
|
||||
StateWaitMsg(ctx context.Context, cid cid.Cid, confidence uint64, limit abi.ChainEpoch, allowReplaced bool) (*api.MsgLookup, error)
|
||||
StateReadState(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*api.ActorState, error)
|
||||
StateMinerPower(context.Context, address.Address, types.TipSetKey) (*api.MinerPower, error)
|
||||
StateMinerFaults(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error)
|
||||
@ -74,6 +73,8 @@ type gatewayDepsAPI interface {
|
||||
StateVMCirculatingSupplyInternal(context.Context, types.TipSetKey) (api.CirculatingSupply, error)
|
||||
}
|
||||
|
||||
var _ gatewayDepsAPI = *new(api.FullNode) // gateway depends on latest
|
||||
|
||||
type GatewayAPI struct {
|
||||
api gatewayDepsAPI
|
||||
lookbackCap time.Duration
|
||||
@ -261,14 +262,6 @@ func (a *GatewayAPI) StateGetActor(ctx context.Context, actor address.Address, t
|
||||
return a.api.StateGetActor(ctx, actor, tsk)
|
||||
}
|
||||
|
||||
func (a *GatewayAPI) StateGetReceipt(ctx context.Context, c cid.Cid, tsk types.TipSetKey) (*types.MessageReceipt, error) {
|
||||
if err := a.checkTipsetKey(ctx, tsk); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return a.api.StateGetReceipt(ctx, c, tsk)
|
||||
}
|
||||
|
||||
func (a *GatewayAPI) StateListMiners(ctx context.Context, tsk types.TipSetKey) ([]address.Address, error) {
|
||||
if err := a.checkTipsetKey(ctx, tsk); err != nil {
|
||||
return nil, err
|
||||
@ -309,12 +302,29 @@ func (a *GatewayAPI) StateNetworkVersion(ctx context.Context, tsk types.TipSetKe
|
||||
return a.api.StateNetworkVersion(ctx, tsk)
|
||||
}
|
||||
|
||||
func (a *GatewayAPI) StateSearchMsg(ctx context.Context, msg cid.Cid) (*api.MsgLookup, error) {
|
||||
return a.api.StateSearchMsgLimited(ctx, msg, a.stateWaitLookbackLimit)
|
||||
func (a *GatewayAPI) StateSearchMsg(ctx context.Context, from types.TipSetKey, msg cid.Cid, limit abi.ChainEpoch, allowReplaced bool) (*api.MsgLookup, error) {
|
||||
if limit == api.LookbackNoLimit {
|
||||
limit = a.stateWaitLookbackLimit
|
||||
}
|
||||
if a.stateWaitLookbackLimit != api.LookbackNoLimit && limit > a.stateWaitLookbackLimit {
|
||||
limit = a.stateWaitLookbackLimit
|
||||
}
|
||||
if err := a.checkTipsetKey(ctx, from); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return a.api.StateSearchMsg(ctx, from, msg, limit, allowReplaced)
|
||||
}
|
||||
|
||||
func (a *GatewayAPI) StateWaitMsg(ctx context.Context, msg cid.Cid, confidence uint64) (*api.MsgLookup, error) {
|
||||
return a.api.StateWaitMsgLimited(ctx, msg, confidence, a.stateWaitLookbackLimit)
|
||||
func (a *GatewayAPI) StateWaitMsg(ctx context.Context, msg cid.Cid, confidence uint64, limit abi.ChainEpoch, allowReplaced bool) (*api.MsgLookup, error) {
|
||||
if limit == api.LookbackNoLimit {
|
||||
limit = a.stateWaitLookbackLimit
|
||||
}
|
||||
if a.stateWaitLookbackLimit != api.LookbackNoLimit && limit > a.stateWaitLookbackLimit {
|
||||
limit = a.stateWaitLookbackLimit
|
||||
}
|
||||
|
||||
return a.api.StateWaitMsg(ctx, msg, confidence, limit, allowReplaced)
|
||||
}
|
||||
|
||||
func (a *GatewayAPI) StateReadState(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*api.ActorState, error) {
|
||||
|
@ -11,6 +11,9 @@ import (
|
||||
promclient "github.com/prometheus/client_golang/prometheus"
|
||||
"go.opencensus.io/tag"
|
||||
|
||||
lapi "github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/api/v0api"
|
||||
"github.com/filecoin-project/lotus/api/v1api"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
lcli "github.com/filecoin-project/lotus/cli"
|
||||
"github.com/filecoin-project/lotus/lib/lotuslog"
|
||||
@ -82,7 +85,7 @@ var runCmd = &cli.Command{
|
||||
log.Fatalf("Cannot register the view: %v", err)
|
||||
}
|
||||
|
||||
api, closer, err := lcli.GetFullNodeAPI(cctx)
|
||||
api, closer, err := lcli.GetFullNodeAPIV1(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -93,14 +96,21 @@ var runCmd = &cli.Command{
|
||||
|
||||
log.Info("Setting up API endpoint at " + address)
|
||||
|
||||
serverOptions := make([]jsonrpc.ServerOption, 0)
|
||||
if maxRequestSize := cctx.Int("api-max-req-size"); maxRequestSize != 0 {
|
||||
serverOptions = append(serverOptions, jsonrpc.WithMaxRequestSize(int64(maxRequestSize)))
|
||||
}
|
||||
rpcServer := jsonrpc.NewServer(serverOptions...)
|
||||
rpcServer.Register("Filecoin", metrics.MetricedGatewayAPI(NewGatewayAPI(api)))
|
||||
serveRpc := func(path string, hnd interface{}) {
|
||||
serverOptions := make([]jsonrpc.ServerOption, 0)
|
||||
if maxRequestSize := cctx.Int("api-max-req-size"); maxRequestSize != 0 {
|
||||
serverOptions = append(serverOptions, jsonrpc.WithMaxRequestSize(int64(maxRequestSize)))
|
||||
}
|
||||
rpcServer := jsonrpc.NewServer(serverOptions...)
|
||||
rpcServer.Register("Filecoin", hnd)
|
||||
|
||||
mux.Handle("/rpc/v0", rpcServer) // todo: v1 support
|
||||
mux.Handle("/rpc/v1", rpcServer)
|
||||
}
|
||||
|
||||
ma := metrics.MetricedGatewayAPI(NewGatewayAPI(api))
|
||||
|
||||
serveRpc("/rpc/v1", ma)
|
||||
serveRpc("/rpc/v0", lapi.Wrap(new(v1api.FullNodeStruct), new(v0api.WrapperV1Full), ma))
|
||||
|
||||
registry := promclient.DefaultRegisterer.(*promclient.Registry)
|
||||
exporter, err := prometheus.NewExporter(prometheus.Options{
|
||||
|
@ -153,7 +153,6 @@
|
||||
* [StateDealProviderCollateralBounds](#StateDealProviderCollateralBounds)
|
||||
* [StateDecodeParams](#StateDecodeParams)
|
||||
* [StateGetActor](#StateGetActor)
|
||||
* [StateGetReceipt](#StateGetReceipt)
|
||||
* [StateListActors](#StateListActors)
|
||||
* [StateListMessages](#StateListMessages)
|
||||
* [StateListMiners](#StateListMiners)
|
||||
@ -181,7 +180,6 @@
|
||||
* [StateReadState](#StateReadState)
|
||||
* [StateReplay](#StateReplay)
|
||||
* [StateSearchMsg](#StateSearchMsg)
|
||||
* [StateSearchMsgLimited](#StateSearchMsgLimited)
|
||||
* [StateSectorExpiration](#StateSectorExpiration)
|
||||
* [StateSectorGetInfo](#StateSectorGetInfo)
|
||||
* [StateSectorPartition](#StateSectorPartition)
|
||||
@ -191,7 +189,6 @@
|
||||
* [StateVerifiedRegistryRootKey](#StateVerifiedRegistryRootKey)
|
||||
* [StateVerifierStatus](#StateVerifierStatus)
|
||||
* [StateWaitMsg](#StateWaitMsg)
|
||||
* [StateWaitMsgLimited](#StateWaitMsgLimited)
|
||||
* [Sync](#Sync)
|
||||
* [SyncCheckBad](#SyncCheckBad)
|
||||
* [SyncCheckpoint](#SyncCheckpoint)
|
||||
@ -3780,46 +3777,6 @@ Response:
|
||||
}
|
||||
```
|
||||
|
||||
### StateGetReceipt
|
||||
StateGetReceipt returns the message receipt for the given message or for a
|
||||
matching gas-repriced replacing message
|
||||
|
||||
NOTE: If the requested message was replaced, this method will return the receipt
|
||||
for the replacing message - if the caller needs the receipt for exactly the
|
||||
requested message, use StateSearchMsg().Receipt, and check that MsgLookup.Message
|
||||
is matching the requested CID
|
||||
|
||||
DEPRECATED: Use StateSearchMsg, this method won't be supported in v1 API
|
||||
|
||||
|
||||
Perms: read
|
||||
|
||||
Inputs:
|
||||
```json
|
||||
[
|
||||
{
|
||||
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
|
||||
},
|
||||
[
|
||||
{
|
||||
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
|
||||
},
|
||||
{
|
||||
"/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve"
|
||||
}
|
||||
]
|
||||
]
|
||||
```
|
||||
|
||||
Response:
|
||||
```json
|
||||
{
|
||||
"ExitCode": 0,
|
||||
"Return": "Ynl0ZSBhcnJheQ==",
|
||||
"GasUsed": 9
|
||||
}
|
||||
```
|
||||
|
||||
### StateListActors
|
||||
StateListActors returns the addresses of every actor in the state
|
||||
|
||||
@ -4660,7 +4617,7 @@ Response:
|
||||
```
|
||||
|
||||
### StateSearchMsg
|
||||
StateSearchMsg searches for a message in the chain, and returns its receipt and the tipset where it was executed
|
||||
StateSearchMsg looks back up to limit epochs in the chain for a message, and returns its receipt and the tipset where it was executed
|
||||
|
||||
NOTE: If a replacing message is found on chain, this method will return
|
||||
a MsgLookup for the replacing message - the MsgLookup.Message will be a different
|
||||
@ -4668,8 +4625,9 @@ CID than the one provided in the 'cid' param, MsgLookup.Receipt will contain the
|
||||
result of the execution of the replacing message.
|
||||
|
||||
If the caller wants to ensure that exactly the requested message was executed,
|
||||
they MUST check that MsgLookup.Message is equal to the provided 'cid'.
|
||||
Without this check both the requested and original message may appear as
|
||||
they must check that MsgLookup.Message is equal to the provided 'cid', or set the
|
||||
`allowReplaced` parameter to false. Without this check, and with `allowReplaced`
|
||||
set to true, both the requested and original message may appear as
|
||||
successfully executed on-chain, which may look like a double-spend.
|
||||
|
||||
A replacing message is a message with a different CID, any of Gas values, and
|
||||
@ -4682,25 +4640,7 @@ Perms: read
|
||||
Inputs:
|
||||
```json
|
||||
[
|
||||
{
|
||||
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
Response:
|
||||
```json
|
||||
{
|
||||
"Message": {
|
||||
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
|
||||
},
|
||||
"Receipt": {
|
||||
"ExitCode": 0,
|
||||
"Return": "Ynl0ZSBhcnJheQ==",
|
||||
"GasUsed": 9
|
||||
},
|
||||
"ReturnDec": {},
|
||||
"TipSet": [
|
||||
[
|
||||
{
|
||||
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
|
||||
},
|
||||
@ -4708,37 +4648,11 @@ Response:
|
||||
"/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve"
|
||||
}
|
||||
],
|
||||
"Height": 10101
|
||||
}
|
||||
```
|
||||
|
||||
### StateSearchMsgLimited
|
||||
StateSearchMsgLimited looks back up to limit epochs in the chain for a message, and returns its receipt and the tipset where it was executed
|
||||
|
||||
NOTE: If a replacing message is found on chain, this method will return
|
||||
a MsgLookup for the replacing message - the MsgLookup.Message will be a different
|
||||
CID than the one provided in the 'cid' param, MsgLookup.Receipt will contain the
|
||||
result of the execution of the replacing message.
|
||||
|
||||
If the caller wants to ensure that exactly the requested message was executed,
|
||||
they MUST check that MsgLookup.Message is equal to the provided 'cid'.
|
||||
Without this check both the requested and original message may appear as
|
||||
successfully executed on-chain, which may look like a double-spend.
|
||||
|
||||
A replacing message is a message with a different CID, any of Gas values, and
|
||||
different signature, but with all other parameters matching (source/destination,
|
||||
nonce, params, etc.)
|
||||
|
||||
|
||||
Perms: read
|
||||
|
||||
Inputs:
|
||||
```json
|
||||
[
|
||||
{
|
||||
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
|
||||
},
|
||||
10101
|
||||
10101,
|
||||
true
|
||||
]
|
||||
```
|
||||
|
||||
@ -5020,62 +4934,7 @@ Inputs:
|
||||
Response: `"0"`
|
||||
|
||||
### StateWaitMsg
|
||||
StateWaitMsg looks back in the chain for a message. If not found, it blocks until the
|
||||
message arrives on chain, and gets to the indicated confidence depth.
|
||||
|
||||
NOTE: If a replacing message is found on chain, this method will return
|
||||
a MsgLookup for the replacing message - the MsgLookup.Message will be a different
|
||||
CID than the one provided in the 'cid' param, MsgLookup.Receipt will contain the
|
||||
result of the execution of the replacing message.
|
||||
|
||||
If the caller wants to ensure that exactly the requested message was executed,
|
||||
they MUST check that MsgLookup.Message is equal to the provided 'cid'.
|
||||
Without this check both the requested and original message may appear as
|
||||
successfully executed on-chain, which may look like a double-spend.
|
||||
|
||||
A replacing message is a message with a different CID, any of Gas values, and
|
||||
different signature, but with all other parameters matching (source/destination,
|
||||
nonce, params, etc.)
|
||||
|
||||
|
||||
Perms: read
|
||||
|
||||
Inputs:
|
||||
```json
|
||||
[
|
||||
{
|
||||
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
|
||||
},
|
||||
42
|
||||
]
|
||||
```
|
||||
|
||||
Response:
|
||||
```json
|
||||
{
|
||||
"Message": {
|
||||
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
|
||||
},
|
||||
"Receipt": {
|
||||
"ExitCode": 0,
|
||||
"Return": "Ynl0ZSBhcnJheQ==",
|
||||
"GasUsed": 9
|
||||
},
|
||||
"ReturnDec": {},
|
||||
"TipSet": [
|
||||
{
|
||||
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
|
||||
},
|
||||
{
|
||||
"/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve"
|
||||
}
|
||||
],
|
||||
"Height": 10101
|
||||
}
|
||||
```
|
||||
|
||||
### StateWaitMsgLimited
|
||||
StateWaitMsgLimited looks back up to limit epochs in the chain for a message.
|
||||
StateWaitMsg looks back up to limit epochs in the chain for a message.
|
||||
If not found, it blocks until the message arrives on chain, and gets to the
|
||||
indicated confidence depth.
|
||||
|
||||
@ -5085,8 +4944,9 @@ CID than the one provided in the 'cid' param, MsgLookup.Receipt will contain the
|
||||
result of the execution of the replacing message.
|
||||
|
||||
If the caller wants to ensure that exactly the requested message was executed,
|
||||
they MUST check that MsgLookup.Message is equal to the provided 'cid'.
|
||||
Without this check both the requested and original message may appear as
|
||||
they must check that MsgLookup.Message is equal to the provided 'cid', or set the
|
||||
`allowReplaced` parameter to false. Without this check, and with `allowReplaced`
|
||||
set to true, both the requested and original message may appear as
|
||||
successfully executed on-chain, which may look like a double-spend.
|
||||
|
||||
A replacing message is a message with a different CID, any of Gas values, and
|
||||
@ -5103,7 +4963,8 @@ Inputs:
|
||||
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
|
||||
},
|
||||
42,
|
||||
10101
|
||||
10101,
|
||||
true
|
||||
]
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user