1、FullNodeAPI全节点接口
1.1 Lotus JSON-RPC API
JSON-RPC是在JSON中对远程过程调用进行编码的标准化方法。比特币和以太坊等项目已将其用于其API。
Lotus使用通过HTTP或Websocket传输的JSON-RPC调用在不同的守护程序和命令行工具之间进行通信。
例如,当您使用来运行Lotus节点的lotus daemon
,它将侦听TCP端口1234上的连接(默认情况下)。
应用程序可能会连接到此端口并发出JSON-RPC调用。
例如,使用CURL,如果我们想调用Filecoin.Version方法,我们可以这样做:
curl -X POST \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "Filecoin.Version",
"params": [],
"id": 1
}' \
http://192.168.1.71:1234/rpc/v0
例如,使用Go,如果我们想调用Filecoin.Version方法,我们可以这样做:
Lotus守护程序将返回类似于以下内容的响应:
{
"jsonrpc": "2.0",
"result": {
"Version": "1.8.0+mainnet+git.5c56017",
"APIVersion": 66048,
"BlockDelay": 30
},
"id": 1
}
大多数情况下,当您使用lotus
命令行客户端运行命令时,例如,lotus version
它实际上是使用WebSocket连接到守护程序,并且正在使用JSON-RPC执行方法。
Lotus的不同守护程序支持不同的方法集。执行时lotus daemon
,它将在端口1234(默认)上侦听,公开用于钱包,交易,检查链同步状态等的JSON-RPC方法。运行时lotus-storage-miner run
,它将在端口2345(默认)上侦听,并且有许多用于执行操作的方法,例如查询扇区的状态。
有关JSON-RPC API的更多详细信息,包括指向可用方法列表的链接,位于:docs.filecoin.io/reference/lotus-api
全节点分为几个模块的接口:
Auth:身份验证相关接口
Net:网络相关接口
Common:一些常用接口
Chain:链相关接口
Beacon:随机信标相关接口
Gas:gas费用相关接口
Sync:同步相关接口
Mpool:消息池相关接口
Miner:矿工相关接口
Wallet:钱包相关接口
Client:存储、检索市场客户端相关接口
State:链状态相关接口
Msig:多签钱包相关接口
Market:market市场相关接口
Paych:支付渠道的交互和管理相关接口
Other:其他一些接口
2、Auth相关接口
AuthVerify(ctx context.Context, token string) ([]auth.Permission, error)
AuthNew(ctx context.Context, perms []auth.Permission) ([]byte, error)
3、Net相关接口
NetConnectedness(context.Context, peer.ID) (network.Connectedness, error)
NetPeers(context.Context) ([]peer.AddrInfo, error)
NetConnect(context.Context, peer.AddrInfo) error
NetAddrsListen(context.Context) (peer.AddrInfo, error)
NetDisconnect(context.Context, peer.ID) error
NetFindPeer(context.Context, peer.ID) (peer.AddrInfo, error)
NetPubsubScores(context.Context) ([]PubsubScore, error)
NetAutoNatStatus(context.Context) (NatInfo, error)
NetAgentVersion(ctx context.Context, p peer.ID) (string, error)
NetPeerInfo(context.Context, peer.ID) (*ExtendedPeerInfo, error)
NetBandwidthStats(ctx context.Context) (metrics.Stats, error)
NetBandwidthStatsByPeer(ctx context.Context) (map[string]metrics.Stats, error)
NetBandwidthStatsByProtocol(ctx context.Context) (map[protocol.ID]metrics.Stats, error)
NetBlockAdd(ctx context.Context, acl NetBlockList) error
NetBlockRemove(ctx context.Context, acl NetBlockList) error
NetBlockList(ctx context.Context) (NetBlockList, error)
4、Common相关接口
ID(context.Context) (peer.ID, error)
Version(context.Context) (Version, error)
LogList(context.Context) ([]string, error)
LogSetLevel(context.Context, string, string) error
Shutdown(context.Context) error
Session(context.Context) (uuid.UUID, error)
Closing(context.Context) (<-chan struct{}, error)
5、Chain相关接口
Chain方法组包含与区块链交互的方法,但不需要任何形式的状态计算。
ChainNotify(context.Context) (<-chan []*HeadChange, error)
ChainHead(context.Context) (*types.TipSet, error)
ChainGetRandomnessFromTickets(ctx context.Context, tsk types.TipSetKey, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error)
ChainGetRandomnessFromBeacon(ctx context.Context, tsk types.TipSetKey, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error)
ChainGetBlock(context.Context, cid.Cid) (*types.BlockHeader, error)
ChainGetTipSet(context.Context, types.TipSetKey) (*types.TipSet, error)
ChainGetBlockMessages(ctx context.Context, blockCid cid.Cid) (*BlockMessages, error)
ChainGetParentReceipts(ctx context.Context, blockCid cid.Cid) ([]*types.MessageReceipt, error)
ChainGetParentMessages(ctx context.Context, blockCid cid.Cid) ([]Message, error)
ChainGetTipSetByHeight(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error)
ChainReadObj(context.Context, cid.Cid) ([]byte, error)
ChainDeleteObj(context.Context, cid.Cid) error
ChainHasObj(context.Context, cid.Cid) (bool, error)
ChainStatObj(ctx context.Context, obj cid.Cid, base cid.Cid) (ObjStat, error)
ChainSetHead(context.Context, types.TipSetKey) error
ChainGetGenesis(context.Context) (*types.TipSet, error)
ChainTipSetWeight(context.Context, types.TipSetKey) (types.BigInt, error)
ChainGetNode(ctx context.Context, p string) (*IpldObject, error)
ChainGetMessage(context.Context, cid.Cid) (*types.Message, error)
ChainGetPath(ctx context.Context, from types.TipSetKey, to types.TipSetKey) ([]*HeadChange, error)
ChainExport(ctx context.Context, nroots abi.ChainEpoch, oldmsgskip bool, tsk types.TipSetKey) (<-chan []byte, error)
5.1 ChainNotify
// ChainNotify返回链头更新的channel。第一条消息保证len == 1, type == 'current'。
ChainNotify(context.Context) (<-chan []*HeadChange, error)
Parameters:
- ctx context.Context
Returns:
- <-chan []*HeadChange链头更新的channel
- error
5.2 ChainHead
// ChainHead返回当前的链头。
ChainHead(context.Context) (*types.TipSet, error)
Parameters:
- ctx context.Context
Returns:
- *types.TipSet当前链头所对应的TipSet
- error
5.3 ChainGetRandomnessFromTickets
// ChainGetRandomnessFromTickets用于对链进行随机抽样
ChainGetRandomnessFromTickets(ctx context.Context, tsk types.TipSetKey, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error)
Parameters:
- ctx context.Context
- tsk types.TipSetKey
- personalization crypto.DomainSeparationTag
- randEpoch abi.ChainEpoch
- entropy []byte
Returns:
- abi.Randomness一串随机的字节
- error
5.4 ChainGetRandomnessFromBeacon
// ChainGetRandomnessFromBeacon用于对信标进行随机抽样
ChainGetRandomnessFromBeacon(ctx context.Context, tsk types.TipSetKey, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error)
Parameters:
- ctx context.Context
- tsk types.TipSetKey
- personalization crypto.DomainSeparationTag
- randEpoch abi.ChainEpoch
- entropy []byte
Returns:
- abi.Randomness一串随机的字节
- error
5.5 ChainGetBlock
// ChainGetBlock 通过给定的Cid取出指定的Block区块
ChainGetBlock(context.Context, cid.Cid) (*types.BlockHeader, error)
Parameters:
- context.Context
- cid.Cid
Returns:
- *types.BlockHeader保存Block信息的结构体
- error
5.6 ChainGetTipSet
// ChainGetTipSet 通过给定的TipSetKey取出指定的TipSet
ChainGetTipSet(context.Context, types.TipSetKey) (*types.TipSet, error)
Parameters:
- context.Context
- types.TipSetKey是一个不可变的cid集合,它为一个tipse生成一个唯一的key
Returns:
- *types.TipSet
- error
5.7 ChainGetBlockMessages
// ChainGetBlockMessages 通过区块cid取出区块中所有的消息
ChainGetBlockMessages(ctx context.Context, blockCid cid.Cid) (*BlockMessages, error)
Parameters:
- ctx context.Context
- blockCid cid.Cid
Returns:
- *BlockMessages 区块保存所有消息的结构体
- error
5.8 ChainGetParentReceipts
// ChainGetParentReceipts返回指定块的父参数集中的消息收据。
ChainGetParentReceipts(ctx context.Context, blockCid cid.Cid) ([]*types.MessageReceipt, error)
Parameters:
- ctx context.Context
- blockCid cid.Cid
Returns:
- []*types.MessageReceipt 消息的收据(执行结果、返回内容、使用多少Gas等)
- error
5.9 ChainGetParentMessages
// ChainGetParentMessages返回指定块的父区块的消息集合。
ChainGetParentMessages(ctx context.Context, blockCid cid.Cid) ([]Message, error)
Parameters:
- ctx context.Context
- blockCid cid.Cid
Returns:
- []Message
- error
5.10 ChainGetTipSetByHeight
// ChainGetTipSetByHeight查找指定epoch的tipset,如果在指定的epoch中没有块,则返回上一个epoch的一个tipset。ChainGetTipSetByHeight(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error)
Parameters:
- ctx context.Context
- abi.ChainEpoch
- types.TipSetKey
Returns:
- *types.TipSet
- error
go实现:
func main() {
url := "http://192.168.1.71:1234/rpc/v0"
method := "POST"
payload := strings.NewReader(`{
"jsonrpc": "2.0",
"method": "Filecoin.ChainGetTipSetByHeight",
"id": 1,
"params": [1, null]
}`)
startTime := time.Now()
client := &http.Client{}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBbGxvdyI6WyJyZWFkIiwid3JpdGUiLCJzaWduIiwiYWRtaW4iXX0.TrxhxiEhw0fq-KiK1j3JALnDb9Z7MNicVl57lQL4SCU")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
tc := time.Since(startTime)
fmt.Printf("Filecoin.ChainGetTipSetByHeight time: %d ms\n", tc.Milliseconds())
}
5.11 ChainReadObj
// ChainReadObj从chain blockstore中读取指定cid引用的ipld节点,并返回原始字节。
ChainReadObj(context.Context, cid.Cid) ([]byte, error)
Parameters:
- ctx context.Context
- cid.Cid
Returns:
- []byte
- error
5.12 ChainDeleteObj
// ChainDeleteObj删除给定cid引用的ipld节点.
ChainDeleteObj(context.Context, cid.Cid) error
Parameters:
- ctx context.Context
- cid.Cid
Returns:
- error
5.13 ChainHasObj
// ChainHasObj检查一个给定的cid是否存在于链的blockstore中。
ChainHasObj(context.Context, cid.Cid) (bool, error)
Parameters:
- ctx context.Context
- cid.Cid
Returns:
- bool
- error
5.14 ChainHasObj
// ChainStatObj返回'obj'引用的图形的统计信息。如果还指定了“base”,那么返回的stat将是两个对象之间的差异。
ChainStatObj(ctx context.Context, obj cid.Cid, base cid.Cid) (ObjStat, error)
Parameters:
- ctx context.Context
- obj cid.Cid
- base cid.Cid
Returns:
- ObjStat
- error
5.15 ChainSetHead
// ChainSetHead强制设置当前链头
ChainSetHead(context.Context, types.TipSetKey) error
Parameters:
- ctx context.Context
- types.TipSetKey
Returns:
- error
5.16 ChainGetGenesis
// ChainGetGenesis返回创世的TipSet
ChainGetGenesis(context.Context) (*types.TipSet, error)
Parameters:
- ctx context.Context
Returns:
- *types.TipSet
- error
5.17 ChainTipSetWeight
// ChainTipSetWeight计算指定的TipSet的权重。
ChainTipSetWeight(context.Context, types.TipSetKey) (types.BigInt, error)
Parameters:
- ctx context.Context
- types.TipSetKey
Returns:
- types.BigInt
- error
5.18 ChainGetNode
// ChainGetNode通过p获取对应的IpldObject
ChainGetNode(ctx context.Context, p string) (*IpldObject, error)
Parameters:
- ctx context.Context
- p string
Returns:
- *IpldObject
- error
5.19 ChainGetMessage
// ChainGetMessage从链块存储(blockstore)中读取指定cid引用的消息。
ChainGetMessage(context.Context, cid.Cid) (*types.Message, error)
Parameters:
- ctx context.Context
- cid.Cid
Returns:
- *types.Message
- error
5.20 ChainGetPath
// ChainGetPath返回从一个tipset到另一个tipset所需的一组revert/apply操作,例如:
//```
// to
// ^
// from tAA
// ^ ^
// tBA tAB
// ^---*--^
// ^
// tRR
//```
// Would return `[revert(tBA), apply(tAB), apply(tAA)]`
// 链被fork的时候用到
ChainGetPath(ctx context.Context, from types.TipSetKey, to types.TipSetKey) ([]*HeadChange, error)
Parameters:
- ctx context.Context
- from types.TipSetKey
- to types.TipSetKey
Returns:
- []*HeadChange链头改变时对应的TipSet和类型(revert,apply)
- error
5.21 ChainExport
//ChainExport返回一个转存链数据的CAR的字节流。导出的链数据包括从给定的tipset返回到起源的头链、整个genesis状态和最近的'nroot '状态树。如果设置了oldmsgskip,则来自请求根目录之前的消息也不包括在内。
ChainExport(ctx context.Context, nroots abi.ChainEpoch, oldmsgskip bool, tsk types.TipSetKey) (<-chan []byte, error)
Parameters:
- ctx context.Context
- nroots abi.ChainEpoch
- oldmsgskip bool
- tsk types.TipSetKey
Returns:
- <-chan []byte
- error
6、Beacon相关接口
Beacon方法包含用于与随机信标(DRAND)交互的方法。
BeaconGetEntry(ctx context.Context, epoch abi.ChainEpoch) (*types.BeaconEntry, error)
6.1 BeaconGetEntry
BeaconGetEntry返回给定filecoin epoch的beacon entry。如果entry尚未生成,将会阻塞,直到entry可用为止。
Parameters:
- ctx context.Context
- epoch abi.ChainEpoch
Returns:
- *types.BeaconEntry
- error
7、Gas费用相关接口
GasEstimateFeeCap(context.Context, *types.Message, int64, types.TipSetKey) (types.BigInt, error)
GasEstimateGasLimit(context.Context, *types.Message, types.TipSetKey) (int64, error)
GasEstimateGasPremium(_ context.Context, nblocksincl uint64, sender address.Address, gaslimit int64, tsk types.TipSetKey) (types.BigInt, error)
GasEstimateMessageGas(context.Context, *types.Message, *MessageSendSpec, types.TipSetKey) (*types.Message, error)
7.1 GasEstimateFeeCap
// GasEstimateFeeCap 估算gas费用的上限
GasEstimateFeeCap(context.Context, *types.Message, int64, types.TipSetKey) (types.BigInt, error)
Parameters:
- ctx context.Context
- *types.Message
- int64
- types.TipSetKey
Returns:
- types.BigInt
- error
7.2 GasEstimateGasLimit
// GasEstimateGasLimit估计消息使用的gas量并返回它。如果消息未能执行,则失败。
GasEstimateGasLimit(context.Context, *types.Message, types.TipSetKey) (int64, error)
Parameters:
- ctx context.Context
- *types.Message
- types.TipSetKey
Returns:
- int64
- error
7.3 GasEstimateGasPremium
// GasEstimateGasPremium估计了在“nblocksincl”epoch中可能包含的消息应该使用的gas价格。
GasEstimateGasPremium(_ context.Context, nblocksincl uint64,sender address.Address, gaslimit int64, tsk types.TipSetKey) (types.BigInt, error)
Parameters:
- ctx context.Context
- nblocksincl uint64
- sender address.Address
- gaslimit int64
- tsk types.TipSetKey
Returns:
- types.BigInt
- error
7.4 GasEstimateMessageGas
// GasEstimateMessageGas估计未设置的消息gas属性的gas值
GasEstimateMessageGas(context.Context, *types.Message, *MessageSendSpec, types.TipSetKey) (*types.Message, error)
Parameters:
- ctx context.Context
- *types.Message
- *MessageSendSpec
- tsk types.TipSetKey
Returns:
- *types.Message
- error
8、Sync相关接口
Sync方法组包含与lotus Sync服务交互和观察的方法。
SyncState(context.Context) (*SyncState, error)
SyncSubmitBlock(ctx context.Context, blk *types.BlockMsg) error
SyncIncomingBlocks(ctx context.Context) (<-chan *types.BlockHeader, error)
SyncCheckpoint(ctx context.Context, tsk types.TipSetKey) error
SyncMarkBad(ctx context.Context, bcid cid.Cid) error
SyncUnmarkBad(ctx context.Context, bcid cid.Cid) error
SyncUnmarkAllBad(ctx context.Context) error
SyncCheckBad(ctx context.Context, bcid cid.Cid) (string, error)
SyncValidateTipset(ctx context.Context, tsk types.TipSetKey) (bool, error)
8.1 SyncState
// SyncState返回lotus同步系统的当前状态。
SyncState(context.Context) (*SyncState, error)
Parameters:
- context.Context
Returns:
- *SyncState
- error
8.2 SyncSubmitBlock
// SyncSubmitBlock可用于通过该节点向网络提交新创建的块
SyncSubmitBlock(ctx context.Context, blk *types.BlockMsg) error
Parameters:
- ctx context.Context
- blk *types.BlockMsg
Returns:
- error
8.3 SyncIncomingBlocks
// SyncIncomingBlocks返回一个流传入的channel,同步可能还没有同步块头。
SyncIncomingBlocks(ctx context.Context) (<-chan *types.BlockHeader, error)
Parameters:
- ctx context.Context
Returns:
- <-chan *types.BlockHeader
- error
8.4 SyncCheckpoint
// SyncCheckpoint将一个块标记为检查点,这意味着它永远不会离开它。
SyncCheckpoint(ctx context.Context, tsk types.TipSetKey) error
Parameters:
- ctx context.Context
- tsk types.TipSetKey
Returns:
- error
8.5 SyncMarkBad
// SyncMarkBad将一个块标记为bad,意味着它永远不会被同步。
SyncMarkBad(ctx context.Context, bcid cid.Cid) error
Parameters:
- ctx context.Context
- bcid cid.Cid
Returns:
- error
8.6 SyncUnmarkBad
// SyncUnmarkBad将代码块解除bad标记,这样就可以再次验证和同步。
SyncUnmarkBad(ctx context.Context, bcid cid.Cid) error
Parameters:
- ctx context.Context
- bcid cid.Cid
Returns:
- error
8.7 SyncUnmarkAllBad
// SyncUnmarkAllBad清除坏块缓存,使同步到之前标记为坏的链成为可能。
SyncUnmarkAllBad(ctx context.Context) error
Parameters:
- ctx context.Context
Returns:
- error
8.8 SyncCheckBad
// SyncCheckBad检查一个块是否被标记为bad,如果是,返回原因。
SyncCheckBad(ctx context.Context, bcid cid.Cid) (string, error)
Parameters:
- ctx context.Context
- bcid cid.Cid
Returns:
- string
- error
8.9 SyncValidateTipset
// SyncValidateTipset指示提供的tipset是否有效。
SyncValidateTipset(ctx context.Context, tsk types.TipSetKey) (bool, error)
Parameters:
- ctx context.Context
- tsk types.TipSetKey
Returns:
- bool
- error
9、Mpool相关接口
Mpool方法用于与消息池交互。消息池管理通过网络发送的所有传入和传出的“消息”。
MpoolPending(context.Context, types.TipSetKey) ([]*types.SignedMessage, error)
MpoolSelect(context.Context, types.TipSetKey, float64) ([]*types.SignedMessage, error)
MpoolPush(context.Context, *types.SignedMessage) (cid.Cid, error)
MpoolPushUntrusted(context.Context, *types.SignedMessage) (cid.Cid, error)
MpoolPushMessage(ctx context.Context, msg *types.Message, spec *MessageSendSpec) (*types.SignedMessage, error)
MpoolBatchPush(context.Context, []*types.SignedMessage) ([]cid.Cid, error)
MpoolBatchPushUntrusted(context.Context, []*types.SignedMessage) ([]cid.Cid, error)
MpoolBatchPushMessage(context.Context, []*types.Message, *MessageSendSpec) ([]*types.SignedMessage, error)
MpoolGetNonce(context.Context, address.Address) (uint64, error)
MpoolSub(context.Context) (<-chan MpoolUpdate, error)
MpoolClear(context.Context, bool) error
MpoolSetConfig(context.Context, *types.MpoolConfig) error
9.1 MpoolPending
// MpoolPending返回挂起的内存池消息。
MpoolPending(context.Context, types.TipSetKey) ([]*types.SignedMessage, error)
Parameters:
- context.Context
- types.TipSetKey
Returns:
- []*types.SignedMessage
- error
9.2 MpoolSelect
// MpoolSelect返回一个挂起消息列表,以便包含在下一个块中。
MpoolSelect(context.Context, types.TipSetKey, float64) ([]*types.SignedMessage, error)
Parameters:
- context.Context
- types.TipSetKey
- float64
Returns:
- []*types.SignedMessage
- error
9.3 MpoolPush
// MpoolPush将已签名的消息推送到内存池。
MpoolPush(context.Context, *types.SignedMessage) (cid.Cid, error)
Parameters:
- context.Context
- *types.SignedMessage
Returns:
- cid.Cid
- error
9.4 MpoolPushUntrusted
// MpoolPushUntrusted将一条已签名的消息从不受信任的源推送到mempool。
MpoolPushUntrusted(context.Context, *types.SignedMessage) (cid.Cid, error)
Parameters:
- context.Context
- types.TipSetKey
Returns:
- cid.Cid
- error
9.5 MpoolPushMessage
// MpoolPushMessage自动分配一个nonce、signs,并将消息推送到mempool。
// MessageSendSpec.MaxFee仅在GasFeeCap/GasPremium字段未指定时使用。当maxFee设置为0时,MpoolPushMessage将根据当前的链条件猜测适当的费用。
MpoolPushMessage(ctx context.Context, msg *types.Message, spec *MessageSendSpec) (*types.SignedMessage, error)
Parameters:
- context.Context
- msg *types.Message
- spec *MessageSendSpec
Returns:
- []*types.SignedMessage
- error
9.6 MpoolBatchPush
// MpoolBatchPush批量将已签名的消息推送到内存池。
MpoolBatchPush(context.Context, []*types.SignedMessage) ([]cid.Cid, error)
Parameters:
- context.Context
- []*types.SignedMessage
Returns:
- []cid.Cid
- error
9.7 MpoolBatchPushUntrusted
// MpoolBatchPushUntrusted批量将已签名的消息从不受信任的源推送到mempool。
MpoolBatchPushUntrusted(context.Context, []*types.SignedMessage) ([]cid.Cid, error)
Parameters:
- context.Context
- []*types.SignedMessage
Returns:
- []cid.Cid
- error
9.8 MpoolBatchPushMessage
// MpoolBatchPushMessage批量将未签名消息推送到内存池。
MpoolBatchPushMessage(context.Context, []*types.Message, *MessageSendSpec) ([]*types.SignedMessage, error)
Parameters:
- context.Context
- []*types.Message
- *MessageSendSpec
Returns:
- []*types.SignedMessage
- error
9.9 MpoolGetNonce
// MpoolGetNonce获取指定发送方的下一个nonce。注意,这个方法可能不是原子的。使用MpoolPushMessage代替。
MpoolGetNonce(context.Context, address.Address) (uint64, error)
Parameters:
- context.Context
- address.Address
Returns:
- uint64
- error
9.10 MpoolSub
// MpoolSub。
MpoolSub(context.Context) (<-chan MpoolUpdate, error)
Parameters:
- context.Context
Returns:
- <-chan MpoolUpdate
- error
9.11 MpoolClear
// MpoolClear清除mpool中挂起的消息。
MpoolClear(context.Context, bool) error
Parameters:
- context.Context
- bool
Returns:
- error
9.12 MpoolGetConfig
// MpoolGetConfig返回当前mpool配置(副本)。
MpoolGetConfig(context.Context) (*types.MpoolConfig, error)
Parameters:
- context.Context
Returns:
- *types.MpoolConfig
- error
9.13 MpoolSetConfig
// MpoolSetConfig将mpool配置设置为所提供的配置(副本)。
MpoolSetConfig(context.Context, *types.MpoolConfig) error
Parameters:
- context.Context
- *types.MpoolConfig
Returns:
- error
10、 Miner相关接口
MinerGetBaseInfo(context.Context, address.Address, abi.ChainEpoch, types.TipSetKey) (*MiningBaseInfo, error)
MinerCreateBlock(context.Context, *BlockTemplate) (*types.BlockMsg, error)
10.1 MinerGetBaseInfo
// MinerGetBaseInfo获取矿工基本信息。
MinerGetBaseInfo(context.Context, address.Address, abi.ChainEpoch, types.TipSetKey) (*MiningBaseInfo, error)
Parameters:
- context.Context
- address.Address
- abi.ChainEpoch
- types.TipSetKey
Returns:
- *MiningBaseInfo
- error
10.2 MinerCreateBlock
// MinerCreateBlock矿工创建区块。
MinerCreateBlock(context.Context, *BlockTemplate) (*types.BlockMsg, error)
Parameters:
- context.Context
- *BlockTemplate
Returns:
- *types.BlockMsg
- error
11、Wallet相关接口
WalletNew(context.Context, types.KeyType) (address.Address, error)
WalletHas(context.Context, address.Address) (bool, error)
WalletList(context.Context) ([]address.Address, error)
WalletBalance(context.Context, address.Address) (types.BigInt, error)
WalletSign(context.Context, address.Address, []byte) (*crypto.Signature, error)
WalletSignMessage(context.Context, address.Address, *types.Message) (*types.SignedMessage, error)
WalletVerify(context.Context, address.Address, []byte, *crypto.Signature) (bool, error)
WalletDefaultAddress(context.Context) (address.Address, error)
WalletSetDefault(context.Context, address.Address) error
WalletExport(context.Context, address.Address) (*types.KeyInfo, error)
WalletImport(context.Context, *types.KeyInfo) (address.Address, error)
WalletDelete(context.Context, address.Address) error
WalletValidateAddress(context.Context, string) (address.Address, error)
11.1 WalletNew
// WalletNew使用给定的sigType在钱包中创建一个新地址。
// 可用的键类型:bls, secp256k1, secp256k1-ledger
// 支持数值类型:1- secp256k1, 2 - bls是被废弃的。
WalletNew(context.Context, types.KeyType) (address.Address, error)
Parameters:
- context.Context
- types.KeyType
Returns:
- address.Address
- error
11.2 WalletHas
// WalletHas表示给定的地址是否在钱包中。
WalletHas(context.Context, address.Address) (bool, error)
Parameters:
- context.Context
- address.Address
Returns:
- bool
- error
11.3 WalletList
// WalletList列出了钱包里所有的地址。
WalletList(context.Context) ([]address.Address, error)
Parameters:
- context.Context
Returns:
- []address.Address
- error
11.4 WalletBalance
// WalletBalance返回链的当前头的给定地址的余额。
WalletBalance(context.Context, address.Address) (types.BigInt, error)
Parameters:
- context.Context
- address.Address
Returns:
- types.BigInt
- error
11.5 WalletSign
// WalletSign使用给定的地址对给定的字节进行签名。
WalletSign(context.Context, address.Address, []byte) (*crypto.Signature, error)
Parameters:
- context.Context
- address.Address
- []byte
Returns:
- *crypto.Signature
- error
11.6 WalletSignMessage
// WalletSignMessage使用给定的地址对给定的消息进行签名。
WalletSignMessage(context.Context, address.Address, *types.Message) (*types.SignedMessage, error)
Parameters:
- context.Context
- address.Address
- *types.Message
Returns:
- *types.SignedMessage
- error
11.7 WalletVerify
// WalletVerify接受一个地址、一个签名和一些字节,并指示签名是否有效。地址不一定要在钱包里。
WalletVerify(context.Context, address.Address, []byte, *crypto.Signature) (bool, error)
Parameters:
- context.Context
- address.Address
- []byte
- *crypto.Signature
Returns:
- bool
- error
11.8 WalletDefaultAddress
// WalletDefaultAddress返回钱包中标记为默认的地址。
WalletDefaultAddress(context.Context) (address.Address, error)
Parameters:
- context.Context
Returns:
- address.Address
- error
11.9 WalletSetDefault
// WalletSetDefault将给定的地址标记为默认地址。
WalletSetDefault(context.Context, address.Address) error
Parameters:
- context.Context
- address.Address
Returns:
- error
11.10 WalletExport
// WalletExport返回钱包中地址的私钥。
WalletExport(context.Context, address.Address) (*types.KeyInfo, error)
Parameters:
- context.Context
- address.Address
Returns:
- *types.KeyInfo
- error
11.11 WalletImport
// WalletImport接收包含私钥的KeyInfo,并将其导入钱包。
WalletImport(context.Context, *types.KeyInfo) (address.Address, error)
Parameters:
- context.Context
- *types.KeyInfo
Returns:
- address.Address
- error
11.12 WalletDelete
// WalletDelete从钱包中删除一个地址。
WalletDelete(context.Context, address.Address) error
Parameters:
- context.Context
- address.Address
Returns:
- error
11.13 WalletValidateAddress
// WalletValidateAddress验证给定的字符串是否可以被解码为格式良好的地址
WalletValidateAddress(context.Context, string) (address.Address, error)
Parameters:
- context.Context
- string
Returns:
- address.Address
- error
12、Client相关接口
Client方法都必须作为客户端与存储和检索市场进行交互。
ClientImport(ctx context.Context, ref FileRef) (*ImportRes, error)
ClientRemoveImport(ctx context.Context, importID multistore.StoreID) error
ClientStartDeal(ctx context.Context, params *StartDealParams) (*cid.Cid, error)
ClientGetDealInfo(context.Context, cid.Cid) (*DealInfo, error)
ClientListDeals(ctx context.Context) ([]DealInfo, error)
ClientGetDealUpdates(ctx context.Context) (<-chan DealInfo, error)
ClientGetDealStatus(ctx context.Context, statusCode uint64) (string, error)
ClientHasLocal(ctx context.Context, root cid.Cid) (bool, error)
ClientFindData(ctx context.Context, root cid.Cid, piece *cid.Cid) ([]QueryOffer, error)
ClientMinerQueryOffer(ctx context.Context, miner address.Address, root cid.Cid, piece *cid.Cid) (QueryOffer, error)
ClientRetrieve(ctx context.Context, order RetrievalOrder, ref *FileRef) error
ClientRetrieveWithEvents(ctx context.Context, order RetrievalOrder, ref *FileRef) (<-chan marketevents.RetrievalEvent, error)
ClientQueryAsk(ctx context.Context, p peer.ID, miner address.Address) (*storagemarket.StorageAsk, error)
ClientDealPieceCID(ctx context.Context, root cid.Cid) (DataCIDSize, error)
ClientCalcCommP(ctx context.Context, inpath string) (*CommPRet, error)
ClientGenCar(ctx context.Context, ref FileRef, outpath string) error
ClientDealSize(ctx context.Context, root cid.Cid) (DataSize, error)
ClientListDataTransfers(ctx context.Context) ([]DataTransferChannel, error)
ClientDataTransferUpdates(ctx context.Context) (<-chan DataTransferChannel, error)
ClientRestartDataTransfer(ctx context.Context, transferID datatransfer.TransferID, otherPeer peer.ID, isInitiator bool) error
ClientCancelDataTransfer(ctx context.Context, transferID datatransfer.TransferID, otherPeer peer.ID, isInitiator bool) error
ClientRetrieveTryRestartInsufficientFunds(ctx context.Context, paymentChannel address.Address) error
ClientListImports(ctx context.Context) ([]Import, error)
13、State相关接口
State方法用于查询、检查和与链状态交互。大多数方法采用TipSetKey作为参数。这个state就是查找TipSet的状态。当一个nil的TipSetKey可以作为参数提供,就会使用链中最重的tipset。
StateCall(context.Context, *types.Message, types.TipSetKey) (*InvocResult, error)
StateReplay(context.Context, types.TipSetKey, cid.Cid) (*InvocResult, error)
StateGetActor(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*types.Actor, error)
StateReadState(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*ActorState, error)
StateListMessages(ctx context.Context, match *MessageMatch, tsk types.TipSetKey, toht abi.ChainEpoch) ([]cid.Cid, error)
StateDecodeParams(ctx context.Context, toAddr address.Address, method abi.MethodNum, params []byte, tsk types.TipSetKey) (interface{}, error)
StateNetworkName(context.Context) (dtypes.NetworkName, error)
StateMinerSectors(context.Context, address.Address, *bitfield.BitField, types.TipSetKey) ([]*miner.SectorOnChainInfo, error)
StateMinerActiveSectors(context.Context, address.Address, types.TipSetKey) ([]*miner.SectorOnChainInfo, error)
StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*dline.Info, error)
StateMinerPower(context.Context, address.Address, types.TipSetKey) (*MinerPower, error)
StateMinerInfo(context.Context, address.Address, types.TipSetKey) (miner.MinerInfo, error)
StateMinerDeadlines(context.Context, address.Address, types.TipSetKey) ([]Deadline, error)
StateMinerPartitions(ctx context.Context, m address.Address, dlIdx uint64, tsk types.TipSetKey) ([]Partition, error)
StateMinerFaults(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error)
StateAllMinerFaults(ctx context.Context, lookback abi.ChainEpoch, ts types.TipSetKey) ([]*Fault, error)
StateMinerRecoveries(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error)
StateMinerPreCommitDepositForPower(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error)
StateMinerInitialPledgeCollateral(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error)
StateMinerAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error)
StateMinerSectorAllocated(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (bool, error)
StateSectorPreCommitInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error)
StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error)
StateSectorExpiration(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorExpiration, error)
StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*miner.SectorLocation, error)
StateSearchMsg(context.Context, cid.Cid) (*MsgLookup, error)
StateWaitMsg(ctx context.Context, cid cid.Cid, confidence uint64) (*MsgLookup, error)
StateWaitMsgLimited(ctx context.Context, cid cid.Cid, confidence uint64, limit abi.ChainEpoch) (*MsgLookup, error)
StateListMiners(context.Context, types.TipSetKey) ([]address.Address, error)
StateListActors(context.Context, types.TipSetKey) ([]address.Address, error)
StateMarketBalance(context.Context, address.Address, types.TipSetKey) (MarketBalance, error)
StateMarketParticipants(context.Context, types.TipSetKey) (map[string]MarketBalance, error)
StateMarketDeals(context.Context, types.TipSetKey) (map[string]MarketDeal, error)
StateMarketStorageDeal(context.Context, abi.DealID, types.TipSetKey) (*MarketDeal, error)
StateLookupID(context.Context, address.Address, types.TipSetKey) (address.Address, error)
StateAccountKey(context.Context, address.Address, types.TipSetKey) (address.Address, error)
StateChangedActors(context.Context, cid.Cid, cid.Cid) (map[string]types.Actor, error)
StateGetReceipt(context.Context, cid.Cid, types.TipSetKey) (*types.MessageReceipt, error)
StateMinerSectorCount(context.Context, address.Address, types.TipSetKey) (MinerSectors, error)
StateCompute(context.Context, abi.ChainEpoch, []*types.Message, types.TipSetKey) (*ComputeStateOutput, error)
StateVerifierStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*abi.StoragePower, error)
StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*abi.StoragePower, error)
StateVerifiedRegistryRootKey(ctx context.Context, tsk types.TipSetKey) (address.Address, error)
StateDealProviderCollateralBounds(context.Context, abi.PaddedPieceSize, bool, types.TipSetKey) (DealCollateralBounds, error)
StateCirculatingSupply(context.Context, types.TipSetKey) (abi.TokenAmount, error)
StateVMCirculatingSupplyInternal(context.Context, types.TipSetKey) (CirculatingSupply, error)
StateNetworkVersion(context.Context, types.TipSetKey) (network.Version, error)
13.1 StateCall
// StateCall运行给定的消息并返回其结果,并且不进行任何持久的更改。
StateCall(context.Context, *types.Message, types.TipSetKey) (*InvocResult, error)
Parameters:
- context.Context
- *types.Message
- types.TipSetKey
Returns:
- *InvocResult
- error
13.2 StateReplay
// StateReplay重播给定的消息,假设它包含在指定的tipset中的一个块中。如果没有提供tipset key,则查找适当的tipset。
StateReplay(context.Context, types.TipSetKey, cid.Cid) (*InvocResult, error)
Parameters:
- context.Context
- types.TipSetKey
- cid.Cid
Returns:
- *InvocResult
- error
13.3 StateGetActor
// StateGetActor返回指示的参与者的现时状态和平衡。
StateGetActor(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*types.Actor, error)
Parameters:
- ctx context.Context
- actor address.Address
- tsk types.TipSetKey
Returns:
- *types.Actor
- error
13.4 StateReadState
// StateReadState返回指示的actor的状态。
StateReadState(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*ActorState, error)
Parameters:
- ctx context.Context
- actor address.Address
- tsk types.TipSetKey
Returns:
- *ActorState
- error
root@hos:/# lotus state read-state f01 // f01
{
"AddressMap": {
"/": "bafy2bzacec5e4rputw6wgjaxmlmu6fkmovb2p5zblet5wtz5pplwun3eipuju"
},
"NetworkName": "mainnet",
"NextID": 106681
}
root@hos:/# lotus state read-state f02 // f02 fil/1/reward 奖励状态
{
"BaselineTotal": "768335872210768889362796814",
"CumsumBaseline": "234191955605542909096709",
"CumsumRealized": "234189490855937740636160",
"EffectiveBaselinePower": "3043311871865719409",
"EffectiveNetworkTime": 78974,
"Epoch": 326014,
"SimpleTotal": "330000000000000000000000000",
"ThisEpochBaselinePower": "3581710777542733404",
"ThisEpochReward": "79328459378847294913",
"ThisEpochRewardSmoothed": {
"PositionEstimate": "27022414008455266444316055720016084045780110289978687389973",
"VelocityEstimate": "46733109068626715176966450829245800536096806968605410"
},
"TotalStoragePowerReward": "17624000603654293346298282"
}
root@hos:/# lotus state read-state f03
{
"Entries": [
{
"MethodNum": 5,
"Receiver": "f04"
},
{
"MethodNum": 9,
"Receiver": "f05"
}
]
}
root@hos:/# lotus state read-state f04 // fil/1/storagepower 存储算力状态
{
"Claims": {
"/": "bafy2bzacebtgky7ecrfwuxon6tbzx72njfc577b4id6b4boyv7k4cok5nc3ha"
},
"CronEventQueue": {
"/": "bafy2bzacea5j7jk442udp72e4elduaolumbzrexgdqjhimpann252rrg5xypc"
},
"FirstCronEpoch": 326015,
"MinerAboveMinPowerCount": 745,
"MinerCount": 19734,
"ProofValidationBatch": null,
"ThisEpochPledgeCollateral": "23368406287910247558845012",
"ThisEpochQAPowerSmoothed": {
"PositionEstimate": "549569290044652055415518498354202923072947530228920489222",
"VelocityEstimate": "1963777490808617717598321997797621068301905596079094"
},
"ThisEpochQualityAdjPower": "1612032406014590976",
"ThisEpochRawBytePower": "1611970186183704576",
"TotalBytesCommitted": "1612292343090642944",
"TotalPledgeCollateral": "23368406287910247558845012",
"TotalQABytesCommitted": "1612355022926905344",
"TotalQualityAdjPower": "1612032406014590976",
"TotalRawBytePower": "1611970186183704576"
}
root@hos:/# lotus state read-state f05 // fil/1/storagemarket 存储市场状态
{
"DealOpsByEpoch": {
"/": "bafy2bzacecw5tpbdyjny4tcmhfqnw26vsvihzqhmjkhsmnclux3lcaatliqvs"
},
"EscrowTable": {
"/": "bafy2bzaceaxsyglblop25rsxxy4wcgxft2sqtbidtg2vklo6oda5dqnojizfe"
},
"LastCron": 326014,
"LockedTable": {
"/": "bafy2bzacebrt5euqxadnmzsodgacqfpektd3oqcinctrobeghe2ebfl7bhe4s"
},
"NextID": 1444903,
"PendingProposals": {
"/": "bafy2bzaceaycomsyqr4zzds6kxh6vo6n2moboyxay32kqxsndaxo2zpfdxlga"
},
"Proposals": {
"/": "bafy2bzacecntneput7b6gcp6aapfugcsnmgy52g3lcgzc2mcpz5em6vypmkxc"
},
"States": {
"/": "bafy2bzacebjagi45jsuc4ku3dfa5umplutwrwd7jjoovo64qkcpfcwano6fxs"
},
"TotalClientLockedCollateral": "0",
"TotalClientStorageFee": "6142010144904144154436",
"TotalProviderLockedCollateral": "188244291340759514232"
}
root@hos:/# lotus state read-state f01000 // fil/1/storageminer 存储矿工
{
"AllocatedSectors": {
"/": "bafy2bzacedyfzqf2yosdjbi6jb4kxx2rv2mox4eb3iy5qq6hgvsbukhvflrns"
},
"CurrentDeadline": 46,
"Deadlines": {
"/": "bafy2bzacedyypcxm5ehe6brxhsdms7brh32e4yptzm3yrkuh75rm5epx2oc6o"
},
"EarlyTerminations": [
0
],
"FeeDebt": "0",
"Info": {
"/": "bafy2bzacebspbndypxdn6sk4qia36z5s372xt7rss54ufhdojszlocjjdra4u"
},
"InitialPledge": "0",
"LockedFunds": "0",
"PreCommitDeposits": "0",
"PreCommittedSectors": {
"/": "bafy2bzaceamp42wmmgr2g2ymg46euououzfyck7szknvfacqscohrvaikwfay"
},
"PreCommittedSectorsExpiry": {
"/": "bafy2bzacec37ge5tcke2myov7ujhojrq5fowh66vuyow4u665edbxopziuju4"
},
"ProvingPeriodStart": 323218,
"Sectors": {
"/": "bafy2bzaceblmb2fxosa2jfahlah7p27qhnnh7amib6wtmxdziibbm4e5ers52"
},
"VestingFunds": {
"/": "bafy2bzacealbq6s7ptdud6gvpc2yv54opwotncjlqjxmzb2q2rnjxv753rwdc"
}
}
root@hos:/# lotus state read-state f01248 // fil/1/storageminer 存储矿工
{
"AllocatedSectors": {
"/": "bafy2bzacebh6rmskmnvkox4ofomzess2jm6kwxu3ft7c33rxo5l6ppozqezac"
},
"CurrentDeadline": 37,
"Deadlines": {
"/": "bafy2bzacebxnyknrbd5fz5phm7ln73224yxvfd65u47cy7cdqqgex4kukithw"
},
"EarlyTerminations": [
0
],
"FeeDebt": "0",
"Info": {
"/": "bafy2bzacedr4ow3wzogcsvavdq5brbukemd2j34fp54pezyllfxxbgnrwe2yq"
},
"InitialPledge": "666208681873401318957723",
"LockedFunds": "629972432690938951598530",
"PreCommitDeposits": "0",
"PreCommittedSectors": {
"/": "bafy2bzaceamp42wmmgr2g2ymg46euououzfyck7szknvfacqscohrvaikwfay"
},
"PreCommittedSectorsExpiry": {
"/": "bafy2bzacea66a5lh2ccfrwqjt26ilcvsbox7p4ugoctvaghhwp5jhioxqb5fe"
},
"ProvingPeriodStart": 323775,
"Sectors": {
"/": "bafy2bzacedy3umcrcqqdfebwmw5asilbama4bkox4r6gdsdbczn7suqdr2hqq"
},
"VestingFunds": {
"/": "bafy2bzacecxjikr5pnwflovwfs5pkkvljtmwl4efo5oz5duye5a5qtuljjdbu"
}
}
root@hos:/# lotus state --tipset bafy2bzaced25tbo6y5kgbzi2gya7s2wvmiz5xdudkcu3k2huan4g34rkahe3u,bafy2bzacecbxtti4w7f5figusqaubfjmv25edznrdynu7htsmwcgvprh2snvk,bafy2bzacedds2p2hdfsvifgxjnqngyrkpeszrl5bo6six7ci4bl3jk36dsdla read-state f01248
{
"AllocatedSectors": {
"/": "bafy2bzacecq27lqkg56exhobcvq3bbc3anp2dpjvn2bhqdiqdtfuiojyyuv52"
},
"CurrentDeadline": 20,
"Deadlines": {
"/": "bafy2bzacebboov5k7bc7ea6iccex6me2gzwhm6rijnyvwjsfjwt4q77v2cweg"
},
"EarlyTerminations": [
0
],
"FeeDebt": "0",
"Info": {
"/": "bafy2bzacedr4ow3wzogcsvavdq5brbukemd2j34fp54pezyllfxxbgnrwe2yq"
},
"InitialPledge": "660871389003289822327674",
"LockedFunds": "624135229303181250121030",
"PreCommitDeposits": "202467385778161649520",
"PreCommittedSectors": {
"/": "bafy2bzaceas5vnvicmwero3h6i4o5r7ekk4q4vad77leh7ns4asupixuoynmy"
},
"PreCommittedSectorsExpiry": {
"/": "bafy2bzacedibm6e772h6h33nfyxzmpaw7snatneu25jsiyg4n3unhim2hozlm"
},
"ProvingPeriodStart": 318015,
"Sectors": {
"/": "bafy2bzaceadqcyk3a2ldcfktkd4w7xqgpgpw5yxwcmav5t2g4iyqfaniddnag"
},
"VestingFunds": {
"/": "bafy2bzaceal5jzgvua3mq7zdb566332dzmkmnwggfcgcig7peci2pmzg2qsqc"
}
}
13.5 StateListMessages
// StateListMessages返回所有与地址匹配的消息,并在给定的高度停止。
StateListMessages(ctx context.Context, match *MessageMatch, tsk types.TipSetKey, toht abi.ChainEpoch) ([]cid.Cid, error)
Parameters:
- ctx context.Context
- match *MessageMatch
- tsk types.TipSetKey
- toht abi.ChainEpoch
Returns:
- []cid.Cid
- error
13.6 StateDecodeParams
// StateDecodeParams尝试根据接收方、参与者地址和方法号解码所提供的参数。
StateDecodeParams(ctx context.Context, toAddr address.Address, method abi.MethodNum, params []byte, tsk types.TipSetKey) (interface{}, error)
Parameters:
- ctx context.Context
- toAddr address.Address
- method abi.MethodNum
- params []byte,
- tsk types.TipSetKey
Returns:
- interface{}
- error
13.7 StateNetworkName
// StateNetworkName返回与节点同步的网络的名称
StateNetworkName(context.Context) (dtypes.NetworkName, error)
Parameters:
- context.Context
Returns:
- dtypes.NetworkName
- error
13.8 StateMinerSectors
// stateminersector返回关于给定矿商行业的信息。如果filter bitfield为nil,则包括所有扇区。
StateMinerSectors(context.Context, address.Address, *bitfield.BitField, types.TipSetKey) ([]*miner.SectorOnChainInfo, error)
Parameters:
- context.Context
- address.Address
- *bitfield.BitField
- types.TipSetKey
Returns:
- []*miner.SectorOnChainInfo
- error
13.9 StateMinerActiveSectors
// StateMinerActiveSectors返回关于给定矿机正在积极证明的扇区的信息。
StateMinerActiveSectors(context.Context, address.Address, types.TipSetKey) ([]*miner.SectorOnChainInfo, error)
Parameters:
- context.Context
- , address.Address
- types.TipSetKey
Returns:
- []*miner.SectorOnChainInfo
- error
13.10 StateMinerProvingDeadline
// StateMinerProvingDeadline计算一个证明期间的某个epoch的deadline,并返回与deadline相关的计算。
StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*dline.Info, error)
Parameters:
- context.Context
- address.Address
- types.TipSetKey
Returns:
- *dline.Info
- error
13.11 StateMinerPower
// StateMinerPower返回指定矿机的power。
StateMinerPower(context.Context, address.Address, types.TipSetKey) (*MinerPower, error)
Parameters:
- context.Context
- address.Address
- types.TipSetKey
Returns:
- *MinerPower
- error
13.12 StateMinerInfo
// StateMinerInfo返回关于指定矿机的信息
StateMinerInfo(context.Context, address.Address, types.TipSetKey) (miner.MinerInfo, error)
Parameters:
- context.Context
- address.Address
- types.TipSetKey
Returns:
- miner.MinerInfo
- error
13.13 StateMinerDeadlines
// stateminerdeadline返回给定矿机的所有proving deadlines。
StateMinerDeadlines(context.Context, address.Address, types.TipSetKey) ([]Deadline, error)
Parameters:
- context.Context
- address.Address
- types.TipSetKey
Returns:
- []Deadline
- error
13.14 StateMinerPartitions
// StateMinerPartitions返回指定deadline内的所有Partition。
StateMinerPartitions(ctx context.Context, m address.Address, dlIdx uint64, tsk types.TipSetKey) ([]Partition, error)
Parameters:
- ctx context.Context
- m address.Address
- dlIdx uint64
- tsk types.TipSetKey
Returns:
- []Partition
- error
13.15 StateMinerFaults
// StateMinerFaults返回一个bitfield,指示给定miner的故障扇区。
StateMinerFaults(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error)
Parameters:
- context.Context
- address.Address
- types.TipSetKey
Returns:
- bitfield.BitField
- error
13.16 StateAllMinerFaults
// StateAllMinerFaults返回在给定tipset的回看epochs内发生的所有未过期的Faults。
StateAllMinerFaults(ctx context.Context, lookback abi.ChainEpoch, ts types.TipSetKey) ([]*Fault, error)
Parameters:
- ctx context.Context
- lookback abi.ChainEpoch
- ts types.TipSetKey
Returns:
- []*Fault
- error
13.17 StateMinerRecoveries
// StateMinerRecoveries返回一个bitfield,指示给定miner的恢复扇区。
StateMinerRecoveries(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error)
Parameters:
- context.Context
- address.Address
- types.TipSetKey
Returns:
- bitfield.BitField
- error
13.18 StateMinerPreCommitDepositForPower
// StateMinerPreCommitDepositForPower返回指定miner的扇区的预提交保证金。
StateMinerPreCommitDepositForPower(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error)
Parameters:
- context.Context
- address.Address
- miner.SectorPreCommitInfo
- types.TipSetKey
Returns:
- types.BigInt
- error
13.19 StateMinerInitialPledgeCollateral
// StateMinerInitialPledgeCollateral返回指定miner sector的初始抵押品。
StateMinerInitialPledgeCollateral(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error)
Parameters:
- context.Context
- address.Address
- miner.SectorPreCommitInfo
- types.TipSetKey
Returns:
types.BigInt
error
13.20 StateMinerAvailableBalance
// StateMinerAvailableBalance返回miner余额中可以提取或使用的部分。
StateMinerAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error)
Parameters:
- context.Context
- address.Address
- types.TipSetKey
Returns:
- types.BigInt
- error
13.21 StateMinerSectorAllocated
// stateminersectorallocation检查是否分配了扇区
StateMinerSectorAllocated(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (bool, error)
Parameters:
- context.Context
- address.Address
- abi.SectorNumber
- types.TipSetKey
Returns:
- bool
- error
13.22 StateSectorPreCommitInfo
// StateSectorPreCommitInfo返回指定miner扇区的PreCommit信息。
StateSectorPreCommitInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error)
Parameters:
- context.Context
- address.Address
- abi.SectorNumber
- types.TipSetKey
Returns:
- miner.SectorPreCommitOnChainInfo
- error
13.23 StateSectorGetInfo
// StateSectorGetInfo返回指定矿机扇区的链上信息。如果没有找到扇区信息,返回null
// 注意:返回信息。在某些情况下,过期可能不准确,使用state - ectorexpiration来获得准确的过期时间。
StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error)
Parameters:
- context.Context
- address.Address
- abi.SectorNumber
- types.TipSetKey
Returns:
- *miner.SectorOnChainInfo
- error
13.24 StateSectorExpiration
// StateSectorExpiration返回给定的sector将在哪个epoch过期
StateSectorExpiration(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorExpiration, error)
Parameters:
- context.Context
- address.Address
- abi.SectorNumber
- types.TipSetKey
Returns:
- *miner.SectorExpiration
- error
13.25 StateSectorPartition
// StateSectorPartition查找指定的sector的deadline/partition。
StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*miner.SectorLocation, error)
Parameters:
- ctx context.Context
- maddr address.Address
- sectorNumber abi.SectorNumber
- tok types.TipSetKey
Returns:
- *miner.SectorLocation
- error
13.26 StateSearchMsg
// StateSearchMsg在链中搜索消息,并返回其接收和执行该消息的tipset
StateSearchMsg(context.Context, cid.Cid) (*MsgLookup, error)
Parameters:
- context.Context
- cid.Cid
Returns:
- *MsgLookup
- error
13.27 StateWaitMsg
// StateWaitMsg在链中向后查找消息。如果没有找到,它将阻塞,直到消息到达链上,并到达指定的confidence深度。
StateWaitMsg(ctx context.Context, cid cid.Cid, confidence uint64) (*MsgLookup, error)
Parameters:
- ctx context.Context
- cid cid.Cid
- confidence uint64
Returns:
- *MsgLookup
- error
13.28 StateWaitMsgLimited
// StateWaitMsgLimited向后查找以限制消息链中的epoch。如果没有找到,它将阻塞,直到消息到达链上,并到达指定的confidence深度。。
StateWaitMsgLimited(ctx context.Context, cid cid.Cid, confidence uint64, limit abi.ChainEpoch) (*MsgLookup, error)
Parameters:
- ctx context.Context
- cid cid.Cid
- confidence uint64
- limit abi.ChainEpoch
Returns:
- *MsgLookup
- error
13.29 StateListMiners
// StateListMiners返回在power Actor中声明power的每个miner的地址。
StateListMiners(context.Context, types.TipSetKey) ([]address.Address, error)
Parameters:
- context.Context
- types.TipSetKey
Returns:
- []address.Address
- error
13.30 StateListActors
// StateListActors返回该state中每个actor的地址
StateListActors(context.Context, types.TipSetKey) ([]address.Address, error)
Parameters:
- context.Context
- types.TipSetKey
Returns:
- []address.Address
- error
root@hos:~# lotus state list-actors
f01
f01248
...
f02
f03
f04
f05
...
13.31 StateMarketBalance
// StateMarketBalance查询存储市场中给定地址的托管和锁定余额。
StateMarketBalance(context.Context, address.Address, types.TipSetKey) (MarketBalance, error)
Parameters:
- context.Context
- address.Address
- types.TipSetKey
Returns:
- MarketBalance
- error
13.32 StateMarketParticipants
// StateMarketParticipants返回存储市场中每个actor的托管和锁定余额。
StateMarketParticipants(context.Context, types.TipSetKey) (map[string]MarketBalance, error)
Parameters:
- context.Context
- types.TipSetKey
Returns:
- map[string]MarketBalance
- error
13.33 StateMarketDeals
// StateMarketDeals返回存储市场中每笔交易的信息
StateMarketDeals(context.Context, types.TipSetKey) (map[string]MarketDeal, error)
Parameters:
- context.Context
- types.TipSetKey
Returns:
- map[string]MarketDeal
- error
13.34 StateMarketStorageDeal
// StateMarketStorageDeal返回有关指定交易的信息。
StateMarketStorageDeal(context.Context, abi.DealID, types.TipSetKey) (*MarketDeal, error)
Parameters:
- context.Context
- abi.DealID
- types.TipSetKey
Returns:
- *MarketDeal
- error
13.35 StateLookupID
// StateLookupID检索给定地址的ID地址
StateLookupID(context.Context, address.Address, types.TipSetKey) (address.Address, error)
Parameters:
- context.Context
- address.Address
- types.TipSetKey
Returns:
- address.Address
- error
13.36 StateAccountKey
// StateAccountKey返回给定ID地址的公钥地址。
StateAccountKey(context.Context, address.Address, types.TipSetKey) (address.Address, error)
Parameters:
- context.Context
- address.Address
- types.TipSetKey
Returns:
- address.Address
- error
13.37 StateChangedActors
// StateChangedActors返回在两个给定状态cid之间状态改变的所有actor。
StateChangedActors(context.Context, cid.Cid, cid.Cid) (map[string]types.Actor, error)
Parameters:
- context.Context
- cid.Cid
- cid.Cid
Returns:
- map[string]types.Actor
- error
13.38 StateGetReceipt
// StateGetReceipt返回给定消息的MessageReceipt。
StateGetReceipt(context.Context, cid.Cid, types.TipSetKey) (*types.MessageReceipt, error)
Parameters:
- context.Context
- cid.Cid
- types.TipSetKey
Returns:
- *types.MessageReceipt
- error
13.39 StateMinerSectorCount
// StateMinerSectorCount返回miner扇区集和证明集中的扇区数。
StateMinerSectorCount(context.Context, address.Address, types.TipSetKey) (MinerSectors, error)
Parameters:
- context.Context
- address.Address
- types.TipSetKey
Returns:
- MinerSectors
- error
13.40 StateCompute
// StateCompute是一个灵活的命令,它在给定的tipset上应用给定的消息。这些消息就像VM在提供的高度一样运行
StateCompute(context.Context, abi.ChainEpoch, []*types.Message, types.TipSetKey) (*ComputeStateOutput, error)
Parameters:
- context.Context
- abi.ChainEpoch
- []*types.Message
- types.TipSetKey
Returns:
- *ComputeStateOutput
- error
13.41 StateVerifierStatus
// StateVerifierStatus返回给定地址的数据上限。如果数据cap表中没有地址项,则返回nil。。
StateVerifierStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*abi.StoragePower, error)
Parameters:
- ctx context.Context
- addr address.Address
- tsk types.TipSetKey
Returns:
- *abi.StoragePower
- error
13.42 StateVerifiedClientStatus
// StateVerifiedClientStatus返回给定地址的数据cap。如果数据cap表中没有地址项,则返回nil。
StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*abi.StoragePower, error)
Parameters:
- ctx context.Context
- addr address.Address
- tsk types.TipSetKey
Returns:
- *abi.StoragePower
- error
13.43 StateVerifiedRegistryRootKey
// StateVerifiedClientStatus返回Verified Registry's root key
StateVerifiedRegistryRootKey(ctx context.Context, tsk types.TipSetKey) (address.Address, error)
Parameters:
- ctx context.Context
- tsk types.TipSetKey
Returns:
- address.Address
- error
13.44 StateDealProviderCollateralBounds
// StateDealProviderCollateralBounds返回存储提供商可以发行的最小和最大抵押品。它以交易规模和验证状态为参数。
StateDealProviderCollateralBounds(context.Context, abi.PaddedPieceSize, bool, types.TipSetKey) (DealCollateralBounds, error)
Parameters:
- context.Context
- abi.PaddedPieceSize
- bool
- types.TipSetKey
Returns:
- DealCollateralBounds
- error
13.45 StateCirculatingSupply
// StateCirculatingSupply在给定的参数集返回Filecoin的准确循环供应。这在协议本身的任何地方都没有使用,只供外部使用。
StateCirculatingSupply(context.Context, types.TipSetKey) (abi.TokenAmount, error)
Parameters:
- context.Context
- types.TipSetKey
Returns:
- abi.TokenAmount
- error
13.46 StateVMCirculatingSupplyInternal
// StateVMCirculatingSupplyInternal返回一个近似的循环供应的Filecoin在给定的tipset。这是runtime接口向actor代码报告的值。
StateVMCirculatingSupplyInternal(context.Context, types.TipSetKey) (CirculatingSupply, error)
Parameters:
- context.Context
- types.TipSetKey
Returns:
- CirculatingSupply
- error
13.47 StateNetworkVersion
// StateNetworkVersion返回给定tipset上的网络版本。
StateNetworkVersion(context.Context, types.TipSetKey) (network.Version, error)
Parameters:
- context.Context
- types.TipSetKey
Returns:
- network.Version
- error
14、Msig相关接口
Msig方法用于与filecoin网络上的多签钱包交互。
MsigGetAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error)
MsigGetVestingSchedule(context.Context, address.Address, types.TipSetKey) (MsigVesting, error)
MsigGetVested(context.Context, address.Address, types.TipSetKey, types.TipSetKey) (types.BigInt, error)
MsigCreate(context.Context, uint64, []address.Address, abi.ChainEpoch, types.BigInt, address.Address, types.BigInt) (cid.Cid, error)
MsigPropose(context.Context, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error)
MsigApprove(context.Context, address.Address, uint64, address.Address) (cid.Cid, error)
MsigApproveTxnHash(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error)
MsigCancel(context.Context, address.Address, uint64, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error)
MsigAddPropose(context.Context, address.Address, address.Address, address.Address, bool) (cid.Cid, error)
MsigAddApprove(context.Context, address.Address, address.Address, uint64, address.Address, address.Address, bool) (cid.Cid, error)
MsigAddCancel(context.Context, address.Address, address.Address, uint64, address.Address, bool) (cid.Cid, error)
MsigSwapPropose(context.Context, address.Address, address.Address, address.Address, address.Address) (cid.Cid, error)
MsigSwapApprove(context.Context, address.Address, address.Address, uint64, address.Address, address.Address, address.Address) (cid.Cid, error)
MsigSwapCancel(context.Context, address.Address, address.Address, uint64, address.Address, address.Address) (cid.Cid, error)
MsigRemoveSigner(ctx context.Context, msig address.Address, proposer address.Address, toRemove address.Address, decrease bool) (cid.Cid, error)
14.1 MsigGetAvailableBalance
// MsigGetAvailableBalance返回可提取或使用的multisig's的余额的一部分
MsigGetAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error)
Parameters:
- context.Context
- address.Address
- types.TipSetKey
Returns:
- types.BigInt
- error
14.2 MsigGetVestingSchedule
// MsigGetVestingSchedule返回给定multisig的Vesting细节。
MsigGetVestingSchedule(context.Context, address.Address, types.TipSetKey) (MsigVesting, error)
Parameters:
- context.Context
- address.Address
- types.TipSetKey
Returns:
- MsigVesting
- error
14.3 MsigGetVested
// MsigGetVested返回在一定时期内在一个multisig中既得利益的FIL的数量。
// 它接受以下参数:<multisig address>, <start epoch>, <end epoch>
MsigGetVested(context.Context, address.Address, types.TipSetKey, types.TipSetKey) (types.BigInt, error)
Parameters:
- context.Context
- address.Address
- types.TipSetKey
- types.TipSetKey
Returns:
- types.BigInt
- error
14.4 MsigCreate
// MsigCreate返回multisig钱包。
// 它接受以下参数:<required number of senders>, <approving addresses>, <unlock duration> <initial balance>, <sender address of the create msg>, <gas price>
MsigCreate(context.Context, uint64, []address.Address, abi.ChainEpoch, types.BigInt, address.Address, types.BigInt) (cid.Cid, error)
Parameters:
- context.Context
- uint64
- []address.Address
- abi.ChainEpoch
- types.BigInt
- address.Address
- types.BigInt
Returns:
- cid.Cid
- error
14.5 MsigPropose
// MsigPropose提议multisig message
// 它接受以下参数:<multisig address>, <recipient address>, <value to transfer>, <sender address of the propose msg>, <method to call in the proposed message>, <params to include in the proposed message>
MsigPropose(context.Context, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error)
Parameters:
- context.Context
- address.Address
- address.Address
- types.BigInt
- address.Address
- uint64
- []byte
Returns:
- cid.Cid
- error
14.6 MsigApprove
// MsigApprove通过transaction ID批准之前提议的multisig消息。
// 它接受以下参数: <multisig address>, <proposed transaction ID> <signer address>
MsigApprove(context.Context, address.Address, uint64, address.Address) (cid.Cid, error)
Parameters:
- context.Context
- address.Address
- uint64
- address.Address
Returns:
- cid.Cid
- error
14.7 MsigApproveTxnHash
// MsigApproveTxnHash批准之前提议的multisig消息,该消息使用transactionID和提议中使用的参数的散列指定。这种审批方法可以确保您只审批您认为的交易。
// 它接受以下参数<multisig address>, <start epoch>, <end epoch>
MsigApproveTxnHash(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error)
Parameters:
- context.Context
- address.Address
- uint64
- address.Address
- address.Address
- types.BigInt
- address.Address
- uint64
- []byte
Returns:
- cid.Cid
- error
14.8 MsigCancel
//MsigCancel取消先前提出的multisig消息。
// 它接受以下参数:<multisig address>, <proposed transaction ID>, <recipient address>, <value to transfer>, <sender address of the cancel msg>, <method to call in the proposed message>, <params to include in the proposed message>
MsigCancel(context.Context, address.Address, uint64, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error)
Parameters:
- context.Context
- address.Address
- uint64
- address.Address
- types.BigInt
- address.Address
- uint64
- []byte
Returns:
- cid.Cid
- error
14.9 MsigAddPropose
// msigaddproposal建议在multisig中添加一个singer
// 它接受以下参数:<multisig address>, <sender address of the propose msg>, <new signer>, <whether the number of required signers should be increased>
MsigAddPropose(context.Context, address.Address, address.Address, address.Address, bool) (cid.Cid, error)
Parameters:
- context.Context
- address.Address
- address.Address
- address.Address
- bool
Returns:
- cid.Cid
- error
14.10 MsigAddApprove
// MsigAddApprove批准先前建议的AddSigner消息。
// 它接受以下参数:<multisig address>, <sender address of the approve msg>, <proposed message ID>, <proposer address>, <new signer>, <whether the number of required signers should be increased>
MsigAddApprove(context.Context, address.Address, address.Address, uint64, address.Address, address.Address, bool) (cid.Cid, error)
Parameters:
- context.Context
- address.Address
- address.Address
- uint64
- address.Address
- address.Address
- bool
Returns:
- cid.Cid
- error
14.11 MsigAddCancel
// MsigAddCancel取消先前建议的AddSigner消息。
// 它接受以下参数: <multisig address>, <sender address of the cancel msg>, <proposed message ID>, <new signer>, <whether the number of required signers should be increased>
MsigAddCancel(context.Context, address.Address, address.Address, uint64, address.Address, bool) (cid.Cid, error)
Parameters:
- context.Context
- address.Address
- address.Address
- uint64
- address.Address
- bool
Returns:
- cid.Cid
- error
14.12 MsigSwapPropose
// MsigSwapPropose建议在multisig中交换2个singers。
// 它接受以下参数:<multisig address>, <sender address of the propose msg>, <old signer>, <new signer>
MsigSwapPropose(context.Context, address.Address, address.Address, address.Address, address.Address) (cid.Cid, error)
Parameters:
- context.Context
- address.Address
- address.Address,
- address.Address,
- address.Address
Returns:
- cid.Cid
- error
14.13 MsigSwapApprove
// MsigSwapApprove批准先前提议的SwapSigner
// 它接受以下参数:<multisig address>, <sender address of the approve msg>, <proposed message ID>, <proposer address>, <old signer>, <new signer>
MsigSwapApprove(context.Context, address.Address, address.Address, uint64, address.Address, address.Address, address.Address) (cid.Cid, error)
Parameters:
- context.Context
- address.Address
- address.Address
- uint64
- address.Address
- address.Address
- address.Address
Returns:
- cid.Cid
- error
14.14 MsigSwapCancel
// MsigSwapCancel取消先前提出的SwapSigner消息。
// 它接受以下参数:<multisig address>, <sender address of the cancel msg>, <proposed message ID>, <old signer>, <new signer>
MsigSwapCancel(context.Context, address.Address, address.Address, uint64, address.Address, address.Address) (cid.Cid, error)
Parameters:
- context.Context
- address.Address
- address.Address
- uint64
- address.Address
- address.Address
Returns:
- cid.Cid
- error
14.15 MsigRemoveSigner
// MsigRemoveSigner建议从multisig中删除签名者。
// 它接受进行更改的multisig,要发送消息的提出者地址,要删除的地址,以及一个指示签名阈值是否应该随地址删除一起降低1的布尔值。
MsigRemoveSigner(ctx context.Context, msig address.Address, proposer address.Address, toRemove address.Address, decrease bool) (cid.Cid, error)
Parameters:
- ctx context.Context
- msig address.Address
- proposer address.Address
- toRemove address.Address
- decrease bool
Returns:
- cid.Cid
- error
15、Market相关接口
MarketReserveFunds(ctx context.Context, wallet address.Address, addr address.Address, amt types.BigInt) (cid.Cid, error)
MarketReleaseFunds(ctx context.Context, addr address.Address, amt types.BigInt) error
15.1 MarketReserveFunds
// MarketReserveFunds为交易储备资金。
MarketReserveFunds(ctx context.Context, wallet address.Address, addr address.Address, amt types.BigInt) (cid.Cid, error)
Parameters:
- ctx context.Context
- wallet address.Address
- addr address.Address
- amt types.BigInt
Returns:
- cid.Cid
- error
15.2 MarketReleaseFunds
// MarketReleaseFunds释放MarketReserveFunds预留的资金。
MarketReleaseFunds(ctx context.Context, addr address.Address, amt types.BigInt) error
Parameters:
- context.Context
- addr address.Address
- amt types.BigInt
Returns:
- error
16、Paych相关接口
Paych方法用于与支付渠道的交互和管理。
PaychGet(ctx context.Context, from, to address.Address, amt types.BigInt) (*ChannelInfo, error)
PaychGetWaitReady(context.Context, cid.Cid) (address.Address, error)
PaychAvailableFunds(ctx context.Context, ch address.Address) (*ChannelAvailableFunds, error)
PaychAvailableFundsByFromTo(ctx context.Context, from, to address.Address) (*ChannelAvailableFunds, error)
PaychList(context.Context) ([]address.Address, error)
PaychStatus(context.Context, address.Address) (*PaychStatus, error)
PaychSettle(context.Context, address.Address) (cid.Cid, error)
PaychCollect(context.Context, address.Address) (cid.Cid, error)
PaychAllocateLane(ctx context.Context, ch address.Address) (uint64, error)
PaychNewPayment(ctx context.Context, from, to address.Address, vouchers []VoucherSpec) (*PaymentInfo, error)
PaychVoucherCheckValid(context.Context, address.Address, *paych.SignedVoucher) error
PaychVoucherCheckSpendable(context.Context, address.Address, *paych.SignedVoucher, []byte, []byte) (bool, error)
PaychVoucherCreate(context.Context, address.Address, types.BigInt, uint64) (*VoucherCreateResult, error)
PaychVoucherAdd(context.Context, address.Address, *paych.SignedVoucher, []byte, types.BigInt) (types.BigInt, error)
PaychVoucherList(context.Context, address.Address) ([]*paych.SignedVoucher, error)
PaychVoucherSubmit(context.Context, address.Address, *paych.SignedVoucher, []byte, []byte) (cid.Cid, error)
17、Other:其他接口
CreateBackup(ctx context.Context, fpath string) error
17.1 CreateBackup
// CreateBackup根据指定的文件名创建节点备份。方法要求lotus daemon运行并且LOTUS_BACKUP_BASE_PATH环境变量设置为某个路径,并且调用CreateBackup时指定的路径在基本路径中
CreateBackup(ctx context.Context, fpath string) error
Parameters:
- ctx context.Context
- fpath string
Returns:
- error
blocks表里按照height查找miner的中奖以及win_count
root@hos:~# lotus state read-state f01248
{
“AllocatedSectors”: {
“/“: “bafy2bzacedabt4anodvuztdmefirgoi47dsdqnjwgx2dpyazxrs4oj7tib4fc”
},
“CurrentDeadline”: 46,
“Deadlines”: {
“/“: “bafy2bzacebjtvyjxaplcgohu6s52hzl6etd2fmivcnbrpzv3dvoe6ce6e7akq”
},
“EarlyTerminations”: [
0
],
“FeeDebt”: “0”,
“Info”: {
“/“: “bafy2bzacedr4ow3wzogcsvavdq5brbukemd2j34fp54pezyllfxxbgnrwe2yq”
},
“InitialPledge”: “622509720772281475481367”,
“LockedFunds”: “559976923035001977787178”,
“PreCommitDeposits”: “276019658683124288457”,
“PreCommittedSectors”: {
“/“: “bafy2bzaceajoxidhuvyz4pvvlqgczymbzdan6kbyhouzxleuupgmgfomij7yo”
},
“PreCommittedSectorsExpiry”: {
“/“: “bafy2bzacedmkbroyub3fplnvdwa7vkdabaeyrdgobyipg2f2kv2rrxszu5t2o”
},
“ProvingPeriodStart”: 269055,
“Sectors”: {
“/“: “bafy2bzacecrce6ufegvyfaxv7cecy7a6dntdfxd3hpwwahxkf525jyzijfc32”
},
“VestingFunds”: {
“/“: “bafy2bzaceb6bbstuzntbb75l525v7vfp37ydsqchphmrbf4spke35fvahbwek”
}
}
root@hos:~# lotus state read-state f01248
{
“AllocatedSectors”: {
“/“: “bafy2bzaceb2cnusu6wkbeuy4jkjiqmmix6hlwswiqh7qetfe6aaoxi6wcmaee”
},
“CurrentDeadline”: 5,
“Deadlines”: {
“/“: “bafy2bzacead52bql6vwnyr7jdt7sa3pylujljhm3tkdweupbhtvaoi3633j4m”
},
“EarlyTerminations”: [
0
],
“FeeDebt”: “0”,
“Info”: {
“/“: “bafy2bzacedr4ow3wzogcsvavdq5brbukemd2j34fp54pezyllfxxbgnrwe2yq”
},
“InitialPledge”: “623801503759457215345727”,
“LockedFunds”: “559410768266754758222597”,
“PreCommitDeposits”: “267788787238100317735”,
“PreCommittedSectors”: {
“/“: “bafy2bzacectmlovwirp6x7d6agjisj2tjphfgpmhtdfcik37mwkf2thzthro2”
},
“PreCommittedSectorsExpiry”: {
“/“: “bafy2bzacecv2c3b24esaj6r64estzxn7pl4yggsp7xw3mewlqou3rji5phu6g”
},
“ProvingPeriodStart”: 271935,
“Sectors”: {
“/“: “bafy2bzaceang6sxkh3v45yvp23tvxwgxn64vwintxpleb7dcxogvnur55n3ao”
},
“VestingFunds”: {
“/“: “bafy2bzacecrmp5unvv3fbymwo2wneicpyvia2dkga5yiluhvy34gc6qtgwbuk”
}
}
lotus chain read-obj bafy2bzaceb6bbstuzntbb75l525v7vfp37ydsqchphmrbf4spke35fvahbwek
{“AllocatedSectors”:{“/“:”bafy2bzacea456askyutsf7uk4ta2q5aojrlcji4mhaqokbfalgvoq4ueeh4l2”},”CurrentDeadline”:0,”Deadlines”:{“/“:”bafy2bzaceakubxbluycf7ug7ve3o5yg2kwbhjaf65gtu5m4ethfrq2qxurtcy”},”EarlyTerminations”:[0],”Info”:{“/“:”bafy2bzaced23lstf3seqsq5mogtctlbxrskqzskxe2xs74unwtnrnhlc4exyw”},”InitialPledgeRequirement”:”0”,”LockedFunds”:”0”,”PreCommitDeposits”:”0”,”PreCommittedSectors”:{“/“:”bafy2bzaceamp42wmmgr2g2ymg46euououzfyck7szknvfacqscohrvaikwfay”},”PreCommittedSectorsExpiry”:{“/“:”bafy2bzacedswlcz5ddgqnyo3sak3jmhmkxashisnlpq6ujgyhe4mlobzpnhs6”},”ProvingPeriodStart”:3004,”Sectors”:{“/“:”bafy2bzacedswlcz5ddgqnyo3sak3jmhmkxashisnlpq6ujgyhe4mlobzpnhs6”},”VestingFunds”:{“/“:”bafy2bzacealbq6s7ptdud6gvpc2yv54opwotncjlqjxmzb2q2rnjxv753rwdc”}}
{“AllocatedSectors”:{“/“:”bafy2bzacea456askyutsf7uk4ta2q5aojrlcji4mhaqokbfalgvoq4ueeh4l2”},”CurrentDeadline”:0,”Deadlines”:{“/“:”bafy2bzaceakubxbluycf7ug7ve3o5yg2kwbhjaf65gtu5m4ethfrq2qxurtcy”},”EarlyTerminations”:[0],”Info”:{“/“:”bafy2bzaced23lstf3seqsq5mogtctlbxrskqzskxe2xs74unwtnrnhlc4exyw”},”InitialPledgeRequirement”:”0”,”LockedFunds”:”0”,”PreCommitDeposits”:”0”,”PreCommittedSectors”:{“/“:”bafy2bzaceamp42wmmgr2g2ymg46euououzfyck7szknvfacqscohrvaikwfay”},”PreCommittedSectorsExpiry”:{“/“:”bafy2bzacedswlcz5ddgqnyo3sak3jmhmkxashisnlpq6ujgyhe4mlobzpnhs6”},”ProvingPeriodStart”:3004,”Sectors”:{“/“:”bafy2bzacedswlcz5ddgqnyo3sak3jmhmkxashisnlpq6ujgyhe4mlobzpnhs6”},”VestingFunds”:{“/“:”bafy2bzacealbq6s7ptdud6gvpc2yv54opwotncjlqjxmzb2q2rnjxv753rwdc”}}
{“AllocatedSectors”:{“/“:”bafy2bzacec3kfucxpfukfcnlhz73eymnjhirmlrc5z2nop2plbqvocsxj66ra”},”CurrentDeadline”:0,”Deadlines”:{“/“:”bafy2bzacecebj2awf7slcrrl7hrgz6ox2rzq4zscqxv27kwofmkjtytdoweyo”},”EarlyTerminations”:[0],”Info”:{“/“:”bafy2bzacear2wkgakll545dlkslu33izpqhy3htxuxjliugcw6rzqne4nsvzq”},”InitialPledgeRequirement”:”312499995095859200”,”LockedFunds”:”1864080807098733412498”,”PreCommitDeposits”:”0”,”PreCommittedSectors”:{“/“:”bafy2bzaceamp42wmmgr2g2ymg46euououzfyck7szknvfacqscohrvaikwfay”},”PreCommittedSectorsExpiry”:{“/“:”bafy2bzaceaeadzbk3fhkojehlssencvwed4qp5f7jtvc6par57rwguukzpgry”},”ProvingPeriodStart”:658,”Sectors”:{“/“:”bafy2bzaceatqbymaxk7ixlimx6j7ro27syuqaxon6uslpivbglxe7f4svfpto”},”VestingFunds”:{“/“:”bafy2bzaceck2d2xinmmtijd5ocmxbzzvollghiz4awed5fiqsrolzm275i3gs”}}
{“AllocatedSectors”:{“/“:”bafy2bzacec3kfucxpfukfcnlhz73eymnjhirmlrc5z2nop2plbqvocsxj66ra”},”CurrentDeadline”:6,”Deadlines”:{“/“:”bafy2bzacecebj2awf7slcrrl7hrgz6ox2rzq4zscqxv27kwofmkjtytdoweyo”},”EarlyTerminations”:[0],”Info”:{“/“:”bafy2bzacear2wkgakll545dlkslu33izpqhy3htxuxjliugcw6rzqne4nsvzq”},”InitialPledgeRequirement”:”312499995095859200”,”LockedFunds”:”38367498280698840359048”,”PreCommitDeposits”:”0”,”PreCommittedSectors”:{“/“:”bafy2bzaceamp42wmmgr2g2ymg46euououzfyck7szknvfacqscohrvaikwfay”},”PreCommittedSectorsExpiry”:{“/“:”bafy2bzaceaeadzbk3fhkojehlssencvwed4qp5f7jtvc6par57rwguukzpgry”},”ProvingPeriodStart”:658,”Sectors”:{“/“:”bafy2bzaceatqbymaxk7ixlimx6j7ro27syuqaxon6uslpivbglxe7f4svfpto”},”VestingFunds”:{“/“:”bafy2bzacebdtte6ej3ndvvxhyyt5ezgby46zvgqj7tf57kdetbb5jdiqo3bm2”}}
{“AllocatedSectors”:{“/“:”bafy2bzacec3kfucxpfukfcnlhz73eymnjhirmlrc5z2nop2plbqvocsxj66ra”},”CurrentDeadline”:6,”Deadlines”:{“/“:”bafy2bzacecebj2awf7slcrrl7hrgz6ox2rzq4zscqxv27kwofmkjtytdoweyo”},”EarlyTerminations”:[0],”Info”:{“/“:”bafy2bzacear2wkgakll545dlkslu33izpqhy3htxuxjliugcw6rzqne4nsvzq”},”InitialPledgeRequirement”:”312499995095859200”,”LockedFunds”:”37838070939143773040708”,”PreCommitDeposits”:”0”,”PreCommittedSectors”:{“/“:”bafy2bzaceamp42wmmgr2g2ymg46euououzfyck7szknvfacqscohrvaikwfay”},”PreCommittedSectorsExpiry”:{“/“:”bafy2bzaceaeadzbk3fhkojehlssencvwed4qp5f7jtvc6par57rwguukzpgry”},”ProvingPeriodStart”:658,”Sectors”:{“/“:”bafy2bzaceatqbymaxk7ixlimx6j7ro27syuqaxon6uslpivbglxe7f4svfpto”},”VestingFunds”:{“/“:”bafy2bzacebbg32hm5lnmtla7w4clregfyknd7mj7zr2su6bjdld4sde5zvvgq”}}
{“AllocatedSectors”:{“/“:”bafy2bzacec3kfucxpfukfcnlhz73eymnjhirmlrc5z2nop2plbqvocsxj66ra”},”CurrentDeadline”:0,”Deadlines”:{“/“:”bafy2bzacecebj2awf7slcrrl7hrgz6ox2rzq4zscqxv27kwofmkjtytdoweyo”},”EarlyTerminations”:[0],”Info”:{“/“:”bafy2bzacear2wkgakll545dlkslu33izpqhy3htxuxjliugcw6rzqne4nsvzq”},”InitialPledgeRequirement”:”312499995095859200”,”LockedFunds”:”1486913487001229156804”,”PreCommitDeposits”:”0”,”PreCommittedSectors”:{“/“:”bafy2bzaceamp42wmmgr2g2ymg46euououzfyck7szknvfacqscohrvaikwfay”},”PreCommittedSectorsExpiry”:{“/“:”bafy2bzaceaeadzbk3fhkojehlssencvwed4qp5f7jtvc6par57rwguukzpgry”},”ProvingPeriodStart”:658,”Sectors”:{“/“:”bafy2bzaceatqbymaxk7ixlimx6j7ro27syuqaxon6uslpivbglxe7f4svfpto”},”VestingFunds”:{“/“:”bafy2bzaceb2wgzosl64cjafe2yt5hiil3a2kab443wxkqns5tm4x4bpnnrpgg”}}
{“AllocatedSectors”:{“/“:”bafy2bzacec3kfucxpfukfcnlhz73eymnjhirmlrc5z2nop2plbqvocsxj66ra”},”CurrentDeadline”:0,”Deadlines”:{“/“:”bafy2bzacecebj2awf7slcrrl7hrgz6ox2rzq4zscqxv27kwofmkjtytdoweyo”},”EarlyTerminations”:[0],”Info”:{“/“:”bafy2bzacear2wkgakll545dlkslu33izpqhy3htxuxjliugcw6rzqne4nsvzq”},”InitialPledgeRequirement”:”312499995095859200”,”LockedFunds”:”623779110704376371288”,”PreCommitDeposits”:”0”,”PreCommittedSectors”:{“/“:”bafy2bzaceamp42wmmgr2g2ymg46euououzfyck7szknvfacqscohrvaikwfay”},”PreCommittedSectorsExpiry”:{“/“:”bafy2bzaceaeadzbk3fhkojehlssencvwed4qp5f7jtvc6par57rwguukzpgry”},”ProvingPeriodStart”:658,”Sectors”:{“/“:”bafy2bzaceatqbymaxk7ixlimx6j7ro27syuqaxon6uslpivbglxe7f4svfpto”},”VestingFunds”:{“/“:”bafy2bzacebpdufvkcfjmrv2cuxlmtkam4muj2pqtk2shgzer5nnrxwhmwsbf6”}}
{“AllocatedSectors”:{“/“:”bafy2bzacec3kfucxpfukfcnlhz73eymnjhirmlrc5z2nop2plbqvocsxj66ra”},”CurrentDeadline”:20,”Deadlines”:{“/“:”bafy2bzacecebj2awf7slcrrl7hrgz6ox2rzq4zscqxv27kwofmkjtytdoweyo”},”EarlyTerminations”:[0],”Info”:{“/“:”bafy2bzacear2wkgakll545dlkslu33izpqhy3htxuxjliugcw6rzqne4nsvzq”},”InitialPledgeRequirement”:”312499995095859200”,”LockedFunds”:”277146830514602748944950”,”PreCommitDeposits”:”0”,”PreCommittedSectors”:{“/“:”bafy2bzaceamp42wmmgr2g2ymg46euououzfyck7szknvfacqscohrvaikwfay”},”PreCommittedSectorsExpiry”:{“/“:”bafy2bzaceaeadzbk3fhkojehlssencvwed4qp5f7jtvc6par57rwguukzpgry”},”ProvingPeriodStart”:6418,”Sectors”:{“/“:”bafy2bzaceatqbymaxk7ixlimx6j7ro27syuqaxon6uslpivbglxe7f4svfpto”},”VestingFunds”:{“/“:”bafy2bzacebeayd6hvuawxpvdz6hymjyildkrzlkoueodlz7mwt6ilmaib5o6e”}}
actor_states head 关联 actors head
actors parentroot 对应blocks parentroot
blocks根据高度获取parentroot,然后到actors里找到head,再到actor_states里面找到对应的值
watch cat $(ls ~/log/*log | tail -n 1) | grep “block not found” | wc -l
{“AllocatedSectors”:{“/“:”bafy2bzacec3kfucxpfukfcnlhz73eymnjhirmlrc5z2nop2plbqvocsxj66ra”},”CurrentDeadline”:1,”Deadlines”:{“/“:”bafy2bzacecebj2awf7slcrrl7hrgz6ox2rzq4zscqxv27kwofmkjtytdoweyo”},”EarlyTerminations”:[0],”Info”:{“/“:”bafy2bzacear2wkgakll545dlkslu33izpqhy3htxuxjliugcw6rzqne4nsvzq”},”InitialPledgeRequirement”:”312499995095859200”,”LockedFunds”:”26560348586748358971313”,”PreCommitDeposits”:”0”,”PreCommittedSectors”:{“/“:”bafy2bzaceamp42wmmgr2g2ymg46euououzfyck7szknvfacqscohrvaikwfay”},”PreCommittedSectorsExpiry”:{“/“:”bafy2bzaceaeadzbk3fhkojehlssencvwed4qp5f7jtvc6par57rwguukzpgry”},”ProvingPeriodStart”:658,”Sectors”:{“/“:”bafy2bzaceatqbymaxk7ixlimx6j7ro27syuqaxon6uslpivbglxe7f4svfpto”},”VestingFunds”:{“/“:”bafy2bzaceciat4wzrqqz7hxalvvczt7wozs3hyz2mgemvpgdqzyjoxbv7xagm”}}