1
0
Fork 0
mirror of https://github.com/ACINQ/eclair.git synced 2025-02-22 14:22:39 +01:00

separated NodeDiscovered/NodeUpdated events

This commit is contained in:
pm47 2017-02-10 17:06:46 +01:00
parent e3e93dc95f
commit 8334350576
2 changed files with 8 additions and 1 deletions

View file

@ -10,6 +10,8 @@ trait NetworkEvent
case class NodeDiscovered(ann: NodeAnnouncement) extends NetworkEvent
case class NodeUpdated(ann: NodeAnnouncement) extends NetworkEvent
case class NodeLost(nodeId: BinaryData) extends NetworkEvent
case class ChannelDiscovered(ann: ChannelAnnouncement) extends NetworkEvent

View file

@ -133,8 +133,13 @@ class Router(watcher: ActorRef) extends Actor with ActorLogging {
case n: NodeAnnouncement if nodes.containsKey(n.nodeId) && nodes(n.nodeId).timestamp >= n.timestamp =>
log.debug(s"ignoring announcement $n (old timestamp or duplicate)")
case n: NodeAnnouncement if nodes.containsKey(n.nodeId) =>
log.info(s"updated node nodeId=${n.nodeId}")
context.system.eventStream.publish(NodeUpdated(n))
context become mainWithLog(nodes + (n.nodeId -> n), channels, updates, rebroadcast :+ n, awaiting, stash)
case n: NodeAnnouncement =>
log.info(s"added/replaced node nodeId=${n.nodeId}")
log.info(s"added node nodeId=${n.nodeId}")
context.system.eventStream.publish(NodeDiscovered(n))
context become mainWithLog(nodes + (n.nodeId -> n), channels, updates, rebroadcast :+ n, awaiting, stash)