lnwire+peer: clamp pong bytes, make ping handler more effcieint

This was not properly enforced and would be a spec violation on the
peer's end. Also re-use a pong buffer to save on heap allocations if
there are a lot of peers. The pong buffer is only read from, so this
is concurrent safe.
This commit is contained in:
Olaoluwa Osuntokun committed 2022-01-13 15:01:18 -08:00
1 parent ae16f2b631
commit 3481286ea0
6 files changed
+55 -7

No files matched your search

+2
View File
@@ -999,6 +999,7 @@ func TestStaticRemoteDowngrade(t *testing.T) {
Features: test.features,
Conn: mockConn,
WritePool: writePool,
PongBuf: make([]byte, lnwire.MaxPongBytes),
},
}
@@ -1103,6 +1104,7 @@ func TestPeerCustomMessage(t *testing.T) {
}
return nil
},
PongBuf: make([]byte, lnwire.MaxPongBytes),
})
// Set up the init sequence.