common

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidMsgType              = errors.New("invalid message type")
	ErrPendingSimplex              = errors.New("previous send is still pending")
	ErrInvalidArg                  = errors.New("invalid arguments")
	ErrUnknownTokenType            = errors.New("unknown token type")
	ErrDeadlinePassed              = errors.New("deadline already passed")
	ErrZeroConditions              = errors.New("condpay has no conditions")
	ErrNoChannel                   = errors.New("no available channel")
	ErrPayNotFound                 = errors.New("payment not found")
	ErrPayNoIngress                = errors.New("payment does not have ingress state")
	ErrPayNoEgress                 = errors.New("payment does not have egress state")
	ErrPayDestMismatch             = errors.New("pay dest and self mismatch")
	ErrPaySrcMismatch              = errors.New("pay src and self mismatch")
	ErrSimplexParse                = errors.New("cannot parse simplex state")
	ErrRateLimited                 = errors.New("rate limited, please try again later")
	ErrInvalidSig                  = errors.New("invalid signature")
	ErrInvalidSeqNum               = errors.New("invalid sequence number")
	ErrInvalidPendingPays          = errors.New("invalid pending pay list")
	ErrInvalidTokenAddress         = errors.New("invalid token address")
	ErrInvalidAccountAddress       = errors.New("invalid account address")
	ErrInvalidAmount               = errors.New("invalid amount")
	ErrInsufficentDepositCapacity  = errors.New("insufficient deposit capacity")
	ErrChannelDescriptorNotInclude = errors.New("my address not included in the channel descriptor")
	ErrOpenEventOnWrongState       = errors.New("open event on wrong state")
	ErrUnparsable                  = errors.New("unparsable")
	ErrInvalidChannelID            = errors.New("channel ID mismatch")
	ErrInvalidChannelPeerFrom      = errors.New("channel peerFrom mismatch")
	ErrInvalidTransferAmt          = errors.New("invalid transfer amount")
	ErrInvalidPendingAmt           = errors.New("invalid total pending amount")
	ErrInvalidPayDeadline          = errors.New("invalid pay resolve deadline")
	ErrInvalidLastPayDeadline      = errors.New("invalid last pay resolve deadline")
	ErrInvalidSettleReason         = errors.New("invalid payment settle reason")
	ErrTooManyPendingPays          = errors.New("too many pending payments")
	ErrNoEnoughBalance             = errors.New("balance not enough")
	ErrInvalidPayResolver          = errors.New("invalid pay resolver address")
	ErrSecretNotRevealed           = errors.New("hash lock secret not revealed")
	ErrEgressPayNotCanceled        = errors.New("egress payment not canceled")
	ErrEgressPayPaid               = errors.New("egress payment already paid")
	ErrPayOnChainResolved          = errors.New("pay already onchain resolved")
	ErrPayOffChainResolved         = errors.New("pay already offchain resolved")
	ErrPayAlreadyPending           = errors.New("pay already exists in pending pay list")
	ErrPayRouteLoop                = errors.New("pay route loop")
	ErrInvalidPaySrc               = errors.New("invalid pay source")
	ErrInvalidPayDst               = errors.New("invalid pay destination")
	ErrRouteNotFound               = errors.New("no route to destination")
	ErrPeerNotOnline               = errors.New("peer not online")
	ErrPeerNotFound                = errors.New("no peer found")
	ErrSimplexStateNotFound        = errors.New("channel simplex state not found")
	ErrChannelNotFound             = errors.New("channel not found")
	ErrInvalidChannelState         = errors.New("invalid channel state")
	ErrNoCelerStream               = errors.New("no celer stream")
	ErrStreamAleadyExists          = errors.New("celer stream already exists")
	ErrCelerMsgTimeout             = errors.New("celer message send timeout")
	ErrDelegateProofNotFound       = errors.New("delegate proof not found")
	ErrTcbNotFound                 = errors.New("tcb entry not found")
	ErrRecvCelerMsgTimeout         = errors.New("timeout waiting to recv celer msg")
	ErrLeaseAcquired               = errors.New("lease acquired by others")
	ErrPendingRefill               = errors.New("pending channel refill job")
	ErrDepositNotFound             = errors.New("deposit job not found")
)

err constants for various errors

Functions

This section is empty.

Types

type CProfile

type CProfile struct {
	ETHInstance        string            `json:"ethInstance"`
	SvrETHAddr         string            `json:"svrEthAddr"`
	WalletAddr         string            `json:"walletAddr"`
	LedgerAddr         string            `json:"ledgerAddr"`
	VirtResolverAddr   string            `json:"virtResolverAddr"`
	EthPoolAddr        string            `json:"ethPoolAddr"`
	PayResolverAddr    string            `json:"payResolverAddr"`
	PayRegistryAddr    string            `json:"payRegistryAddr"`
	RouterRegistryAddr string            `json:"routerRegistryAddr"`
	SvrRPC             string            `json:"svrRpc"`
	SvrName            string            `json:"svrName,omitempty"`
	SelfRPC            string            `json:"selfRpc,omitempty"`
	StoreDir           string            `json:"storeDir,omitempty"`
	StoreSql           string            `json:"storeSql,omitempty"`
	WsOrigin           string            `json:"wsOrigin,omitempty"`
	ChainId            int64             `json:"chainId"`
	BlockDelayNum      uint64            `json:"blockDelayNum"`
	IsOSP              bool              `json:"isOsp,omitempty"`
	ListenOnChain      bool              `json:"listenOnChain,omitempty"`
	PollingInterval    uint64            `json:"pollingInterval"`
	DisputeTimeout     uint64            `json:"disputeTimeout"`
	Ledgers            map[string]string `json:"ledgers"`
	ExplorerUrl        string            `json:"explorerUrl,omitempty"`
	CheckInterval      map[string]uint64 `json:"checkInterval,omitempty"`
	SgnGateway         string            `json:"sgnGateway"`
	SgnContractAddr    string            `json:"sgnAddr"`
}

CProfile contains configurations for CelerClient/OSP

func Bytes2Profile

func Bytes2Profile(data []byte) *CProfile

Bytes2Profile does json.Unmarshal and return CProfile

func ParseProfile

func ParseProfile(path string) *CProfile

ParseProfile parses file content at path and returns CProfile supports both old and new schema

type ChannelBalance

type ChannelBalance struct {
	MyAddr     ctype.Addr
	MyFree     *big.Int
	MyLocked   *big.Int
	PeerAddr   ctype.Addr
	PeerFree   *big.Int
	PeerLocked *big.Int
}

type ChannelSeqNums

type ChannelSeqNums struct {
	Base       uint64
	LastUsed   uint64
	LastAcked  uint64
	LastNacked uint64
}

type E

type E struct {
	Reason string
	Code   int
}

type GlobalNodeConfig

type GlobalNodeConfig interface {
	GetOnChainAddr() ctype.Addr
	GetEthPoolAddr() ctype.Addr
	GetEthConn() *ethclient.Client
	GetRPCAddr() string
	GetSvrName() string
	GetWalletContract() chain.Contract
	// GetLedgerContract returns latest ledger contract.
	GetLedgerContract() chain.Contract
	// GetLedgerContractOn returns ledger contract on addr. The addr must exist in profile ledger address map.
	// It will return nil otherwise.
	GetLedgerContractOn(ctype.Addr) chain.Contract
	// GetAllLedgerContracts returns a map with key being ledger addresses in profile and ledger contract bound to to the address.
	GetAllLedgerContracts() map[ctype.Addr]chain.Contract
	// GetLedgerContractOf returns ledger contract object of which address is used by the cid.
	GetLedgerContractOf(ctype.CidType) chain.Contract
	GetVirtResolverContract() chain.Contract
	GetPayResolverContract() chain.Contract
	GetPayRegistryContract() chain.Contract
	GetRouterRegistryContract() chain.Contract
	GetCheckInterval(string) uint64
}

type MsgFrame

type MsgFrame struct {
	Message  *rpc.CelerMsg
	PeerAddr ctype.Addr
	LogEntry *pem.PayEventMessage
}

type ProfileContracts

type ProfileContracts struct {
	Wallet, Ledger, VirtResolver, EthPool, PayResolver, PayRegistry, RouterRegistry string
	Ledgers                                                                         map[string]string
}

type ProfileEthereum

type ProfileEthereum struct {
	Gateway                                                  string
	ChainId, BlockIntervalSec, BlockDelayNum, DisputeTimeout uint64
	Contracts                                                ProfileContracts
	// CheckInterval is map of eventname to its check interval for monitor service
	// if not set (ie. 0) will check every blockIntervalSec (ie. same as check new block head)
	// if specify, key must be one of event.go const string values
	// monitor will check every checkInterval * blockIntervalSec
	CheckInterval map[string]uint64
}

type ProfileJSON

type ProfileJSON struct {
	// schema version, ignored for now but will be useful
	// when need to handle incompatible schema in the future
	Version  string
	Ethereum ProfileEthereum
	Osp      ProfileOsp
	Sgn      ProfileSgn
}

ProfileJSON handles new profile json schema

func ParseProfileJSON

func ParseProfileJSON(path string) *ProfileJSON

func (*ProfileJSON) ToCProfile

func (pj *ProfileJSON) ToCProfile() *CProfile

type ProfileOsp

type ProfileOsp struct {
	Host, Address, ExplorerUrl string
}

type ProfileSgn

type ProfileSgn struct {
	Gateway         string
	SgnContractAddr string
}

type StateCallback

type StateCallback interface {
	OnDispute(seqNum int)
}

type StreamWriter

type StreamWriter interface {
	WriteCelerMsg(peer ctype.Addr, celerMsg *rpc.CelerMsg) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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