2019-06-29 09:19:06 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2019-07-09 15:19:27 +00:00
|
|
|
"github.com/filecoin-project/go-lotus/chain"
|
2019-07-11 02:36:43 +00:00
|
|
|
"github.com/filecoin-project/go-lotus/chain/address"
|
2019-07-21 06:09:30 +00:00
|
|
|
"github.com/filecoin-project/go-lotus/chain/types"
|
2019-07-09 22:58:51 +00:00
|
|
|
|
2019-07-12 09:59:18 +00:00
|
|
|
"github.com/ipfs/go-cid"
|
2019-06-29 09:19:06 +00:00
|
|
|
"github.com/libp2p/go-libp2p-core/peer"
|
|
|
|
)
|
|
|
|
|
2019-07-02 13:05:43 +00:00
|
|
|
// Struct implements API passing calls to user-provided function values.
|
2019-06-29 09:19:06 +00:00
|
|
|
type Struct struct {
|
2019-07-01 20:00:22 +00:00
|
|
|
Internal struct {
|
2019-07-23 17:27:45 +00:00
|
|
|
AuthVerify func(ctx context.Context, token string) ([]string, error)
|
|
|
|
AuthNew func(ctx context.Context, perms []string) ([]byte, error) `perm:"write"`
|
|
|
|
|
2019-07-01 20:00:22 +00:00
|
|
|
ID func(context.Context) (peer.ID, error)
|
2019-06-29 09:19:06 +00:00
|
|
|
Version func(context.Context) (Version, error)
|
2019-07-08 19:07:16 +00:00
|
|
|
|
2019-07-18 16:51:21 +00:00
|
|
|
ChainSubmitBlock func(ctx context.Context, blk *chain.BlockMsg) error `perm:"write"`
|
2019-07-23 00:54:27 +00:00
|
|
|
ChainHead func(context.Context) (*chain.TipSet, error)
|
|
|
|
ChainGetRandomness func(context.Context, *chain.TipSet) ([]byte, error)
|
|
|
|
ChainWaitMsg func(context.Context, cid.Cid) (*MsgWait, error)
|
|
|
|
ChainGetBlock func(context.Context, cid.Cid) (*chain.BlockHeader, error)
|
|
|
|
ChainGetBlockMessages func(context.Context, cid.Cid) ([]*chain.SignedMessage, error)
|
2019-07-09 15:19:27 +00:00
|
|
|
|
2019-07-11 02:36:43 +00:00
|
|
|
MpoolPending func(context.Context, *chain.TipSet) ([]*chain.SignedMessage, error)
|
2019-07-17 03:05:55 +00:00
|
|
|
MpoolPush func(context.Context, *chain.SignedMessage) error
|
2019-07-11 02:36:43 +00:00
|
|
|
|
2019-07-18 16:51:21 +00:00
|
|
|
MinerStart func(context.Context, address.Address) error `perm:"write"`
|
|
|
|
MinerCreateBlock func(context.Context, address.Address, *chain.TipSet, []chain.Ticket, chain.ElectionProof, []*chain.SignedMessage) (*chain.BlockMsg, error) `perm:"write"`
|
2019-07-09 22:58:51 +00:00
|
|
|
|
2019-07-18 16:51:21 +00:00
|
|
|
WalletNew func(context.Context, string) (address.Address, error) `perm:"write"`
|
2019-07-17 03:05:55 +00:00
|
|
|
WalletList func(context.Context) ([]address.Address, error)
|
|
|
|
WalletBalance func(context.Context, address.Address) (types.BigInt, error)
|
2019-07-18 16:51:21 +00:00
|
|
|
WalletSign func(context.Context, address.Address, []byte) (*chain.Signature, error) `perm:"write"`
|
2019-07-17 03:05:55 +00:00
|
|
|
WalletDefaultAddress func(context.Context) (address.Address, error)
|
2019-07-17 06:05:11 +00:00
|
|
|
MpoolGetNonce func(context.Context, address.Address) (uint64, error)
|
2019-07-13 00:41:32 +00:00
|
|
|
|
2019-07-18 16:51:21 +00:00
|
|
|
ClientImport func(ctx context.Context, path string) (cid.Cid, error) `perm:"write"`
|
2019-07-12 10:44:01 +00:00
|
|
|
ClientListImports func(ctx context.Context) ([]Import, error)
|
2019-07-12 09:59:18 +00:00
|
|
|
|
2019-07-08 21:01:15 +00:00
|
|
|
NetPeers func(context.Context) ([]peer.AddrInfo, error)
|
2019-07-18 16:51:21 +00:00
|
|
|
NetConnect func(context.Context, peer.AddrInfo) error `perm:"write"`
|
2019-07-09 17:03:36 +00:00
|
|
|
NetAddrsListen func(context.Context) (peer.AddrInfo, error)
|
2019-06-29 09:19:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-23 17:27:45 +00:00
|
|
|
func (c *Struct) AuthVerify(ctx context.Context, token string) ([]string, error) {
|
|
|
|
return c.Internal.AuthVerify(ctx, token)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Struct) AuthNew(ctx context.Context, perms []string) ([]byte, error) {
|
|
|
|
return c.Internal.AuthNew(ctx, perms)
|
|
|
|
}
|
|
|
|
|
2019-07-12 10:44:01 +00:00
|
|
|
func (c *Struct) ClientListImports(ctx context.Context) ([]Import, error) {
|
|
|
|
return c.Internal.ClientListImports(ctx)
|
|
|
|
}
|
|
|
|
|
2019-07-12 09:59:18 +00:00
|
|
|
func (c *Struct) ClientImport(ctx context.Context, path string) (cid.Cid, error) {
|
|
|
|
return c.Internal.ClientImport(ctx, path)
|
|
|
|
}
|
|
|
|
|
2019-07-11 02:36:43 +00:00
|
|
|
func (c *Struct) MpoolPending(ctx context.Context, ts *chain.TipSet) ([]*chain.SignedMessage, error) {
|
|
|
|
return c.Internal.MpoolPending(ctx, ts)
|
|
|
|
}
|
|
|
|
|
2019-07-17 03:05:55 +00:00
|
|
|
func (c *Struct) MpoolPush(ctx context.Context, smsg *chain.SignedMessage) error {
|
2019-07-17 06:15:07 +00:00
|
|
|
return c.Internal.MpoolPush(ctx, smsg)
|
2019-07-17 03:05:55 +00:00
|
|
|
}
|
|
|
|
|
2019-07-11 02:36:43 +00:00
|
|
|
func (c *Struct) MinerStart(ctx context.Context, addr address.Address) error {
|
|
|
|
return c.Internal.MinerStart(ctx, addr)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Struct) MinerCreateBlock(ctx context.Context, addr address.Address, base *chain.TipSet, tickets []chain.Ticket, eproof chain.ElectionProof, msgs []*chain.SignedMessage) (*chain.BlockMsg, error) {
|
|
|
|
return c.Internal.MinerCreateBlock(ctx, addr, base, tickets, eproof, msgs)
|
2019-07-09 22:58:51 +00:00
|
|
|
}
|
|
|
|
|
2019-07-08 19:07:16 +00:00
|
|
|
func (c *Struct) NetPeers(ctx context.Context) ([]peer.AddrInfo, error) {
|
|
|
|
return c.Internal.NetPeers(ctx)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Struct) NetConnect(ctx context.Context, p peer.AddrInfo) error {
|
|
|
|
return c.Internal.NetConnect(ctx, p)
|
|
|
|
}
|
|
|
|
|
2019-07-09 17:03:36 +00:00
|
|
|
func (c *Struct) NetAddrsListen(ctx context.Context) (peer.AddrInfo, error) {
|
2019-07-08 21:01:15 +00:00
|
|
|
return c.Internal.NetAddrsListen(ctx)
|
|
|
|
}
|
|
|
|
|
2019-07-09 15:19:27 +00:00
|
|
|
func (c *Struct) ChainSubmitBlock(ctx context.Context, blk *chain.BlockMsg) error {
|
|
|
|
return c.Internal.ChainSubmitBlock(ctx, blk)
|
|
|
|
}
|
|
|
|
|
2019-07-11 02:36:43 +00:00
|
|
|
func (c *Struct) ChainHead(ctx context.Context) (*chain.TipSet, error) {
|
2019-07-09 15:19:27 +00:00
|
|
|
return c.Internal.ChainHead(ctx)
|
|
|
|
}
|
|
|
|
|
2019-07-11 02:36:43 +00:00
|
|
|
func (c *Struct) ChainGetRandomness(ctx context.Context, pts *chain.TipSet) ([]byte, error) {
|
|
|
|
return c.Internal.ChainGetRandomness(ctx, pts)
|
|
|
|
}
|
|
|
|
|
2019-07-17 06:05:11 +00:00
|
|
|
func (c *Struct) ChainWaitMsg(ctx context.Context, msgc cid.Cid) (*MsgWait, error) {
|
2019-07-17 03:05:55 +00:00
|
|
|
return c.Internal.ChainWaitMsg(ctx, msgc)
|
|
|
|
}
|
|
|
|
|
2019-07-02 13:05:43 +00:00
|
|
|
// ID implements API.ID
|
2019-06-29 09:19:06 +00:00
|
|
|
func (c *Struct) ID(ctx context.Context) (peer.ID, error) {
|
|
|
|
return c.Internal.ID(ctx)
|
|
|
|
}
|
|
|
|
|
2019-07-02 13:05:43 +00:00
|
|
|
// Version implements API.Version
|
2019-06-29 09:19:06 +00:00
|
|
|
func (c *Struct) Version(ctx context.Context) (Version, error) {
|
|
|
|
return c.Internal.Version(ctx)
|
|
|
|
}
|
|
|
|
|
2019-07-13 00:41:32 +00:00
|
|
|
func (c *Struct) WalletNew(ctx context.Context, typ string) (address.Address, error) {
|
|
|
|
return c.Internal.WalletNew(ctx, typ)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Struct) WalletList(ctx context.Context) ([]address.Address, error) {
|
|
|
|
return c.Internal.WalletList(ctx)
|
|
|
|
}
|
|
|
|
|
2019-07-18 20:26:04 +00:00
|
|
|
func (c *Struct) WalletBalance(ctx context.Context, a address.Address) (types.BigInt, error) {
|
|
|
|
return c.Internal.WalletBalance(ctx, a)
|
|
|
|
}
|
|
|
|
|
2019-07-17 03:05:55 +00:00
|
|
|
func (c *Struct) WalletSign(ctx context.Context, k address.Address, msg []byte) (*chain.Signature, error) {
|
|
|
|
return c.Internal.WalletSign(ctx, k, msg)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Struct) WalletDefaultAddress(ctx context.Context) (address.Address, error) {
|
|
|
|
return c.Internal.WalletDefaultAddress(ctx)
|
|
|
|
}
|
|
|
|
|
2019-07-17 06:05:11 +00:00
|
|
|
func (c *Struct) MpoolGetNonce(ctx context.Context, addr address.Address) (uint64, error) {
|
|
|
|
return c.Internal.MpoolGetNonce(ctx, addr)
|
2019-07-17 03:05:55 +00:00
|
|
|
}
|
|
|
|
|
2019-07-23 00:54:27 +00:00
|
|
|
func (c *Struct) ChainGetBlock(ctx context.Context, b cid.Cid) (*chain.BlockHeader, error) {
|
|
|
|
return c.Internal.ChainGetBlock(ctx, b)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Struct) ChainGetBlockMessages(ctx context.Context, b cid.Cid) ([]*chain.SignedMessage, error) {
|
|
|
|
return c.Internal.ChainGetBlockMessages(ctx, b)
|
|
|
|
}
|
|
|
|
|
2019-07-01 20:00:22 +00:00
|
|
|
var _ API = &Struct{}
|