substrate

package
v1.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2021 License: LGPL-3.0 Imports: 22 Imported by: 1

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

View Source
const FungibleTransfer eventName = "FungibleTransfer"
View Source
const GenericTransfer eventName = "GenericTransfer"
View Source
const NonFungibleTransfer eventName = "NonFungibleTransfer"

Variables

View Source
var AcknowledgeProposal utils.Method = utils.BridgePalletName + ".acknowledge_proposal"
View Source
var BlockRetryInterval = time.Second * 5

Frequency of polling for a new block

View Source
var BlockRetryLimit = 5
View Source
var ErrBlockNotReady = errors.New("required result to be 32 bytes, but got 0")
View Source
var Subscriptions = []struct {
	name    eventName
	handler eventHandler
}{
	{FungibleTransfer, fungibleTransferHandler},
	{NonFungibleTransfer, nonFungibleTransferHandler},
	{GenericTransfer, genericTransferHandler},
}
View Source
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) Id

func (c *Chain) Id() msg.ChainId

func (*Chain) LatestBlock added in v1.0.4

func (c *Chain) LatestBlock() metrics.LatestBlock

func (*Chain) Name

func (c *Chain) Name() string

func (*Chain) SetRouter

func (c *Chain) SetRouter(r *core.Router)

func (*Chain) Start

func (c *Chain) Start() error

func (*Chain) Stop

func (c *Chain) Stop()

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL