2019-08-01 00:09:09 +08:00
|
|
|
from typing import NamedTuple
|
2019-07-27 11:49:03 +08:00
|
|
|
|
2019-11-21 11:47:54 +08:00
|
|
|
import multiaddr
|
|
|
|
|
2019-09-02 23:21:57 +08:00
|
|
|
from libp2p.pubsub import floodsub, gossipsub
|
2019-09-02 21:01:13 +08:00
|
|
|
|
2019-11-21 11:47:54 +08:00
|
|
|
# Just a arbitrary large number.
|
|
|
|
# It is used when calling `MplexStream.read(MAX_READ_LEN)`,
|
|
|
|
# to avoid `MplexStream.read()`, which blocking reads until EOF.
|
2020-01-07 14:14:34 +08:00
|
|
|
MAX_READ_LEN = 65535
|
2019-11-21 11:47:54 +08:00
|
|
|
|
|
|
|
|
|
|
|
LISTEN_MADDR = multiaddr.Multiaddr("/ip4/127.0.0.1/tcp/0")
|
|
|
|
|
|
|
|
|
2019-09-02 21:01:13 +08:00
|
|
|
FLOODSUB_PROTOCOL_ID = floodsub.PROTOCOL_ID
|
|
|
|
GOSSIPSUB_PROTOCOL_ID = gossipsub.PROTOCOL_ID
|
2019-07-27 11:49:03 +08:00
|
|
|
|
2019-08-01 00:09:09 +08:00
|
|
|
|
|
|
|
class GossipsubParams(NamedTuple):
|
|
|
|
degree: int = 10
|
|
|
|
degree_low: int = 9
|
|
|
|
degree_high: int = 11
|
|
|
|
time_to_live: int = 30
|
|
|
|
gossip_window: int = 3
|
|
|
|
gossip_history: int = 5
|
2019-12-02 22:49:27 +08:00
|
|
|
heartbeat_initial_delay: float = 0.1
|
2019-08-01 00:09:09 +08:00
|
|
|
heartbeat_interval: float = 0.5
|
|
|
|
|
|
|
|
|
|
|
|
GOSSIPSUB_PARAMS = GossipsubParams()
|