Documentation ¶
Index ¶
- Variables
- func DampenLatency[T any](in <-chan T, out chan<- T, interval time.Duration, delay time.Duration)
- func NewEthClient(rpcUrl string) (ethcli *ethclient.Client, chainId *big.Int, err error)
- func SetNonce(auth *bind.TransactOpts, ethcli ethereum.PendingStateReader) error
- func WaitForTx(ethcli ethereum.TransactionReader, tx *types.Transaction) error
- type ActionBatchSubscription
- type ActionSender
- func (a *ActionSender) SendAction(action arch.Action) (*types.Transaction, error)
- func (a *ActionSender) SendActions(actionBatch []arch.Action) (*types.Transaction, error)
- func (a *ActionSender) StartSendingActions(actionsChan <-chan []arch.Action, txUpdateChan chan<- *ActionTxUpdate, ...) (<-chan error, func())
- type ActionTxStatus
- type ActionTxUpdate
- type EthCli
- type IO
- func (io *IO) ActionBatchOutChan() <-chan arch.ActionBatch
- func (io *IO) ActionInChan() chan<- []arch.Action
- func (io *IO) ErrChan() <-chan error
- func (io *IO) Hinter() *TxHinter
- func (io *IO) NewClient(kv lib.KeyValueStore, core arch.Core) *client.Client
- func (io *IO) RegisterCancelFn(fn func())
- func (io *IO) SetTxUpdateHook(fn func(*ActionTxUpdate))
- func (io *IO) Stop()
- type TableGetter
- type TxHinter
- type TxMonitor
- func (txm *TxMonitor) AddTxHash(txHash common.Hash)
- func (txm *TxMonitor) HasTx(txHash common.Hash) bool
- func (txm *TxMonitor) IsPending(tx *types.Transaction) bool
- func (txm *TxMonitor) PendingTxs() []common.Hash
- func (txm *TxMonitor) PendingTxsCount() int
- func (txm *TxMonitor) RemoveTx(txHash common.Hash)
- func (txm *TxMonitor) Update() (modified bool)
Constants ¶
This section is empty.
Variables ¶
var ( StandardTimeout = 5 * time.Second // Standard timeout for RPC requests BlockQueryLimit uint64 = 256 // Maximum number of blocks to query in a single request HeaderChanSize = 4 // Size of the header channel )
Functions ¶
func DampenLatency ¶
DampenLatency dampens the latency of a channel by adding a delay to cushion latency variability.
func NewEthClient ¶
func SetNonce ¶
func SetNonce(auth *bind.TransactOpts, ethcli ethereum.PendingStateReader) error
func WaitForTx ¶
func WaitForTx(ethcli ethereum.TransactionReader, tx *types.Transaction) error
Types ¶
type ActionBatchSubscription ¶
type ActionBatchSubscription struct {
// contains filtered or unexported fields
}
ActionBatchSubscription is a subscription to action batches emitted by a core contract.
func SubscribeActionBatches ¶
func SubscribeActionBatches( ethcli EthCli, actionSchemas arch.ActionSchemas, coreAddress common.Address, startingBlockNumber uint64, actionBatchesChan chan<- arch.ActionBatchWithLogs, ) *ActionBatchSubscription
SubscribeActionBatches subscribes to action batches emitted by the core contract at coreAddress.
func (*ActionBatchSubscription) Err ¶
func (s *ActionBatchSubscription) Err() <-chan error
Err returns the subscription error channel. Only one value will ever be sent. The error channel is closed by Unsubscribe.
func (*ActionBatchSubscription) Unsubscribe ¶
func (s *ActionBatchSubscription) Unsubscribe()
Unsubscribe unsubscribes from the action batch subscription and closes the error channel. It does not close the action batch channel.
type ActionSender ¶
type ActionSender struct {
// contains filtered or unexported fields
}
ActionSender sends actions to a core contract.
func NewActionSender ¶
func NewActionSender( ethcli EthCli, actionSchemas arch.ActionSchemas, gasEstimator ethereum.GasEstimator, contractAddress common.Address, from common.Address, nonce uint64, signerFn bind.SignerFn, ) *ActionSender
NewActionSender creates a new ActionSender.
func (*ActionSender) SendAction ¶
func (a *ActionSender) SendAction(action arch.Action) (*types.Transaction, error)
SendAction sends and action to the contract.
func (*ActionSender) SendActions ¶
func (a *ActionSender) SendActions(actionBatch []arch.Action) (*types.Transaction, error)
SendActions sends multiple actions to the contract in a single transaction.
func (*ActionSender) StartSendingActions ¶
func (a *ActionSender) StartSendingActions( actionsChan <-chan []arch.Action, txUpdateChan chan<- *ActionTxUpdate, retryTxData <-chan []byte, retryTxHashes chan<- common.Hash, ) (<-chan error, func())
StartSendingActions starts sending actions from the given channel.
type ActionTxStatus ¶
type ActionTxStatus uint8
const ( ActionTxStatus_Unsent ActionTxStatus = iota ActionTxStatus_Pending ActionTxStatus_Included ActionTxStatus_Failed )
func (*ActionTxStatus) String ¶
func (c *ActionTxStatus) String() string
type ActionTxUpdate ¶
type IO ¶
type IO struct {
// contains filtered or unexported fields
}
func NewIO ¶
func NewIO( ethcli EthCli, blockTime time.Duration, schemas arch.ArchSchemas, auth *bind.TransactOpts, gameAddress, coreAddress common.Address, startingBlockNumber uint64, dampenDelay time.Duration, ) *IO
NewIO creates a new IO.
func (*IO) ActionBatchOutChan ¶
func (io *IO) ActionBatchOutChan() <-chan arch.ActionBatch
func (*IO) ActionInChan ¶
func (*IO) RegisterCancelFn ¶
func (io *IO) RegisterCancelFn(fn func())
func (*IO) SetTxUpdateHook ¶
func (io *IO) SetTxUpdateHook(fn func(*ActionTxUpdate))
type TableGetter ¶
type TableGetter struct {
// contains filtered or unexported fields
}
TableGetter reads a table from the core contract.
func NewTableReader ¶
func NewTableReader( ethcli EthCli, tableSchemas arch.TableSchemas, coreAddress common.Address, ) *TableGetter
NewTableReader creates a new TableGetter.
func (*TableGetter) Read ¶
func (t *TableGetter) Read(tableName string, keys ...interface{}) (interface{}, error)
ReadTable reads a table from the contract.
type TxHinter ¶
type TxHinter struct {
// contains filtered or unexported fields
}
func NewTxHinter ¶
func NewTxHinter(txm *TxMonitor, txUpdateChan <-chan *ActionTxUpdate) *TxHinter
NewTxHinter creates a new TxHinter. The TxHinter is used to get the actions sent by all monitored pending transactions.
func (*TxHinter) GetHints ¶
GetHints returns the actions sent by all monitored pending transactions.
func (*TxHinter) HintNonce ¶
HintNonce returns the nonce of the last hint. The hint is incremented every time the hints change.
type TxMonitor ¶
type TxMonitor struct {
// contains filtered or unexported fields
}
func NewTxMonitor ¶
func NewTxMonitor(ethcli EthCli, retryTxData chan<- []byte, retryTxHashes <-chan common.Hash) *TxMonitor
NewTxMonitor creates a new TxMonitor. The TxMonitor is used to monitor the status of transactions. All included or stale transactions are discarded.
func (*TxMonitor) IsPending ¶
func (txm *TxMonitor) IsPending(tx *types.Transaction) bool
IsPending returns whether a transaction is pending.
func (*TxMonitor) PendingTxs ¶
PendingTxs returns the hash all of monitored transactions that are currently pending.
func (*TxMonitor) PendingTxsCount ¶
PendingTxsCount returns the number of transactions monitored that are currently pending.