Replace magic number with named constants

This commit is contained in:
parth-soni07
2025-09-09 13:24:07 +05:30
parent 74f4aaf136
commit 4a36d6efeb
5 changed files with 194 additions and 59 deletions

View File

@ -39,6 +39,12 @@ from libp2p.tools.async_service import (
Service,
)
from .config import (
DIAL_TIMEOUT,
STREAM_READ_TIMEOUT,
STREAM_WRITE_TIMEOUT,
)
logger = logging.getLogger(__name__)
# Protocol ID for DCUtR
@ -47,11 +53,6 @@ PROTOCOL_ID = TProtocol("/libp2p/dcutr")
# Maximum message size for DCUtR (4KiB as per spec)
MAX_MESSAGE_SIZE = 4 * 1024
# Timeouts
STREAM_READ_TIMEOUT = 30 # seconds
STREAM_WRITE_TIMEOUT = 30 # seconds
DIAL_TIMEOUT = 10 # seconds
# Maximum number of hole punch attempts per peer
MAX_HOLE_PUNCH_ATTEMPTS = 5