Documentation
¶
Index ¶
- Constants
- func RecycleInstantiatedTcbDepositTx(tx *storage.DALTx, args ...interface{}) error
- func RequestStandardDeposit(nowTs uint64, myAddr ctype.Addr, initializer *entity.PaymentChannelInitializer, ...) (int, error)
- func RequestTcbDeposit(dal *storage.DAL, nodeConfig common.GlobalNodeConfig, ...) (int, error)
- type CNode
- func (c *CNode) AddBooleanPay(newPay *entity.ConditionalPay, note *anypb.Any, dstNetId uint64) (ctype.PayIDType, error)
- func (c *CNode) AddCelerStream(celerMsg *rpc.CelerMsg, stream rpc.CelerStream) (context.Context, error)
- func (c *CNode) BcastRoutingInfo(req *rpc.RoutingRequest, osps []string)
- func (c *CNode) BuildRoutingTable(token ctype.Addr) (map[ctype.Addr]ctype.CidType, error)
- func (c *CNode) ClearPaymentsInChannel(cid ctype.CidType) error
- func (c *CNode) ClearPaymentsWithPeerOsps() error
- func (c *CNode) Close()
- func (c *CNode) ConfirmBooleanPay(payID ctype.PayIDType) error
- func (c *CNode) ConfirmOnChainResolvedPays(cid ctype.CidType) error
- func (c *CNode) ConfirmSettlePaymentChannel(cid ctype.CidType) error
- func (c *CNode) ConfirmWithdraw(cid ctype.CidType) error
- func (c *CNode) CooperativeWithdraw(cid ctype.CidType, amount *big.Int, callback cooperativewithdraw.Callback) (string, error)
- func (c *CNode) DepositWithCallback(amt *big.Int, cid ctype.CidType, cb deposit.DepositCallback) (string, error)
- func (c *CNode) ForwardMsgToPeer(req *rpc.FwdReq) error
- func (c *CNode) GetBalance(cid ctype.CidType) (*common.ChannelBalance, error)
- func (c *CNode) GetChannelIdForPeer(peer, tokenAddr ctype.Addr) (ctype.CidType, error)
- func (c *CNode) GetConnManager() *rpc.ConnectionManager
- func (c *CNode) GetConnectedOsps() map[ctype.Addr]bool
- func (c *CNode) GetCurrentBlockNumber() *big.Int
- func (c *CNode) GetDAL() *storage.DAL
- func (c *CNode) GetJoinStatusForNode(dst, tokenAddr ctype.Addr) rpc.JoinCelerStatus
- func (c *CNode) GetKVStore() storage.KVStore
- func (c *CNode) GetPaymentState(payID ctype.PayIDType) (int, int)
- func (c *CNode) GetPeerOsps() map[ctype.Addr]*route.NeighborInfo
- func (c *CNode) GetRPCAddr() string
- func (c *CNode) GetSettleFinalizedTime(cid ctype.CidType) (*big.Int, error)
- func (c *CNode) GetSgnGuardRequest(cid ctype.CidType) (*SgnRequest, error)
- func (c *CNode) GetSgnSubscription() (*SgnSubscription, error)
- func (c *CNode) HandleAuthAck(peer ctype.Addr, ack *rpc.AuthAck)
- func (c *CNode) HandleAuthReq(req *rpc.AuthReq) (*rpc.CelerMsg, error)
- func (c *CNode) InstantiateChannel(cid ctype.CidType, openCallback event.OpenChannelCallback) error
- func (c *CNode) IntendSettlePaymentChannel(cid ctype.CidType) error
- func (c *CNode) IntendWithdraw(cidFrom ctype.CidType, amount *big.Int, cidTo ctype.CidType) error
- func (c *CNode) IsLocalPeer(client ctype.Addr) bool
- func (c *CNode) MonitorCooperativeWithdrawJob(withdrawHash string, callback cooperativewithdraw.Callback)
- func (c *CNode) MonitorDepositJobWithCallback(jobID string, cb deposit.DepositCallback)
- func (c *CNode) NumClients() int
- func (c *CNode) OnNewStream(callback event.OnNewStreamCallback)
- func (c *CNode) OnReceivingToken(callback event.OnReceivingTokenCallback)
- func (c *CNode) OnSendToken(sendCallback event.OnSendingTokenCallback)
- func (c *CNode) OpenChannel(peer ctype.Addr, amtSelf *big.Int, amtPeer *big.Int, ...) error
- func (c *CNode) ProcessMigrateChannelRequest(in *rpc.MigrateChannelRequest) (*rpc.MigrateChannelResponse, error)
- func (c *CNode) ProcessOpenChannelRequest(in *rpc.OpenChannelRequest) (*rpc.OpenChannelResponse, error)
- func (c *CNode) ProcessTcbRequest(in *rpc.OpenChannelRequest) (*rpc.OpenChannelResponse, error)
- func (c *CNode) QueryDeposit(depositID string) (int, string, error)
- func (c *CNode) RecvBcastRoutingInfo(in *rpc.RoutingRequest) error
- func (c *CNode) RegisterStream(peerAddr ctype.Addr, peerHTTPTarget string) error
- func (c *CNode) RegisterStreamErrCallback(peerAddr ctype.Addr, callback rpc.ErrCallbackFunc)
- func (c *CNode) RejectBooleanPay(payID ctype.PayIDType) error
- func (c *CNode) RemoveCooperativeWithdrawJob(withdrawHash string)
- func (c *CNode) RemoveDepositJob(jobID string) error
- func (c *CNode) RequestDeposit(peerAddr ctype.Addr, tokenAddr ctype.Addr, toPeer bool, amount *big.Int, ...) (string, error)
- func (c *CNode) RequestSgnGuardState(cid ctype.CidType) error
- func (c *CNode) SetDelegation(tokens []ctype.Addr, timeout int64) error
- func (c *CNode) SetMsgDropper(dropRecv, dropSend bool)
- func (c *CNode) SettleExpiredPays(cid ctype.CidType) error
- func (c *CNode) SettleOnChainResolvedPay(payID ctype.PayIDType) error
- func (c *CNode) SignState(in []byte) []byte
- func (c *CNode) SyncOnChainChannelStates(cid ctype.CidType) (int, error)
- func (c *CNode) TcbOpenChannel(peer ctype.Addr, amtPeer *big.Int, tokenInfo *entity.TokenInfo, ...) error
- func (c *CNode) VetoWithdraw(cid ctype.CidType) error
- type SgnRequest
- type SgnResponseWithHeight
- type SgnSubscription
Constants ¶
const ( // Enum of policy allowed. AllowTcbOpenChannel = 1 << iota AllowStandardOpenChannel = 1 << iota )
Variables ¶
This section is empty.
Functions ¶
func RequestStandardDeposit ¶
func RequestStandardDeposit( nowTs uint64, myAddr ctype.Addr, initializer *entity.PaymentChannelInitializer, ospToOsp bool, ocem *pem.OpenChannelEventMessage) (int, error)
RequestStandardDeposit checks open-channel policy. nowTs is a unix timestamp (seconds); the contract's `OpenDeadline` and rtconfig `MinDeadlineDelta` / `MaxDeadlineDelta` are also seconds in the blocktime contracts.
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 (*CNode) ClearPaymentsInChannel ¶
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 (*CNode) ConfirmOnChainResolvedPays ¶
func (*CNode) ConfirmSettlePaymentChannel ¶
func (*CNode) CooperativeWithdraw ¶
func (*CNode) DepositWithCallback ¶
func (*CNode) GetBalance ¶
func (*CNode) GetChannelIdForPeer ¶
func (*CNode) GetConnManager ¶
func (c *CNode) GetConnManager() *rpc.ConnectionManager
func (*CNode) GetCurrentBlockNumber ¶
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 (*CNode) GetPaymentState ¶
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 ¶
Return the server's internal RPC address.
func (*CNode) GetSettleFinalizedTime ¶
func (*CNode) GetSgnGuardRequest ¶
func (c *CNode) GetSgnGuardRequest(cid ctype.CidType) (*SgnRequest, error)
func (*CNode) GetSgnSubscription ¶
func (c *CNode) GetSgnSubscription() (*SgnSubscription, error)
func (*CNode) HandleAuthAck ¶
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 ¶
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 (*CNode) IntendSettlePaymentChannel ¶
func (*CNode) IntendWithdraw ¶
func (*CNode) IsLocalPeer ¶
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 ¶
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 (*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) RecvBcastRoutingInfo ¶
func (c *CNode) RecvBcastRoutingInfo(in *rpc.RoutingRequest) error
func (*CNode) RegisterStream ¶
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) RemoveCooperativeWithdrawJob ¶
func (*CNode) RemoveDepositJob ¶
func (*CNode) RequestDeposit ¶
func (*CNode) SetDelegation ¶
func (*CNode) SetMsgDropper ¶
func (*CNode) SettleOnChainResolvedPay ¶
func (*CNode) SyncOnChainChannelStates ¶
func (*CNode) TcbOpenChannel ¶
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"`
}