Documentation ¶
Index ¶
- Variables
- func Connect(ctx context.Context, from, to *fast.Filecoin) error
- func CtxMiningNext(ctx context.Context, count int)
- func CtxMiningOnce(ctx context.Context)
- func CtxSleepDelay(ctx context.Context) <-chan time.Time
- func GetHeadBlockHeight(ctx context.Context, client *fast.Filecoin) (abi.ChainEpoch, error)
- func InitAndStart(ctx context.Context, node *fast.Filecoin, ...) error
- func SendFilecoinDefaults(ctx context.Context, from, to *fast.Filecoin, value int) error
- func SendFilecoinFromDefault(ctx context.Context, node *fast.Filecoin, addr address.Address, value int) (cid.Cid, error)
- func SetCtxMiningOnce(ctx context.Context, fn MiningOnceFunc) context.Context
- func SetCtxSleepDelay(ctx context.Context, d time.Duration) context.Context
- func SetCtxWaitForMpool(ctx context.Context, fn MpoolWaitFunc) context.Context
- func SetupGenesisNode(ctx context.Context, node *fast.Filecoin, minerAddress address.Address, ...) error
- func WaitForBlockHeight(ctx context.Context, client *fast.Filecoin, bh abi.ChainEpoch) error
- func WithWallet(ctx context.Context, fc *fast.Filecoin, sessionWallet address.Address, ...) (err error)
- type MiningOnceFunc
- type MpoolWaitFunc
- type MsgInfo
- type MsgSearchFn
Constants ¶
This section is empty.
Variables ¶
var ErrWithWalletRestoreFailed = errors.New("failed to restore default wallet after WithWallet exited")
ErrWithWalletRestoreFailed is returned if the original address could not be restored.
Functions ¶
func Connect ¶
Connect issues a `swarm connect` to the `from` node, using the addresses of the `to` node
func CtxMiningNext ¶
CtxMiningNext will call CtxMiningOnce only after a message is in the message pool ready to mine. This lets us run blocking commands that require mining by configuring the mining beforehand.
func CtxMiningOnce ¶
CtxMiningOnce will call the MiningOnceFunc set on the context using SetMiningOnceFunc. If no value is set on the context, the call is a noop.
func CtxSleepDelay ¶
CtxSleepDelay is a helper method to make sure people don't call `time.Sleep` or `time.After` themselves in series. It will use the time.Duration in the context, or default to `clock.epochDuration` from the venus/mining package. A channel is return which will receive a time.Time value after the delay.
func GetHeadBlockHeight ¶
GetHeadBlockHeight will inspect the chain head and return the height
func InitAndStart ¶
func InitAndStart(ctx context.Context, node *fast.Filecoin, fns ...func(context.Context, *fast.Filecoin) error) error
InitAndStart is a quick way to run Init and Start for a filecoin process. A variadic set of functions can be passed to run between init and the start of the daemon to make configuration changes.
func SendFilecoinDefaults ¶
SendFilecoinDefaults sends the `value` amount of fil from the default wallet address of the `from` node to the `to` node's default wallet, and waits for the message to be received by the `to` node.
func SendFilecoinFromDefault ¶
func SendFilecoinFromDefault(ctx context.Context, node *fast.Filecoin, addr address.Address, value int) (cid.Cid, error)
SendFilecoinFromDefault will send the `value` of FIL from the default wallet address, per the config of the `node`, to the provided address `addr` and wait for the message to showup on chain. The waiting node is the sender, this does not guarantee that the message has been received by the targeted node of addr.
func SetCtxMiningOnce ¶
func SetCtxMiningOnce(ctx context.Context, fn MiningOnceFunc) context.Context
SetCtxMiningOnce returns a context with `fn` set in the context. To run the MiningOnceFunc value, call CtxMiningOnce.
func SetCtxSleepDelay ¶
SetCtxSleepDelay returns a context with `d` set in the context. To sleep with the value, call CtxSleepDelay with the context.
func SetCtxWaitForMpool ¶
func SetCtxWaitForMpool(ctx context.Context, fn MpoolWaitFunc) context.Context
SetCtxWaitForMpool returns a context with `fn` set in the context. To run the MiningOnceFunc with a MpoolWaitFunc value, call CtxMiningOnceForBlockingCommand.
func SetupGenesisNode ¶
func SetupGenesisNode(ctx context.Context, node *fast.Filecoin, minerAddress address.Address, minerOwner files.File) error
SetupGenesisNode will initialize, start, configure, and issue the "start mining" command to the filecoin process `node`. Process `node` will be configured with miner `minerAddress`, and import the address of the miner `minerOwner`. Lastly the process `node` will start mining.
func WaitForBlockHeight ¶
WaitForBlockHeight will inspect the chain head and wait till the height is equal to or greater than the provide height `bh`
func WithWallet ¶
func WithWallet(ctx context.Context, fc *fast.Filecoin, sessionWallet address.Address, sessionFn func(*fast.Filecoin) error) (err error)
WithWallet can be used to temporarlly change the default wallet address of the node to sessionWallet for all FAST actions executed inside of sessionFn.
WithWallet should be used when you want to temporarally change the default wallet address of the node.
Error ErrWithWalletRestoreFailed will be returned if the original address could not be restored.
Types ¶
type MiningOnceFunc ¶
type MiningOnceFunc func()
MiningOnceFunc is the type for the value used when calling SetCtxMiningOnce
type MpoolWaitFunc ¶
type MpoolWaitFunc func()
MpoolWaitFunc is a function that can wait for a message to appear in its queu
type MsgInfo ¶
type MsgInfo struct { BlockCid cid.Cid MsgCid cid.Cid }
MsgInfo contains the BlockCid for the message MsgCid
func WaitForChainMessage ¶
func WaitForChainMessage(ctx context.Context, node *fast.Filecoin, fn MsgSearchFn) (*MsgInfo, error)
WaitForChainMessage iterates over the chain until the provided function `fn` returns true.
type MsgSearchFn ¶
MsgSearchFn is the function signature used to find a message