Documentation
¶
Index ¶
- Variables
- func Channel2RouteState(c *channel.Channel, partenerAddress common.Address, amount *big.Int, ...) *route.State
- func MakeExclude(addrs ...common.Address) map[common.Address]bool
- type ChannelGraph
- func (cg *ChannelGraph) AddChannel(ch *channel.Channel) error
- func (cg *ChannelGraph) AddPath(source, target common.Address)
- func (cg *ChannelGraph) AllNodes() (nodes []common.Address)
- func (cg *ChannelGraph) ChannelCanTransfer(partenerAddress common.Address) bool
- func (cg *ChannelGraph) GetBestRoutes(nodesStatus NodesStatusGetter, ourAddress common.Address, ...) (onlineNodes []*route.State)
- func (cg *ChannelGraph) GetPartenerAddress2Channel(address common.Address) (c *channel.Channel)
- func (cg *ChannelGraph) HasChannel(source, target common.Address) bool
- func (cg *ChannelGraph) RemoveChannel(ch *channel.Channel)
- func (cg *ChannelGraph) RemovePath(source, target common.Address)
- func (cg *ChannelGraph) ShortestPath(source, target common.Address, amount *big.Int, feeCharger fee.Charger) (totalWeight int64, err error)
- type NodesStatusGetter
Constants ¶
This section is empty.
Variables ¶
var EmptyExlude map[common.Address]bool
EmptyExlude 为了调用 GetBestRoutes 方便一点 EmptyExclude : to make GetBestRoutes easy to invoke.
Functions ¶
Types ¶
type ChannelGraph ¶
type ChannelGraph struct { OurAddress common.Address TokenAddress common.Address PartenerAddress2Channel map[common.Address]*channel.Channel ChannelIdentifier2Channel map[common.Hash]*channel.Channel // contains filtered or unexported fields }
ChannelGraph is a Graph based on the channels and can find path between participants. 整个 ChannelGraph 只能单线程访问 The whole ChannelGraph can only be accessed by a single process.
func NewChannelGraph ¶
func NewChannelGraph(ourAddress, tokenAddress common.Address, edges []common.Address) *ChannelGraph
NewChannelGraph create ChannelGraph,one token one channelGraph
func (*ChannelGraph) AddChannel ¶
func (cg *ChannelGraph) AddChannel(ch *channel.Channel) error
AddChannel Instantiate a channel this node participates and add to the graph.
If the channel is already registered do nothing.
func (*ChannelGraph) AddPath ¶
func (cg *ChannelGraph) AddPath(source, target common.Address)
AddPath Add a new edge into the network.
func (*ChannelGraph) AllNodes ¶
func (cg *ChannelGraph) AllNodes() (nodes []common.Address)
AllNodes returns all neighbor nodes
func (*ChannelGraph) ChannelCanTransfer ¶
func (cg *ChannelGraph) ChannelCanTransfer(partenerAddress common.Address) bool
ChannelCanTransfer returns True if the channel with `partner_address` is open and has spendable funds. """
TODO: check if the partner's network is alive
func (*ChannelGraph) GetBestRoutes ¶
func (cg *ChannelGraph) GetBestRoutes(nodesStatus NodesStatusGetter, ourAddress common.Address, targetAdress common.Address, amount *big.Int, targetAmount *big.Int, excludeAddresses map[common.Address]bool, feeCharger fee.Charger) (onlineNodes []*route.State)
GetBestRoutes returns all neighbor nodes order by weight from it to target. 我们现在的路由算法应该是有历史记忆的最短路径/最小费用算法. 跳过所有已经走过的路径.
- GetBestRoutes :function to return all neighbor nodes order by weight from it to target. *
- Note that the routing algorithm we currently use should be the shortest-path/minimized-fee algorithm with history record,
- which circumvents all routes that have been iterated.
func (*ChannelGraph) GetPartenerAddress2Channel ¶
func (cg *ChannelGraph) GetPartenerAddress2Channel(address common.Address) (c *channel.Channel)
GetPartenerAddress2Channel returns a channel between me and address
func (*ChannelGraph) HasChannel ¶
func (cg *ChannelGraph) HasChannel(source, target common.Address) bool
HasChannel return True if there is a connecting path regardless of the number of hops.
func (*ChannelGraph) RemoveChannel ¶
func (cg *ChannelGraph) RemoveChannel(ch *channel.Channel)
RemoveChannel remove a channel from graph,and i'm a participant of this channel
func (*ChannelGraph) RemovePath ¶
func (cg *ChannelGraph) RemovePath(source, target common.Address)
RemovePath Remove an edge from the network. this edge may not exist