routing: vertexes are now serialized pub keys instead of pubkey hashes

This commit is contained in:
Olaoluwa Osuntokun 2016-09-20 16:07:22 -07:00
parent ca89ddb9ea
commit 5ebaf9d1e7
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
3 changed files with 19 additions and 11 deletions

@ -583,9 +583,10 @@ func (f *fundingManager) handleFundingSignComplete(fmsg *fundingSignCompleteMsg)
// so this new channel can be utilized during path
// finding.
chanInfo := openChan.StateSnapshot()
capacity := int64(chanInfo.Capacity)
capacity := int64(chanInfo.LocalBalance + chanInfo.RemoteBalance)
vertex := hex.EncodeToString(fmsg.peer.identityPub.SerializeCompressed())
fmsg.peer.server.routingMgr.OpenChannel(
graph.NewID(chanInfo.RemoteID),
graph.NewID(vertex),
graph.NewEdgeID(fundingPoint.String()),
&rt.ChannelInfo{
Cpt: capacity,
@ -655,8 +656,9 @@ func (f *fundingManager) handleFundingOpen(fmsg *fundingOpenMsg) {
// Notify the L3 routing manager of the newly active channel link.
capacity := int64(resCtx.reservation.OurContribution().FundingAmount +
resCtx.reservation.TheirContribution().FundingAmount)
vertex := hex.EncodeToString(fmsg.peer.identityPub.SerializeCompressed())
fmsg.peer.server.routingMgr.OpenChannel(
graph.NewID([32]byte(fmsg.peer.lightningID)),
graph.NewID(vertex),
graph.NewEdgeID(resCtx.reservation.FundingOutpoint().String()),
&rt.ChannelInfo{
Cpt: capacity,

@ -208,7 +208,7 @@ out:
select {
case err := <-errChan:
rpcsLog.Errorf("unable to open channel to "+
"lightningID(%v) nor peerID(%v): %v",
"lightningID(%x) nor peerID(%v): %v",
in.TargetNode, in.TargetPeerId, err)
return err
case fundingUpdate := <-updateChan:

@ -118,7 +118,8 @@ func newServer(listenAddrs []string, notifier chainntnfs.ChainNotifier,
// Create a new routing manager with ourself as the sole node within
// the graph.
s.routingMgr = routing.NewRoutingManager(graph.NewID(s.lightningID), nil)
selfVertex := hex.EncodeToString(serializedPubKey)
s.routingMgr = routing.NewRoutingManager(graph.NewID(selfVertex), nil)
s.rpcServer = newRpcServer(s)
@ -306,22 +307,27 @@ out:
msg1 := msg.(*routing.RoutingMessage)
if msg1.ReceiverID == nil {
peerLog.Critical("msg1.GetReceiverID() == nil")
continue
}
receiverID := msg1.ReceiverID.ToByte32()
receiverID := msg1.ReceiverID.String()
var targetPeer *peer
for _, peer := range s.peers { // TODO: threadsafe api
nodePub := peer.identityPub.SerializeCompressed()
idStr := hex.EncodeToString(nodePub)
// We found the the target
if peer.lightningID == receiverID {
if receiverID == idStr {
targetPeer = peer
break
}
}
if targetPeer != nil {
fndgLog.Info("Peer found. Sending message")
done := make(chan struct{}, 1)
targetPeer.queueMsg(msg1.Msg, done)
targetPeer.queueMsg(msg1.Msg, nil)
} else {
srvrLog.Errorf("Can't find peer to send message %v", receiverID)
srvrLog.Errorf("Can't find peer to send message %v",
receiverID)
}
case <-s.quit:
break out