common

package
v0.0.0-...-ab58f20 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2020 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EthContractAddr = "0000000000000000000000000000000000000000"
)
View Source
const (
	PendingSpPrefix = "pendingSp:"
)
View Source
const RoutingTableDestTokenSpliter = "@"

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 0 conds")
	ErrNoChannel                   = errors.New("no available channel")
	ErrPayNotFound                 = errors.New("payment not found")
	ErrPayStateNotFound            = errors.New("payment state not found")
	ErrPayDestMismatch             = errors.New("pay dest and self mismatch")
	ErrPaySrcMismatch              = errors.New("pay src and self mismatch")
	ErrSimplexParse                = errors.New("cannot parse simplex from storage")
	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")
	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")
	ErrPeerNotFound                = errors.New("no peer found for the given cid")
	ErrSimplexStateNotFound        = errors.New("channel simplex state 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"`
	SelfRPC            string `json:"selfRpc,omitempty"`
	StoreDir           string `json:"storeDir,omitempty"`
	StoreSql           string `json:"storeSql,omitempty"`
	WebPort            string `json:"webPort,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"`
}

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     string
	MyFree     *big.Int
	MyLocked   *big.Int
	PeerAddr   string
	PeerFree   *big.Int
	PeerLocked *big.Int
}

type ChannelSeqNums

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

type Crypto

type Crypto interface {
	Signer
	SigValidator
}

type E

type E struct {
	Reason string
	Code   int
}

type GlobalNodeConfig

type GlobalNodeConfig interface {
	GetOnChainAddr() string
	GetOnChainAddrBytes() []byte
	GetEthPoolAddr() ctype.Addr
	GetEthConn() *ethclient.Client
	GetRPCAddr() string
	GetWalletContract() chain.Contract
	GetLedgerContract() chain.Contract
	GetVirtResolverContract() chain.Contract
	GetPayResolverContract() chain.Contract
	GetPayRegistryContract() chain.Contract
	GetRouterRegistryContract() chain.Contract
}

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
}

type ProfileEthereum

type ProfileEthereum struct {
	Gateway                                  string
	ChainId, BlockIntervalSec, BlockDelayNum uint64
	Contracts                                ProfileContracts
}

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
}

ProfileJSON handles new profile json schema

func (*ProfileJSON) ToCProfile

func (pj *ProfileJSON) ToCProfile() *CProfile

type ProfileOsp

type ProfileOsp struct {
	Host, Address string
}

type RoutingPolicy

type RoutingPolicy int
const (
	NoRoutingPolicy       RoutingPolicy = 1 << iota
	GateWayPolicy         RoutingPolicy = 1 << iota
	ServiceProviderPolicy RoutingPolicy = 1 << iota
)

type SigValidator

type SigValidator interface {
	SigIsValid(signer string, data []byte, sig []byte) bool
}

type Signer

type Signer interface {
	Sign(data []byte) ([]byte, error)
}

type StateCallback

type StateCallback interface {
	OnDispute(seqNum int)
}

type StateChannelRouter

type StateChannelRouter interface {
	// Return Channel ID and peer
	LookupNextChannelOnToken(dst string, tokenAddr string) (ctype.CidType, string, error)
	LookupIngressChannelOnPay(payID ctype.PayIDType) (ctype.CidType, string, error)
	LookupEgressChannelOnPay(payID ctype.PayIDType) (ctype.CidType, string, error)
	// deprecated
	LookupNextChannel(dst string) (ctype.CidType, error)
}

type StreamWriter

type StreamWriter interface {
	WriteCelerMsg(peer string, 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