substrate

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2021 License: LGPL-3.0 Imports: 31 Imported by: 0

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 Mod = 1
View Source
const NonFungibleTransfer eventName = "NonFungibleTransfer"
View Source
const RoundInterval = time.Second * 2

Variables

View Source
var BlockRetryInterval = time.Second * 5

Frequency of polling for a new block

View Source
var ErrBlockNotReady = errors.New("required result to be 32 bytes, but got 0")
View Source
var NotExecuted = MultiSignTx{
	BlockNumber:   -1,
	MultiSignTxId: 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 EncodeCall

func EncodeCall(call types.Call) []byte

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, multiSignAddress types.AccountID, cli *client.Client,
	resource msg.ResourceId, dest msg.ChainId) *listener

func NewWriter

func NewWriter(conn *Connection, listener *listener, log log15.Logger, sysErr chan<- error,
	m *metrics.ChainMetrics, extendCall bool, krp *signature.KeyringPair, otherRelayers []types.AccountID,
	total uint64, current uint64, threshold uint16, weight uint64) *writer

Types

type BlockNumber

type BlockNumber int64

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

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.

type MultiSigAsMulti

type MultiSigAsMulti struct {
	OriginMsTx       MultiSignTx
	Executed         bool
	Threshold        uint16
	OtherSignatories []string
	MaybeTimePoint   expand.TimePointSafe32
	DestAddress      string
	DestAmount       string
	StoreCall        bool
	MaxWeight        uint64
	DepositNonce     msg.Nonce
}

type MultiSignTx

type MultiSignTx struct {
	BlockNumber   BlockNumber
	MultiSignTxId MultiSignTxId
}

type MultiSignTxId

type MultiSignTxId uint64

type MultiSignTxStatistics

type MultiSignTxStatistics struct {
	TotalCount MultiSignTxId
	CurrentTx  MultiSignTx
}

type Relayer

type Relayer struct {
	// contains filtered or unexported fields
}

type TimePointSafe32

type TimePointSafe32 struct {
	Height types.OptionU32
	Index  types.U32
}

Jump to

Keyboard shortcuts

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