peer: add localFeatures as parameter to newPeer

In this commit we add the set of local features advertised as a
parameter to the newPeer function. With this change, the server will be
able to programmatically determine _which_ bits should be set on a
connection basis, rather than re-using the same global set of bits for
each peer.
This commit is contained in:
Olaoluwa Osuntokun committed 2017-10-18 15:16:09 -07:00
1 parent f6f983a13b
commit 56d4c15914
2 files changed
+21 -20

No files matched your search

+8 -2
View File
@@ -147,6 +147,9 @@ type peer struct {
server *server
// localFeatures is the set of local features that we advertised to the
// remote node.
localFeatures *lnwire.RawFeatureVector
// remoteLocalFeatures is the local feature vector received from the
// peer during the connection handshake.
@@ -164,7 +167,8 @@ type peer struct {
// newPeer creates a new peer from an establish connection object, and a
// pointer to the main server.
func newPeer(conn net.Conn, connReq *connmgr.ConnReq, server *server,
addr *lnwire.NetAddress, inbound bool) (*peer, error) {
addr *lnwire.NetAddress, inbound bool,
localFeatures *lnwire.RawFeatureVector) (*peer, error) {
nodePub := addr.IdentityKey
@@ -178,6 +182,8 @@ func newPeer(conn net.Conn, connReq *connmgr.ConnReq, server *server,
server: server,
localFeatures: localFeatures,
sendQueue: make(chan outgoinMsg),
sendQueueSync: make(chan struct{}),
outgoingQueue: make(chan outgoinMsg),
@@ -1967,7 +1973,7 @@ func (p *peer) handleInitMsg(msg *lnwire.Init) error {
func (p *peer) sendInitMsg() error {
msg := lnwire.NewInitMessage(
p.server.globalFeatures.RawFeatureVector,
p.server.localFeatures.RawFeatureVector,
p.localFeatures,
)
return p.writeMessage(msg)