chore(kad_dht): centralize shared values in common.py

This commit is contained in:
Luca Vivona
2025-06-19 21:24:39 -04:00
parent 09b4c846a4
commit dfc0bb4ec8
5 changed files with 32 additions and 17 deletions

View File

@ -25,12 +25,17 @@ from libp2p.peer.peerinfo import (
PeerInfo,
)
from .pb.kademlia_pb2 import (
Message,
)
from .routing_table import (
RoutingTable,
)
from .common import (
PROTOCOL_ID,
ALPHA
)
from .utils import (
sort_peer_ids_by_distance,
)
@ -38,10 +43,7 @@ from .utils import (
# logger = logging.getLogger("libp2p.kademlia.peer_routing")
logger = logging.getLogger("kademlia-example.peer_routing")
# Constants for the Kademlia algorithm
ALPHA = 3 # Concurrency parameter
MAX_PEER_LOOKUP_ROUNDS = 20 # Maximum number of rounds in peer lookup
PROTOCOL_ID = TProtocol("/ipfs/kad/1.0.0")
class PeerRouting(IPeerRouting):