chain

package
v0.0.0-...-4591d79 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2022 License: GPL-3.0 Imports: 25 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BlockRetryInterval = time.Second * 6
	BlockRetryLimit    = 50
	BlockConfirmNumber = int64(3)
)
View Source
var (
	ErrEventAttributeNumberUnMatch = errors.New("ErrEventAttributeNumberUnMatch")
)
View Source
var ErrNoOutPuts = errors.New("outputs length is zero")
View Source
var (
	ErrorTerminated = errors.New("terminated")
)

Functions

func GetBondUnBondProposalId

func GetBondUnBondProposalId(shotId [32]byte, bond, unbond *big.Int, seq uint64) []byte

func GetBondUnbondUnsignedTx

func GetBondUnbondUnsignedTx(client *hubClient.Client, bond, unbond *big.Int,
	poolAddr types.AccAddress, height int64) (unSignedTx []byte, err error)

if bond == unbond return err if bond > unbond gen delegate tx if bond < unbond gen undelegate tx

func GetBondUnbondUnsignedTxWithTargets

func GetBondUnbondUnsignedTxWithTargets(client *hubClient.Client, bond, unbond *big.Int,
	poolAddr types.AccAddress, height int64, targets []types.ValAddress) (unSignedTx []byte, err error)

if bond == unbond return err if bond > unbond gen delegate tx if bond < unbond gen undelegate tx

func GetClaimRewardProposalId

func GetClaimRewardProposalId(shotId [32]byte, height uint64) []byte

func GetClaimRewardUnsignedTx

func GetClaimRewardUnsignedTx(client *hubClient.Client, poolAddr types.AccAddress, height int64,
	bond, unBond *big.Int) ([]byte, int, *types.Int, error)

if bond > unbond only gen delegate tx (txType: 2) if bond <= unbond

(1)if balanceAmount > rewardAmount of era height ,gen withdraw and delegate tx  (txType: 3)
(2)if balanceAmount < rewardAmount of era height, gen withdraw tx  (txTpye: 1)

func GetTransferProposalId

func GetTransferProposalId(txHash [32]byte, seq uint64) []byte

func GetTransferUnsignedTx

func GetTransferUnsignedTx(client *hubClient.Client, poolAddr types.AccAddress, receives []stafiHubXLedgerTypes.Unbonding,
	logger log15.Logger) ([]byte, []xBankTypes.Output, error)

func GetValidatorUpdateProposalId

func GetValidatorUpdateProposalId(content []byte) []byte

func NewBlockstore

func NewBlockstore(path string, relayer string) (*blockstore.Blockstore, error)

func ParseBondUnBondProposalId

func ParseBondUnBondProposalId(content []byte) (shotId [32]byte, bond, unbond *big.Int, seq uint64, err error)

func ParseClaimRewardProposalId

func ParseClaimRewardProposalId(content []byte) (shotId [32]byte, height uint64, err error)

func ShotIdToArray

func ShotIdToArray(shotId string) ([32]byte, error)

func StartBlock

func StartBlock(bs *blockstore.Blockstore, blk uint64) (uint64, error)

Types

type Chain

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

func NewChain

func NewChain() *Chain

func (*Chain) Initialize

func (c *Chain) Initialize(cfg *config.RawChainConfig, logger log15.Logger, sysErr chan<- error) error

func (*Chain) Name

func (c *Chain) Name() string

func (*Chain) RSymbol

func (c *Chain) RSymbol() core.RSymbol

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()

stop will stop handler and listener

type ConfigOption

type ConfigOption struct {
	BlockstorePath   string            `json:"blockstorePath"`
	StartBlock       int               `json:"startBlock"`
	ChainID          string            `json:"chainId"`
	Denom            string            `json:"denom"`
	GasPrice         string            `json:"gasPrice"`
	EraSeconds       int               `json:"eraSeconds"`
	Pools            map[string]string `json:"pools"`
	TargetValidators []string          `json:"targetValidators"`
}

type Connection

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

func NewConnection

func NewConnection(cfg *config.RawChainConfig, option ConfigOption, log log15.Logger) (*Connection, error)

func (*Connection) BlockStoreUseAddress

func (c *Connection) BlockStoreUseAddress() string

func (*Connection) CacheUnsignedTx

func (pc *Connection) CacheUnsignedTx(key string, tx *WrapUnsignedTx)

func (*Connection) CachedUnsignedTxNumber

func (pc *Connection) CachedUnsignedTxNumber() int

func (*Connection) GetHeightByEra

func (pc *Connection) GetHeightByEra(era uint32) (int64, error)

func (*Connection) GetOnePoolClient

func (c *Connection) GetOnePoolClient() (*hubClient.Client, error)

func (*Connection) GetPoolClient

func (c *Connection) GetPoolClient(poolAddr string) (*hubClient.Client, error)

func (*Connection) GetWrappedUnsignedTx

func (pc *Connection) GetWrappedUnsignedTx(key string) (*WrapUnsignedTx, error)

func (*Connection) RemoveUnsignedTx

func (pc *Connection) RemoveUnsignedTx(key string)

type Handler

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

func NewHandler

func NewHandler(targets []types.ValAddress, conn *Connection, log log15.Logger, stopChan <-chan struct{}, sysErrChan chan<- error) *Handler

func (*Handler) HandleMessage

func (h *Handler) HandleMessage(m *core.Message)

resolve msg from other chains

type Listener

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

func NewListener

func NewListener(name string, symbol core.RSymbol, startBlock uint64, bs blockstore.Blockstorer, conn *Connection, log log15.Logger, stopChan <-chan struct{}, sysErr chan<- error) *Listener

type WrapUnsignedTx

type WrapUnsignedTx struct {
	UnsignedTx []byte
	Key        string
	SnapshotId string
	Era        uint32
	Bond       *big.Int
	Unbond     *big.Int
	Type       stafiHubXLedgerTypes.OriginalTxType
}

Jump to

Keyboard shortcuts

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