core

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2022 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")
	ReasonBondReport       = Reason("BondReport")
	ReasonActiveReport     = Reason("ActiveReport")
	ReasonWithdrawReport   = Reason("WithdrawReport")
	ReasonTransferReport   = Reason("TransferReport")
	ReasonSubmitSignature  = Reason("SubmitSignature")

	ReasonCurrentChainEra  = Reason("CurrentChainEra")
	ReasonBondedPools      = Reason("BondedPools")
	ReasonNewMultisig      = Reason("AsMulti")
	ReasonMultisigExecuted = Reason("MultisigExecuted")
	ReasonGetEraNominated  = Reason("GetEraNominated")

	//send when got event from stafi chain
	ReasonLiquidityBondEvent = Reason("LiquidityBondEvent")

	//send when got event from stafi/stafihub chain
	ReasonEraPoolUpdatedEvent    = Reason("EraPoolUpdatedEvent")
	ReasonBondReportedEvent      = Reason("BondReportedEvent")
	ReasonActiveReportedEvent    = Reason("ActiveReportedEvent")
	ReasonWithdrawReportedEvent  = Reason("WithdrawReportedEvent")
	ReasonTransferReportedEvent  = Reason("TransferReportedEvent")
	ReasonNominationUpdatedEvent = Reason("NominationUpdatedEvent")
	ReasonSignatureEnoughEvent   = Reason("SignatureEnoughed")
	ReasonValidatorUpdatedEvent  = Reason("ValidatorUpdatedEvent")
	ReasonRParamsChangedEvent    = Reason("RParamsChangedEvent")

	//get reason
	ReasonGetPools      = Reason("GetPools")
	ReasonGetSignatures = Reason("GetSignatures")
	ReasonGetBondRecord = Reason("GetBondRecord")
)
View Source
const (
	//stafi chain
	RFIS   = RSymbol("RFIS")
	RDOT   = RSymbol("RDOT")
	RKSM   = RSymbol("RKSM")
	RATOM  = RSymbol("RATOM")
	RSOL   = RSymbol("RSOL")
	RMATIC = RSymbol("RMATIC")
	RBNB   = RSymbol("RBNB")
)
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 EventRParamsChanged

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

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

func (*RSymbol) Decode

func (r *RSymbol) Decode(decoder scale.Decoder) error

func (RSymbol) Encode

func (r RSymbol) Encode(encoder scale.Encoder) error

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