server+peer: add 'init' message support
In this commit the support for global and local feature vectors were added in 'server' and 'peer' structures respectively. Also with commit additional logic was added and now node waits to receive 'init' lnwire.Message before sending/responding on any other messages.
This commit is contained in:
1 parent
bff55cb705
commit
6ce9ea29da
2 files changed
+93
-5
No files matched your search
@@ -76,6 +76,14 @@ type server struct {
|
||||
donePeers chan *peer
|
||||
queries chan interface{}
|
||||
|
||||
// globalFeatures feature vector which affects HTLCs and thus are also
|
||||
// advertised to other nodes.
|
||||
globalFeatures *lnwire.FeatureVector
|
||||
|
||||
// localFeatures is an feature vector which represent the features which
|
||||
// only affect the protocol between these two nodes.
|
||||
localFeatures *lnwire.FeatureVector
|
||||
|
||||
wg sync.WaitGroup
|
||||
quit chan struct{}
|
||||
}
|
||||
@@ -129,6 +137,9 @@ func newServer(listenAddrs []string, notifier chainntnfs.ChainNotifier,
|
||||
broadcastRequests: make(chan *broadcastReq),
|
||||
sendRequests: make(chan *sendReq),
|
||||
|
||||
globalFeatures: lnwire.NewFeatureVector(globalFeaturesMap),
|
||||
localFeatures: lnwire.NewFeatureVector(localFeaturesMap),
|
||||
|
||||
queries: make(chan interface{}),
|
||||
quit: make(chan struct{}),
|
||||
}
|
||||
@@ -413,7 +424,11 @@ func (s *server) peerConnected(conn net.Conn, connReq *connmgr.ConnReq, inbound
|
||||
// TODO(roasbeef): update IP address for link-node
|
||||
// * also mark last-seen, do it one single transaction?
|
||||
|
||||
peer.Start()
|
||||
if err := peer.Start(); err != nil {
|
||||
conn.Close()
|
||||
return
|
||||
}
|
||||
|
||||
s.newPeers <- peer
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user