routing: vertexes are now serialized pub keys instead of pubkey hashes
This commit is contained in:
parent
ca89ddb9ea
commit
5ebaf9d1e7
@ -583,9 +583,10 @@ func (f *fundingManager) handleFundingSignComplete(fmsg *fundingSignCompleteMsg)
|
|||||||
// so this new channel can be utilized during path
|
// so this new channel can be utilized during path
|
||||||
// finding.
|
// finding.
|
||||||
chanInfo := openChan.StateSnapshot()
|
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(
|
fmsg.peer.server.routingMgr.OpenChannel(
|
||||||
graph.NewID(chanInfo.RemoteID),
|
graph.NewID(vertex),
|
||||||
graph.NewEdgeID(fundingPoint.String()),
|
graph.NewEdgeID(fundingPoint.String()),
|
||||||
&rt.ChannelInfo{
|
&rt.ChannelInfo{
|
||||||
Cpt: capacity,
|
Cpt: capacity,
|
||||||
@ -655,8 +656,9 @@ func (f *fundingManager) handleFundingOpen(fmsg *fundingOpenMsg) {
|
|||||||
// Notify the L3 routing manager of the newly active channel link.
|
// Notify the L3 routing manager of the newly active channel link.
|
||||||
capacity := int64(resCtx.reservation.OurContribution().FundingAmount +
|
capacity := int64(resCtx.reservation.OurContribution().FundingAmount +
|
||||||
resCtx.reservation.TheirContribution().FundingAmount)
|
resCtx.reservation.TheirContribution().FundingAmount)
|
||||||
|
vertex := hex.EncodeToString(fmsg.peer.identityPub.SerializeCompressed())
|
||||||
fmsg.peer.server.routingMgr.OpenChannel(
|
fmsg.peer.server.routingMgr.OpenChannel(
|
||||||
graph.NewID([32]byte(fmsg.peer.lightningID)),
|
graph.NewID(vertex),
|
||||||
graph.NewEdgeID(resCtx.reservation.FundingOutpoint().String()),
|
graph.NewEdgeID(resCtx.reservation.FundingOutpoint().String()),
|
||||||
&rt.ChannelInfo{
|
&rt.ChannelInfo{
|
||||||
Cpt: capacity,
|
Cpt: capacity,
|
||||||
|
@ -208,7 +208,7 @@ out:
|
|||||||
select {
|
select {
|
||||||
case err := <-errChan:
|
case err := <-errChan:
|
||||||
rpcsLog.Errorf("unable to open channel to "+
|
rpcsLog.Errorf("unable to open channel to "+
|
||||||
"lightningID(%v) nor peerID(%v): %v",
|
"lightningID(%x) nor peerID(%v): %v",
|
||||||
in.TargetNode, in.TargetPeerId, err)
|
in.TargetNode, in.TargetPeerId, err)
|
||||||
return err
|
return err
|
||||||
case fundingUpdate := <-updateChan:
|
case fundingUpdate := <-updateChan:
|
||||||
|
20
server.go
20
server.go
@ -118,7 +118,8 @@ func newServer(listenAddrs []string, notifier chainntnfs.ChainNotifier,
|
|||||||
|
|
||||||
// Create a new routing manager with ourself as the sole node within
|
// Create a new routing manager with ourself as the sole node within
|
||||||
// the graph.
|
// 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)
|
s.rpcServer = newRpcServer(s)
|
||||||
|
|
||||||
@ -306,22 +307,27 @@ out:
|
|||||||
msg1 := msg.(*routing.RoutingMessage)
|
msg1 := msg.(*routing.RoutingMessage)
|
||||||
if msg1.ReceiverID == nil {
|
if msg1.ReceiverID == nil {
|
||||||
peerLog.Critical("msg1.GetReceiverID() == nil")
|
peerLog.Critical("msg1.GetReceiverID() == nil")
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
receiverID := msg1.ReceiverID.ToByte32()
|
receiverID := msg1.ReceiverID.String()
|
||||||
|
|
||||||
var targetPeer *peer
|
var targetPeer *peer
|
||||||
for _, peer := range s.peers { // TODO: threadsafe api
|
for _, peer := range s.peers { // TODO: threadsafe api
|
||||||
|
nodePub := peer.identityPub.SerializeCompressed()
|
||||||
|
idStr := hex.EncodeToString(nodePub)
|
||||||
|
|
||||||
// We found the the target
|
// We found the the target
|
||||||
if peer.lightningID == receiverID {
|
if receiverID == idStr {
|
||||||
targetPeer = peer
|
targetPeer = peer
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if targetPeer != nil {
|
if targetPeer != nil {
|
||||||
fndgLog.Info("Peer found. Sending message")
|
targetPeer.queueMsg(msg1.Msg, nil)
|
||||||
done := make(chan struct{}, 1)
|
|
||||||
targetPeer.queueMsg(msg1.Msg, done)
|
|
||||||
} else {
|
} 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:
|
case <-s.quit:
|
||||||
break out
|
break out
|
||||||
|
Loading…
Reference in New Issue
Block a user