core

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: GPL-3.0 Imports: 10 Imported by: 10

Documentation

Index

Constants

View Source
const (
	//send from other chain
	ReasonNewEra                       = Reason("NewEra")
	ReasonExeLiquidityBond             = Reason("ExeLiquidityBond")
	ReasonExeNativeAndLsmLiquidityBond = Reason("ExeLiquidityNativeAndLsmBond")
	ReasonBondReport                   = Reason("BondReport")
	ReasonActiveReport                 = Reason("ActiveReport")
	ReasonTransferReport               = Reason("TransferReport")
	ReasonSubmitSignature              = Reason("SubmitSignature")
	ReasonRValidatorUpdateReport       = Reason("RValidatorUpdateReport")
	ReasonInterchainTx                 = Reason("InterchainTx")

	//send when got event from stafihub chain
	ReasonEraPoolUpdatedEvent    = Reason("EraPoolUpdatedEvent")
	ReasonBondReportedEvent      = Reason("BondReportedEvent")
	ReasonActiveReportedEvent    = Reason("ActiveReportedEvent")
	ReasonTransferReportedEvent  = Reason("TransferReportedEvent")
	ReasonSignatureEnoughEvent   = Reason("SignatureEnoughed")
	ReasonRValidatorUpdatedEvent = Reason("RValidatorUpdatedEvent")
	ReasonRValidatorAddedEvent   = Reason("RValidatorAddedEvent")
	ReasonRParamsChangedEvent    = Reason("RParamsChangedEvent")
	ReasonInitPoolEvent          = Reason("InitPoolEvent")
	ReasonRemovePoolEvent        = Reason("RemovePoolEvent")

	//get reason
	ReasonGetPools                   = Reason("GetPools")
	ReasonGetSignatures              = Reason("GetSignatures")
	ReasonGetBondRecord              = Reason("GetBondRecord")
	ReasonGetInterchainTxStatus      = Reason("GetInterchainTxStatus")
	ReasonGetLatestLsmBondProposalId = Reason("GetLatestLsmBondProposalId")
)
View Source
const (
	//stafi hub
	HubRFIS = RSymbol("RFIS")
)

Variables

This section is empty.

Functions

func UseSdkConfigContext

func UseSdkConfigContext(accountPrefix string) func()

UseSDKContext uses a custom Bech32 account prefix and returns a restore func CONTRACT: When using this function, caller must ensure that lock contention doesn't cause program to hang. This function is only for use in codec calls

Types

type Chain

type Chain interface {
	Initialize(cfg *config.RawChainConfig, logger log.Logger, sysErr chan<- error) error
	Start() error // Start chain
	SetRouter(*Router)
	RSymbol() RSymbol
	Name() string
	Stop()
}

type Core

type Core struct {
	Registry []Chain
	// contains filtered or unexported fields
}

func NewCore

func NewCore(logger log.Logger, sysErr <-chan error) *Core

func (*Core) AddChain

func (c *Core) AddChain(chain Chain)

AddChain registers the chain in the Registry and calls Chain.SetRouter()

func (*Core) Errors

func (c *Core) Errors() <-chan error

func (*Core) Start

func (c *Core) Start()

Start will call all registered chains' Start methods and block forever (or until signal is received)

type EventActiveReported

type EventActiveReported struct {
	Denom      string
	ShotId     string
	Snapshot   stafiHubXLedgerTypes.BondSnapshot
	PoolUnbond []*stafiHubXLedgerTypes.Unbonding
}

type EventBondReported

type EventBondReported struct {
	Denom    string
	ShotId   string
	Snapshot stafiHubXLedgerTypes.BondSnapshot
}

type EventEraPoolUpdated

type EventEraPoolUpdated struct {
	Denom      string
	LastEra    uint32
	CurrentEra uint32
	ShotId     string
	Snapshot   stafiHubXLedgerTypes.BondSnapshot
}

=== stafihub -> other chain msg data used in cosmos

type EventInitPool added in v0.2.0

type EventInitPool struct {
	Denom             string
	PoolAddress       string
	WithdrawalAddress string
	HostChannelId     string
	Validators        []string
}

type EventRParamsChanged

type EventRParamsChanged struct {
	Denom      string
	GasPrice   string `json:"gasPrice"`
	EraSeconds uint32 `json:"eraSeconds"`
	LeastBond  string `json:"leastBond"`
	Offset     int32  `json:"offset"`
}

type EventRValidatorAdded added in v0.2.0

type EventRValidatorAdded struct {
	Denom        string
	PoolAddress  string
	Era          uint32
	AddedAddress string
}

type EventRValidatorUpdated added in v0.2.0

type EventRValidatorUpdated struct {
	Denom          string
	PoolAddress    string
	Era            uint32
	OldAddress     string
	NewAddress     string
	CycleVersion   uint64
	CycleNumber    uint64
	CycleSeconds   uint64
	BlockTimestamp int64
}

type EventRemovePool added in v0.2.0

type EventRemovePool struct {
	Denom       string
	PoolAddress string
}

type EventSignatureEnough

type EventSignatureEnough struct {
	Denom      string
	Era        uint32
	Pool       string
	TxType     stafiHubXLedgerTypes.OriginalTxType
	ProposalId string
	Signatures [][]byte
	Threshold  uint32
}

type EventTransferReported

type EventTransferReported struct {
	Denom  string
	ShotId string
}

type Handler

type Handler interface {
	HandleMessage(msg *Message)
}

Handler consumes a message and makes the requried on-chain interactions.

type Message

type Message struct {
	Source      RSymbol
	Destination RSymbol
	Reason      Reason
	Content     interface{}
}

type ParamGetBondRecord

type ParamGetBondRecord struct {
	Denom      string
	TxHash     string
	BondRecord chan stafiHubXLedgerTypes.BondRecord
}

type ParamGetInterchainTxStatus added in v0.2.0

type ParamGetInterchainTxStatus struct {
	PropId string
	Status chan stafiHubXLedgerTypes.InterchainTxStatus
}

type ParamGetLatestLsmBondProposalId added in v0.2.0

type ParamGetLatestLsmBondProposalId struct {
	PropId chan string
}

type ParamGetPools

type ParamGetPools struct {
	Denom string
	Pools chan []string
}

get msg

type ParamGetSignatures

type ParamGetSignatures struct {
	Denom  string
	Era    uint32
	Pool   string
	TxType stafiHubXLedgerTypes.OriginalTxType
	PropId string
	Sigs   chan []string
}

type ParamSubmitSignature

type ParamSubmitSignature struct {
	Denom     string
	Era       uint32
	Pool      string
	TxType    stafiHubXLedgerTypes.OriginalTxType
	PropId    string
	Signature string
}

type ProposalActiveReport

type ProposalActiveReport struct {
	Denom    string
	ShotId   string
	Staked   sdk.Int
	Unstaked sdk.Int
}

type ProposalBondReport

type ProposalBondReport struct {
	Denom  string
	ShotId string
	Action stafiHubXLedgerTypes.BondAction
}

type ProposalExeLiquidityBond

type ProposalExeLiquidityBond struct {
	Denom  string
	Bonder string
	Pool   string
	Txhash string
	Amount sdk.Int
	State  stafiHubXLedgerTypes.LiquidityBondState
}

=== other chain -> stafihub msg data used in cosmos

type ProposalExeNativeAndLsmLiquidityBond added in v0.2.0

type ProposalExeNativeAndLsmLiquidityBond struct {
	Denom            string
	Bonder           string
	Pool             string
	Txhash           string
	NativeBondAmount sdk.Int
	LsmBondAmount    sdk.Int
	State            stafiHubXLedgerTypes.LiquidityBondState
	Msgs             []sdk.Msg
}

type ProposalInterchainTx added in v0.2.0

type ProposalInterchainTx struct {
	Denom  string
	Pool   string
	Era    uint32
	TxType stafiHubXLedgerTypes.OriginalTxType
	Factor uint32
	Msgs   []sdk.Msg
}

type ProposalRValidatorUpdateReport added in v0.2.0

type ProposalRValidatorUpdateReport struct {
	Denom        string
	PoolAddress  string
	CycleVersion uint64
	CycleNumber  uint64
	Status       stafiHubXRValidatorTypes.UpdateRValidatorStatus
}

type ProposalSetChainEra

type ProposalSetChainEra struct {
	Denom string
	Era   uint32
}

type ProposalTransferReport

type ProposalTransferReport struct {
	Denom  string
	ShotId string
}

type ProposalWithdrawReport

type ProposalWithdrawReport struct {
	Denom  string
	ShotId string
}

type RSymbol

type RSymbol string

type Reason

type Reason string

type Router

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

Router forwards messages from their source to their destination

func NewRouter

func NewRouter(log log.Logger) *Router

func (*Router) Listen

func (r *Router) Listen(symbol RSymbol, w Handler)

Listen registers a Writer with a ChainId which Router.Send can then use to propagate messages

func (*Router) Send

func (r *Router) Send(msg *Message) error

Send passes a message to the destination Writer if it exists

func (*Router) StopMsgHandler

func (r *Router) StopMsgHandler()

Jump to

Keyboard shortcuts

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