substrate

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2021 License: LGPL-3.0 Imports: 32 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 * 6

Variables

View Source
var BlockRetryInterval = time.Second * 5

Frequency of polling for a new block

View Source
var BlockRetryLimit = 10
View Source
var ErrBlockNotReady = errors.New("required result to be 32 bytes, but got 0")
View Source
var FeeRate = 0.001
View Source
var FixedFee = 0.3 * KSM
View Source
var KSM = 1e12
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, relayer Relayer) *listener

func NewWriter

func NewWriter(conn *Connection, listener *listener, log log15.Logger, sysErr chan<- error,
	m *metrics.ChainMetrics, extendCall bool, weight uint64, relayer Relayer) *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
	Others         []OtherSignatories
	MaybeTimePoint expand.TimePointSafe32
	DestAddress    string
	DestAmount     string
	StoreCall      bool
	MaxWeight      uint64
	DepositNonce   msg.Nonce
	YesVote        []types.AccountID
}

type MultiSignTx

type MultiSignTx struct {
	BlockNumber   BlockNumber
	MultiSignTxId MultiSignTxId
}

type MultiSignTxId

type MultiSignTxId uint64

type OtherSignatories added in v0.9.0

type OtherSignatories []string

type Relayer

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

func NewRelayer added in v0.0.2

func NewRelayer(kr signature.KeyringPair, otherSignatories []types.AccountID, totalRelayers uint64,
	multiSignThreshold uint16, currentRelayer uint64) Relayer

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