routing: remove unused code, nodeIndex and chanIndex

This commit is contained in:
Johan T. Halseth 2019-02-13 12:13:55 +01:00
parent b1ef153ea9
commit 1259bacd49
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26
2 changed files with 0 additions and 73 deletions

@ -154,15 +154,6 @@ type Route struct {
// Hops contains details concerning the specific forwarding details at
// each hop.
Hops []*Hop
// nodeIndex is a map that allows callers to quickly look up if a node
// is present in this computed route or not.
nodeIndex map[Vertex]struct{}
// chanIndex is an index that allows callers to determine if a channel
// is present in this route or not. Channels are identified by the
// uint64 version of the short channel ID.
chanIndex map[uint64]struct{}
}
// HopFee returns the fee charged by the route hop indicated by hopIndex.
@ -178,21 +169,6 @@ func (r *Route) HopFee(hopIndex int) lnwire.MilliSatoshi {
return incomingAmt - r.Hops[hopIndex].AmtToForward
}
// containsNode returns true if a node is present in the target route, and
// false otherwise.
func (r *Route) containsNode(v Vertex) bool {
_, ok := r.nodeIndex[v]
return ok
}
// containsChannel returns true if a channel is present in the target route,
// and false otherwise. The passed chanID should be the converted uint64 form
// of lnwire.ShortChannelID.
func (r *Route) containsChannel(chanID uint64) bool {
_, ok := r.chanIndex[chanID]
return ok
}
// ToHopPayloads converts a complete route into the series of per-hop payloads
// that is to be encoded within each HTLC using an opaque Sphinx packet.
func (r *Route) ToHopPayloads() []sphinx.HopData {
@ -365,16 +341,6 @@ func NewRouteFromHops(amtToSend lnwire.MilliSatoshi, timeLock uint32,
TotalTimeLock: timeLock,
TotalAmount: amtToSend,
TotalFees: amtToSend - hops[len(hops)-1].AmtToForward,
nodeIndex: make(map[Vertex]struct{}),
chanIndex: make(map[uint64]struct{}),
}
// Then we'll update the node and channel index, to indicate that this
// Vertex and incoming channel link are present within this route.
for _, hop := range hops {
v := Vertex(hop.PubKeyBytes)
route.nodeIndex[v] = struct{}{}
route.chanIndex[hop.ChannelID] = struct{}{}
}
return route, nil

@ -1283,45 +1283,6 @@ type routingMsg struct {
err chan error
}
// pruneNodeFromRoutes accepts set of routes, and returns a new set of routes
// with the target node filtered out.
func pruneNodeFromRoutes(routes []*Route, skipNode Vertex) []*Route {
// TODO(roasbeef): pass in slice index?
prunedRoutes := make([]*Route, 0, len(routes))
for _, route := range routes {
if route.containsNode(skipNode) {
continue
}
prunedRoutes = append(prunedRoutes, route)
}
log.Tracef("Filtered out %v routes with node %x",
len(routes)-len(prunedRoutes), skipNode[:])
return prunedRoutes
}
// pruneChannelFromRoutes accepts a set of routes, and returns a new set of
// routes with the target channel filtered out.
func pruneChannelFromRoutes(routes []*Route, skipChan uint64) []*Route {
prunedRoutes := make([]*Route, 0, len(routes))
for _, route := range routes {
if route.containsChannel(skipChan) {
continue
}
prunedRoutes = append(prunedRoutes, route)
}
log.Tracef("Filtered out %v routes with channel %v",
len(routes)-len(prunedRoutes), skipChan)
return prunedRoutes
}
// pathsToFeeSortedRoutes takes a set of paths, and returns a corresponding set
// of routes. A route differs from a path in that it has full time-lock and
// fee information attached. The set of routes returned may be less than the