lotus/api/struct.go

103 lines
3.4 KiB
Go
Raw Normal View History

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-09 22:58:51 +00:00
2019-07-12 09:59:18 +00:00
"github.com/ipfs/go-cid"
"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.
type Struct struct {
Internal struct {
ID func(context.Context) (peer.ID, error)
Version func(context.Context) (Version, error)
2019-07-08 19:07:16 +00:00
2019-07-11 02:36:43 +00:00
ChainSubmitBlock func(ctx context.Context, blk *chain.BlockMsg) error
ChainHead func(context.Context) (*chain.TipSet, error)
ChainGetRandomness func(context.Context, *chain.TipSet) ([]byte, 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)
MinerStart func(context.Context, address.Address) error
MinerCreateBlock func(context.Context, address.Address, *chain.TipSet, []chain.Ticket, chain.ElectionProof, []*chain.SignedMessage) (*chain.BlockMsg, error)
2019-07-09 22:58:51 +00:00
2019-07-13 00:41:32 +00:00
WalletNew func(context.Context, string) (address.Address, error)
WalletList func(context.Context) ([]address.Address, error)
2019-07-12 10:44:01 +00:00
ClientImport func(ctx context.Context, path string) (cid.Cid, error)
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)
NetConnect func(context.Context, peer.AddrInfo) error
2019-07-09 17:03:36 +00:00
NetAddrsListen func(context.Context) (peer.AddrInfo, error)
}
}
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)
}
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-02 13:05:43 +00:00
// ID implements API.ID
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
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)
}
var _ API = &Struct{}