chain

package
v1.12.7 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: GPL-3.0 Imports: 29 Imported by: 1

Documentation

Index

Constants

View Source
const (
	UnSignedTxTypeUnSpecified             = 0
	UnSignedTxTypeBondEqualUnbondWithdraw = 1
	UnSignedTxTypeDelegate                = 2
	UnSignedTxTypeUnDelegateAndWithdraw   = 3
	UnSignedTxTypeSkipAndWithdraw         = 4
)

Variables

View Source
var (
	ErrNoOutPuts            = errors.New("outputs length is zero")
	ErrNoRewardNeedDelegate = fmt.Errorf("no tx reward need delegate")
	ErrNotFound             = errors.New("NotFound")
	ErrUnknownQueryPath     = errors.New("UnknownQueryPath")
)
View Source
var (
	TxTypeHandleEraPoolUpdatedEvent    = "handleEraPoolUpdatedEvent"
	TxTypeHandleBondReportedEvent      = "handleBondReportedEvent"
	TxTypeHandleActiveReportedEvent    = "handleActiveReportedEvent"
	TxTypeHandleRValidatorUpdatedEvent = "handleRValidatorUpdatedEvent"
)
View Source
var (
	BlockRetryInterval = time.Second * 6
	BlockRetryLimit    = 500
	BlockConfirmNumber = int64(1)
)
View Source
var (
	ErrorTerminated = errors.New("terminated")
)
View Source
var ValidatorBondCapDisabled = types.NewDecFromInt(types.NewInt(-1))

Functions

func CheckMemo added in v1.11.3

func CheckMemo(memoStr string) (retMomoType uint8, retStafiAddress string, retRecoverTxHash string)

func GetBondUnBondProposalId

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

func GetBondUnbondWithdrawMsgsWithTargets added in v1.6.0

func GetBondUnbondWithdrawMsgsWithTargets(client *hubClient.Client, bond, unbond *big.Int,
	poolAddr types.AccAddress, height int64, targets []types.ValAddress, logger log.Logger) (msgs []types.Msg, unSignedType int, err error)

ensue every validator claim reward if bond == unbond: if no delegation before, return errNoMsgs, else gen withdraw tx if bond > unbond: gen delegate tx if bond < unbond: gen undelegate+withdraw tx

func GetBondUnbondWithdrawUnsignedTxWithTargets added in v0.0.2

func GetBondUnbondWithdrawUnsignedTxWithTargets(client *hubClient.Client, bond, unbond, minUnDelegateAmount *big.Int,
	poolAddr types.AccAddress, height int64, targets []types.ValAddress, memo string) (unSignedTx []byte, unSignedTxType int, err error)

ensue every validator claim reward if bond == unbond: if no delegation before, return errNoMsgs, else gen withdraw tx if bond > unbond: gen delegate tx if bond < unbond: gen undelegate+withdraw tx or withdraw tx when no available vals for unbonding

func GetClaimRewardProposalId

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

func GetDelegateRewardUnsignedTxWithReward added in v1.4.0

func GetDelegateRewardUnsignedTxWithReward(client *hubClient.Client, poolAddr types.AccAddress, height int64,
	rewards map[string]types.Coin, memo string) ([]byte, *types.Int, error)

Notice: delegate/undelegate/withdraw operates will withdraw all reward all delegations had withdraw all reward in eraUpdatedEvent handler (0)if rewardAmount of height == 0, hubClient.ErrNoMsgs (1)else gen delegate tx

func GetLatestDealEraUpdatedTx added in v1.6.0

func GetLatestDealEraUpdatedTx(c *hubClient.Client, dstChannelId string) (*types.TxResponse, int64, error)

used for ica pool should filter with dst channel, because the dst channel is unique on dst chain.

func GetLatestReDelegateTx added in v1.5.0

func GetLatestReDelegateTx(c *hubClient.Client, delegatorAddr string) (*types.TxResponse, int64, error)

func GetMemo added in v1.4.1

func GetMemo(era uint32, txType string) string

func GetRewardToBeDelegated added in v1.4.1

func GetRewardToBeDelegated(c *hubClient.Client, delegatorAddr string, era uint32) (map[string]types.Coin, int64, bool, error)

get reward info of pre txs(tx in eraUpdatedEvent of this era and tx in bondReportedEvent/rValidatorUpdatedEvent of era-1) tx in bondReportedEvent of era-1 should use the old validator tx in rValidatorUpdatedEvent of era -1 should replace old to new validator tx in eraUpdatedEvent of this era should already use the new validator

func GetTransferMsgs added in v1.6.0

func GetTransferMsgs(client *hubClient.Client, poolAddr types.AccAddress, receives []*stafiHubXLedgerTypes.Unbonding,
	logger log.Logger) ([]types.Msg, []xBankTypes.Output, error)

func GetTransferProposalId

func GetTransferProposalId(unSignTxHash [32]byte, index uint8) []byte

func GetTransferUnsignedTxWithMemo added in v1.4.0

func GetTransferUnsignedTxWithMemo(client *hubClient.Client, poolAddr types.AccAddress, receives []*stafiHubXLedgerTypes.Unbonding, memo string,
	logger log.Logger) ([]byte, []xBankTypes.Output, error)

func GetValidatorUpdateProposalId

func GetValidatorUpdateProposalId(content []byte, index uint8) []byte

func GetValidatorUpdatedMemo added in v1.5.0

func GetValidatorUpdatedMemo(era uint32, cycleVersion, cycleNumber uint64) string

func NewBlockstore

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

func ParseBondUnBondProposalId

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

func ParseClaimRewardProposalId

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

func ParseMemoAndMsgs added in v1.11.3

func ParseMemoAndMsgs(client *hubClient.Client, txValue []byte) (string, []*xBankTypes.MsgSend, error)

func ShotIdToArray

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

func StartBlock

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

Types

type BlockResult added in v1.10.9

type BlockResult struct {
	Height uint64
	Txs    []*types.TxResponse
}

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 log.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 {
	// get from config file
	BlockstorePath      string            `json:"blockstorePath"`
	StartBlock          int               `json:"startBlock"`
	PoolNameSubKey      map[string]string `json:"pools"`
	MinUnDelegateAmount string            `json:"minUnDelegateAmount"`

	// get from stafihub rparams
	GasPrice      string `json:"gasPrice"`
	EraSeconds    uint32 `json:"eraSeconds"`
	LeastBond     string `json:"leastBond"`
	Offset        int32  `json:"offset"`
	AccountPrefix string `json:"accountPrefix"`

	// get from stafihub
	IcaPoolWithdrawalAddr map[string]string   //delegationAddres => withdrawalAddress
	IcaPoolHostChannel    map[string]string   //delegationAddres => hostChannelId
	PoolTargetValidators  map[string][]string `json:"targetValidators"`
	PoolAddressThreshold  map[string]uint32   `json:"poolThreshold"`
}

type Connection

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

func NewConnection

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

func (*Connection) AddIcaPool added in v1.8.0

func (c *Connection) AddIcaPool(poolAddrStr, withdrawalAddr, hostChannelId string, targetValidators []string) error

func (*Connection) AddPoolTargetValidator added in v1.5.0

func (c *Connection) AddPoolTargetValidator(poolAddrStr string, newVal types.ValAddress)

func (*Connection) BlockStoreUseAddress

func (c *Connection) BlockStoreUseAddress() string

func (*Connection) GetIcaPoolHostChannelId added in v1.8.10

func (c *Connection) GetIcaPoolHostChannelId(poolAddrStr string) (string, error)

func (*Connection) GetIcaPoolRewardAddress added in v1.6.0

func (c *Connection) GetIcaPoolRewardAddress(poolAddrStr string) (types.AccAddress, error)

func (*Connection) GetOnePoolClient

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

func (*Connection) GetPoolClient

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

func (*Connection) GetPoolSubkeyName added in v1.5.0

func (c *Connection) GetPoolSubkeyName(poolAddrStr string) (string, error)

func (*Connection) GetPoolTargetValidators added in v1.5.0

func (c *Connection) GetPoolTargetValidators(poolAddrStr string) ([]types.ValAddress, error)

func (*Connection) GetPoolThreshold added in v1.5.0

func (c *Connection) GetPoolThreshold(poolAddrStr string) (uint32, error)

func (*Connection) RemovePool added in v1.8.0

func (c *Connection) RemovePool(poolAddrStr string)

func (*Connection) RemovePoolClient added in v1.8.0

func (c *Connection) RemovePoolClient(poolAddrStr string)

func (*Connection) RemovePoolTarget added in v1.8.0

func (c *Connection) RemovePoolTarget(poolAddrStr string)

func (*Connection) ReplacePoolTargetValidator added in v1.5.0

func (c *Connection) ReplacePoolTargetValidator(poolAddrStr string, oldVal, newVal types.ValAddress)

func (*Connection) SetPoolTargetValidators added in v1.5.0

func (c *Connection) SetPoolTargetValidators(poolAddrStr string, vals []types.ValAddress) error

type Handler

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

func NewHandler

func NewHandler(conn *Connection, minUnDelegateAmount types.Int, log log.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(symbol core.RSymbol, startBlock uint64, bs utils.Blockstorer, conn *Connection, log log.Logger, stopChan <-chan struct{}, sysErr chan<- error) *Listener

func (Listener) SubmitProposalExeLiquidityBond

func (l Listener) SubmitProposalExeLiquidityBond(proposalExeLiquidityBond core.ProposalExeLiquidityBond) error

blocked until tx is dealed on stafichain

func (Listener) SubmitProposalExeNativeAndLsmLiquidityBond added in v1.11.1

func (l Listener) SubmitProposalExeNativeAndLsmLiquidityBond(proposalExeNativeAndLsmLiquidityBond core.ProposalExeNativeAndLsmLiquidityBond) error

blocked until tx is dealed on stafichain

type RParams

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

type WrapUnsignedTx

type WrapUnsignedTx struct {
	UnsignedTx     []byte
	Key            string
	SnapshotId     string
	Era            uint32
	Bond           *big.Int
	Unbond         *big.Int
	Type           stafiHubXLedgerTypes.OriginalTxType
	PoolAddressStr string
	CycleVersion   uint64
	CycleNumber    uint64
	OldValidator   types.ValAddress
	NewValidator   types.ValAddress
}

Jump to

Keyboard shortcuts

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