cnode

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 66 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Enum of policy allowed.
	AllowTcbOpenChannel      = 1 << iota
	AllowStandardOpenChannel = 1 << iota
)

Variables

This section is empty.

Functions

func RecycleInstantiatedTcbDepositTx

func RecycleInstantiatedTcbDepositTx(tx *storage.DALTx, args ...interface{}) error

func RequestStandardDeposit

func RequestStandardDeposit(
	currentBlock uint64, myAddr ctype.Addr,
	initializer *entity.PaymentChannelInitializer, ospToOsp bool,
	ocem *pem.OpenChannelEventMessage) (int, error)

func RequestTcbDeposit

func RequestTcbDeposit(dal *storage.DAL, nodeConfig common.GlobalNodeConfig, initializer *entity.PaymentChannelInitializer) (int, error)

Types

type CNode

type CNode struct {
	EthAddress ctype.Addr // ETH address of the node

	// OSP server ETH address (for convenience)
	ServerAddr ctype.Addr

	Disputer *dispute.Processor

	AppClient *app.AppClient
	// contains filtered or unexported fields
}

func NewCNode

func NewCNode(
	masterTxConfig *eth.TransactorConfig,
	depositTxConfig *eth.TransactorConfig,
	transactorConfigs []*eth.TransactorConfig,
	profile common.CProfile,
	routingPolicy route.RoutingPolicy,
	routingData []byte) (*CNode, error)

func NewCNodeWithExternalSigner

func NewCNodeWithExternalSigner(
	address ctype.Addr,
	signer eth.Signer,
	profile common.CProfile) (*CNode, error)

NewCNodeWithExternalSigner is only used by client

func (*CNode) AddBooleanPay

func (c *CNode) AddBooleanPay(newPay *entity.ConditionalPay, note *anypb.Any, dstNetId uint64) (ctype.PayIDType, error)

Similar to EstablishCondPayOnToken. This will add hash lock condition to pay condition and set time stamp.

func (*CNode) AddCelerStream

func (c *CNode) AddCelerStream(celerMsg *rpc.CelerMsg, stream rpc.CelerStream) (context.Context, error)

AddCelerStream is called on server side after authReq passed add the stream to connection manager.

func (*CNode) BcastRoutingInfo

func (c *CNode) BcastRoutingInfo(req *rpc.RoutingRequest, osps []string)

An OSP server sends out the message to its peer OSPs.

func (*CNode) BuildRoutingTable

func (c *CNode) BuildRoutingTable(token ctype.Addr) (map[ctype.Addr]ctype.CidType, error)

func (*CNode) ClearPaymentsInChannel

func (c *CNode) ClearPaymentsInChannel(cid ctype.CidType) error

ClearPaymentsInChannel confirm onchain resolved pays and clear expired pays in the channel. For efficieny, only expired pays are checked for possible on-chain resolvement. This function will replace SettleExpiredPays and ConfirmOnChainResolvedPays in the future.

func (*CNode) ClearPaymentsWithPeerOsps

func (c *CNode) ClearPaymentsWithPeerOsps() error

func (*CNode) Close

func (c *CNode) Close()

func (*CNode) ConfirmBooleanPay

func (c *CNode) ConfirmBooleanPay(payID ctype.PayIDType) error

func (*CNode) ConfirmOnChainResolvedPays

func (c *CNode) ConfirmOnChainResolvedPays(cid ctype.CidType) error

func (*CNode) ConfirmSettlePaymentChannel

func (c *CNode) ConfirmSettlePaymentChannel(cid ctype.CidType) error

func (*CNode) ConfirmWithdraw

func (c *CNode) ConfirmWithdraw(cid ctype.CidType) error

func (*CNode) CooperativeWithdraw

func (c *CNode) CooperativeWithdraw(cid ctype.CidType, amount *big.Int, callback cooperativewithdraw.Callback) (string, error)

func (*CNode) DepositWithCallback

func (c *CNode) DepositWithCallback(amt *big.Int, cid ctype.CidType, cb deposit.DepositCallback) (string, error)

func (*CNode) ForwardMsgToPeer

func (c *CNode) ForwardMsgToPeer(req *rpc.FwdReq) error

func (*CNode) GetBalance

func (c *CNode) GetBalance(cid ctype.CidType) (*common.ChannelBalance, error)

func (*CNode) GetChannelIdForPeer

func (c *CNode) GetChannelIdForPeer(peer, tokenAddr ctype.Addr) (ctype.CidType, error)

func (*CNode) GetConnManager

func (c *CNode) GetConnManager() *rpc.ConnectionManager

func (*CNode) GetConnectedOsps

func (c *CNode) GetConnectedOsps() map[ctype.Addr]bool

func (*CNode) GetCurrentBlockNumber

func (c *CNode) GetCurrentBlockNumber() *big.Int

func (*CNode) GetDAL

func (c *CNode) GetDAL() *storage.DAL

func (*CNode) GetJoinStatusForNode

func (c *CNode) GetJoinStatusForNode(dst, tokenAddr ctype.Addr) rpc.JoinCelerStatus

GetJoinStatusForNode gets the join status of an endpoint CAVEAT: Note that this will break if we decide to set a default route so that LookupNextChannelOnToken always returns a nextHop for any query. TODO: May not rely on LookupNextChannelOnToken in the future(yilun)

func (*CNode) GetKVStore

func (c *CNode) GetKVStore() storage.KVStore

func (*CNode) GetPaymentState

func (c *CNode) GetPaymentState(payID ctype.PayIDType) (int, int)

GetPaymentState returns the ingress and egress state of a payment

func (*CNode) GetPeerOsps

func (c *CNode) GetPeerOsps() map[ctype.Addr]*route.NeighborInfo

func (*CNode) GetRPCAddr

func (c *CNode) GetRPCAddr() string

Return the server's internal RPC address.

func (*CNode) GetSettleFinalizedTime

func (c *CNode) GetSettleFinalizedTime(cid ctype.CidType) (*big.Int, error)

func (*CNode) GetSgnGuardRequest

func (c *CNode) GetSgnGuardRequest(cid ctype.CidType) (*SgnRequest, error)

func (*CNode) GetSgnSubscription

func (c *CNode) GetSgnSubscription() (*SgnSubscription, error)

func (*CNode) HandleAuthAck

func (c *CNode) HandleAuthAck(peer ctype.Addr, ack *rpc.AuthAck)

HandleAuthAck tries to update db based on sync info in AuthAck msg NOTE this func doesn't return error as it's best effort to sync state some code are similar to open_channel logic but couldn't re-use due to openchan assumes init state

func (*CNode) HandleAuthReq

func (c *CNode) HandleAuthReq(req *rpc.AuthReq) (*rpc.CelerMsg, error)

HandleAuthReq verifies AuthReq and return msg to send back or error if error is nil, guarantee *rpc.CelerMsg isn't nil

func (*CNode) InstantiateChannel

func (c *CNode) InstantiateChannel(cid ctype.CidType, openCallback event.OpenChannelCallback) error

func (*CNode) IntendSettlePaymentChannel

func (c *CNode) IntendSettlePaymentChannel(cid ctype.CidType) error

func (*CNode) IntendWithdraw

func (c *CNode) IntendWithdraw(cidFrom ctype.CidType, amount *big.Int, cidTo ctype.CidType) error

func (*CNode) IsLocalPeer

func (c *CNode) IsLocalPeer(client ctype.Addr) bool

Is the destination client locally connected on this server?

func (*CNode) MonitorCooperativeWithdrawJob

func (c *CNode) MonitorCooperativeWithdrawJob(
	withdrawHash string,
	callback cooperativewithdraw.Callback)

func (*CNode) MonitorDepositJobWithCallback

func (c *CNode) MonitorDepositJobWithCallback(jobID string, cb deposit.DepositCallback)

func (*CNode) NumClients

func (c *CNode) NumClients() int

Return the number of clients locally connected on this server?

func (*CNode) OnNewStream

func (c *CNode) OnNewStream(callback event.OnNewStreamCallback)

func (*CNode) OnReceivingToken

func (c *CNode) OnReceivingToken(callback event.OnReceivingTokenCallback)

func (*CNode) OnSendToken

func (c *CNode) OnSendToken(sendCallback event.OnSendingTokenCallback)

func (*CNode) OpenChannel

func (c *CNode) OpenChannel(
	peer ctype.Addr,
	amtSelf *big.Int,
	amtPeer *big.Int,
	tokenInfo *entity.TokenInfo,
	ospToOspOpen bool,
	openCallback event.OpenChannelCallback) error

func (*CNode) ProcessMigrateChannelRequest

func (c *CNode) ProcessMigrateChannelRequest(in *rpc.MigrateChannelRequest) (*rpc.MigrateChannelResponse, error)

ProcessMigrateChannelRequest handles channel migration request

func (*CNode) ProcessOpenChannelRequest

func (c *CNode) ProcessOpenChannelRequest(in *rpc.OpenChannelRequest) (*rpc.OpenChannelResponse, error)

func (*CNode) ProcessTcbRequest

func (c *CNode) ProcessTcbRequest(in *rpc.OpenChannelRequest) (*rpc.OpenChannelResponse, error)

func (*CNode) QueryDeposit

func (c *CNode) QueryDeposit(depositID string) (int, string, error)

func (*CNode) RecvBcastRoutingInfo

func (c *CNode) RecvBcastRoutingInfo(in *rpc.RoutingRequest) error

func (*CNode) RegisterStream

func (c *CNode) RegisterStream(peerAddr ctype.Addr, peerHTTPTarget string) error

WARNING: msg drop interceptor only supports single stream, and should only be used in testing

func (*CNode) RegisterStreamErrCallback

func (c *CNode) RegisterStreamErrCallback(peerAddr ctype.Addr, callback rpc.ErrCallbackFunc)

func (*CNode) RejectBooleanPay

func (c *CNode) RejectBooleanPay(payID ctype.PayIDType) error

func (*CNode) RemoveCooperativeWithdrawJob

func (c *CNode) RemoveCooperativeWithdrawJob(withdrawHash string)

func (*CNode) RemoveDepositJob

func (c *CNode) RemoveDepositJob(jobID string) error

func (*CNode) RequestDeposit

func (c *CNode) RequestDeposit(
	peerAddr ctype.Addr, tokenAddr ctype.Addr, toPeer bool, amount *big.Int, maxWait time.Duration) (string, error)

func (*CNode) RequestSgnGuardState

func (c *CNode) RequestSgnGuardState(cid ctype.CidType) error

func (*CNode) SetDelegation

func (c *CNode) SetDelegation(tokens []ctype.Addr, timeout int64) error

func (*CNode) SetMsgDropper

func (c *CNode) SetMsgDropper(dropRecv, dropSend bool)

func (*CNode) SettleExpiredPays

func (c *CNode) SettleExpiredPays(cid ctype.CidType) error

func (*CNode) SettleOnChainResolvedPay

func (c *CNode) SettleOnChainResolvedPay(payID ctype.PayIDType) error

func (*CNode) SignState

func (c *CNode) SignState(in []byte) []byte

SignState signs the data using cnode crypto and return result

func (*CNode) SyncOnChainChannelStates

func (c *CNode) SyncOnChainChannelStates(cid ctype.CidType) (int, error)

func (*CNode) TcbOpenChannel

func (c *CNode) TcbOpenChannel(
	peer ctype.Addr,
	amtPeer *big.Int,
	tokenInfo *entity.TokenInfo,
	openCallback event.OpenChannelCallback) error

func (*CNode) VetoWithdraw

func (c *CNode) VetoWithdraw(cid ctype.CidType) error

type SgnRequest

type SgnRequest struct {
	ChannelId               []byte `json:"channel_id"`
	SeqNum                  uint64 `json:"seq_num"`
	SimplexSender           string `json:"simplex_sender"`
	SimplexReceiver         string `json:"simplex_receiver"`
	SignedSimplexStateBytes []byte `json:"signed_simplex_state_bytes"`
	DisputeTimeout          uint64 `json:"dispute_timeout"`
	TriggerTxHash           string `json:"trigger_tx_hash"`
	TriggerTxBlkNum         uint64 `json:"trigger_tx_blk_num"`
	GuardTxHash             string `json:"guard_tx_hash"`
	GuardTxBlkNum           uint64 `json:"guard_tx_blk_num"`
	GuardSender             string `json:"guard_sender"`
}

type SgnResponseWithHeight

type SgnResponseWithHeight struct {
	Height int64           `json:"height"`
	Result json.RawMessage `json:"result"`
}

type SgnSubscription

type SgnSubscription struct {
	EthAddress string  `json:"eth_address"`
	Deposit    big.Int `json:"deposit"`
	Spend      big.Int `json:"spend"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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