substrate

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2022 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Overview

The substrate package contains the logic for interacting with substrate chains. The current supported transfer types are Fungible.

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, nothing happened.

Index

Constants

View Source
const (
	VoteStatusActive   = "Active"
	VoteStatusPassed   = "Passed"
	VoteStatusExpired  = "Expired"
	VoteStatusExecuted = "Executed"
)
View Source
const (
	DefaultTypeFilePath = "../../network/stafi.json"
)
View Source
const FungibleTransfer eventName = config.FungibleTransferEventId

Variables

View Source
var (
	ValueNotStringError = errors.New("value not string")
	SkipError           = errors.New("should skip")
)
View Source
var (
	// Frequency of polling for a new block
	BlockRetryInterval = 6 * time.Second
	BlockRetryLimit    = 100

	EventRetryLimit    = 20
	EventRetryInterval = 100 * time.Millisecond
)
View Source
var ErrorTerminated = errors.New("terminated")
View Source
var Subscriptions = []struct {
	name    eventName
	handler eventHandler
}{{FungibleTransfer, fungibleTransferHandler}}

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, decimals map[string]decimal.Decimal) *listener

func NewWriter

func NewWriter(conn *Connection, log log15.Logger, sysErr chan<- error, stop <-chan int, decimals map[string]decimal.Decimal) *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) (*Chain, error)

func (*Chain) Id

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

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 ChainIdParam

type ChainIdParam struct {
	Type  string `json:"type"`
	Value uint8  `json:"value"`
}

type Connection

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

func NewConnection

func NewConnection(cfg *core.ChainConfig, log log15.Logger, stop <-chan int) (*Connection, error)

func (*Connection) Address

func (c *Connection) Address() string

func (*Connection) Close

func (c *Connection) Close()

func (*Connection) FinalizedBlockNumber

func (c *Connection) FinalizedBlockNumber() (uint64, error)

func (*Connection) GetEvents

func (c *Connection) GetEvents(blockNum uint64) ([]*substrate.ChainEvent, error)

func (*Connection) LatestBlockNumber

func (c *Connection) LatestBlockNumber() (uint64, error)

func (*Connection) QueryStorage

func (c *Connection) QueryStorage(prefix, method string, arg1, arg2 []byte, result interface{}) (bool, error)

queryStorage performs a storage lookup. Arguments may be nil, result must be a pointer.

type DepositNonceParam

type DepositNonceParam struct {
	Type  string `json:"type"`
	Value uint64 `json:"value"`
}

type EventFungibleTransfer

type EventFungibleTransfer struct {
	Destination  uint8
	DepositNonce uint64
	ResourceId   msg.ResourceId
	Amount       *big.Int
	Recipient    []byte
	Decimal      decimal.Decimal
}

type VoteStatus

type VoteStatus string

func (*VoteStatus) Decode

func (m *VoteStatus) Decode(decoder scale.Decoder) error

Jump to

Keyboard shortcuts

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