autopilot: optimize heavy loaded agent by fetching raw bytes for ChannelEdge

In this commit, we implement an optimization to the autopilot agent to
ensure that we don't spin and waste CPU when we either have a large
graph, or a high max channel target for the agent. Before this commit,
each time we went to read the state of a channel from disk, we would
decompress the EC Point each time. However, for the case of the instal
ChannlEdge struct to feed to the agent, we only actually need to obtain
the pubkey, and can save the potentially expensive point decompression
for each directional channel in the graph.
This commit is contained in:
Olaoluwa Osuntokun 2018-09-04 16:42:12 -07:00
parent 12aadd4978
commit 1217992d9d
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

@ -96,13 +96,12 @@ func (d dbNode) ForEachChannel(cb func(ChannelEdge) error) error {
return nil
}
pubkey, _ := ep.Node.PubKey()
edge := ChannelEdge{
Channel: Channel{
ChanID: lnwire.NewShortChanIDFromInt(ep.ChannelID),
Capacity: ei.Capacity,
FundedAmt: ei.Capacity,
Node: NewNodeID(pubkey),
Node: NodeID(ep.Node.PubKeyBytes),
},
Peer: dbNode{
tx: tx,