Documentation ¶
Overview ¶
The substrate package contains the logic for interacting with substrate chains. The current supported transfer types are Fungible, Nonfungible, and generic.
There are 3 major components: the connection, the listener, and the writer.
Connection ¶
The Connection handles connecting to the substrate client, and submitting transactions to the client. It also handles state queries. The connection is shared by the writer and listener.
Listener ¶
The substrate listener polls blocks and parses the associated events for the three transfer types. It then forwards these into the router.
Writer ¶
As the writer receives messages from the router, it constructs proposals. If a proposal is still active, the writer will attempt to vote on it. Resource IDs are resolved to method name on-chain, which are then used in the proposals when constructing the resulting Call struct.
Index ¶
Constants ¶
const FungibleTransfer eventName = "FungibleTransfer"
const GenericTransfer eventName = "GenericTransfer"
const NonFungibleTransfer eventName = "NonFungibleTransfer"
Variables ¶
var AcknowledgeProposal utils.Method = utils.BridgePalletName + ".acknowledge_proposal"
var BlockRetryInterval = time.Second * 5
Frequency of polling for a new block
var BlockRetryLimit = 5
var ErrBlockNotReady = errors.New("required result to be 32 bytes, but got 0")
var Subscriptions = []struct { name eventName handler eventHandler }{ {FungibleTransfer, fungibleTransferHandler}, {NonFungibleTransfer, nonFungibleTransferHandler}, {GenericTransfer, genericTransferHandler}, }
var TerminatedError = errors.New("terminated")
Functions ¶
func NewListener ¶
func NewListener(conn *Connection, name string, id msg.ChainId, startBlock uint64, log log15.Logger, bs blockstore.Blockstorer, stop <-chan int, sysErr chan<- error, m *metrics.ChainMetrics) *listener
func NewWriter ¶
func NewWriter(conn *Connection, log log15.Logger, sysErr chan<- error, m *metrics.ChainMetrics, extendCall bool) *writer
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
func InitializeChain ¶
func InitializeChain(cfg *core.ChainConfig, logger log15.Logger, sysErr chan<- error, m *metrics.ChainMetrics) (*Chain, error)
func (*Chain) LatestBlock ¶
func (c *Chain) LatestBlock() metrics.LatestBlock
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func NewConnection ¶
func NewConnection(url string, name string, key *signature.KeyringPair, log log15.Logger, stop <-chan int, sysErr chan<- error) *Connection
func (*Connection) Close ¶
func (c *Connection) Close()
func (*Connection) Connect ¶
func (c *Connection) Connect() error
func (*Connection) SubmitTx ¶
func (c *Connection) SubmitTx(method utils.Method, args ...interface{}) error
SubmitTx constructs and submits an extrinsic to call the method with the given arguments. All args are passed directly into GSRPC. GSRPC types are recommended to avoid serialization inconsistencies.