Add Sequence field #13 to packet header according to latest Whitepaper 0.7.1

The field is yet to be used.
This commit is contained in:
Kleissner
2021-04-18 05:22:19 +02:00
parent a82f575816
commit 703e40c947
4 changed files with 46 additions and 23 deletions

View File

@@ -7,6 +7,7 @@ Author: Peter Kleissner
package core
import (
"bytes"
"fmt"
"time"
@@ -14,7 +15,7 @@ import (
)
// respondClosesContactsCount is the number of closest contact to respond.
// Each peer record will take 55 bytes. Overhead is 73 + 15 payload header + UA length + 6 + 34 = 128 bytes without UA.
// Each peer record will take 55 bytes. Overhead is 77 + 15 payload header + UA length + 6 + 34 = 132 bytes without UA.
// It makes sense to stay below 508 bytes (no fragmentation). Reporting back 5 contacts for FIND_SELF requests should do the magic.
const respondClosesContactsCount = 5
@@ -138,6 +139,10 @@ func (peer *PeerInfo) cmdResponse(msg *MessageResponse) {
for _, hash2Peer := range msg.Hash2Peers {
info := nodesDHT.IRLookup(peer.NodeID, hash2Peer.ID.Hash)
if info == nil {
// Response to FIND_SELF?
if bytes.Equal(info.Key, nodeID) && len(hash2Peer.Closest) > 0 {
peer.cmdResponseFindSelf(msg, hash2Peer.Closest)
}
continue
}