diff --git a/config/example_config.toml b/config/example_config.toml index 7991ed5a6..933ccdf8f 100644 --- a/config/example_config.toml +++ b/config/example_config.toml @@ -21,11 +21,27 @@ # `network` contains configuration options for the network module, which manages communication between nodes. [network] + # `network_key` specifies the private key filename to use for node authentication and encryption in the p2p protocol. + ## network_key = "network_key" + # `listens` specifies the addresses and ports where the node will listen for incoming connections from other nodes. ## listens = ["/ip4/0.0.0.0/tcp/21888", "/ip6/::/tcp/21888", "/ip4/0.0.0.0/udp/21888/quic-v1", "/ip6/::/udp/21888/quic-v1"] - # `network_key` specifies the private key filename to use for node authentication and encryption in the p2p protocol. - ## network_key = "network_key" + # `relay_addresses` provides the necessary relay addresses. These should be specified if 'enable_relay' is 'true'. + # Note: this parameter will be ignored if 'enable_relay' is 'false'. + ## relay_addresses = [] + + # `addresses` is a list of peer addresses needed for peer discovery. + # These addresses are used by the Pactus node to discover and connect to other peers on the network. + ## bootstrap_addresses = [] + + # `min_connections` is the minimum number of connections that the Pactus node should maintain. + # Default is 8 + ## min_connections = 8 + + # `max_connections` is the maximum number of connections that the Pactus node should maintain. + # Default is 16 + ## max_connections = 16 # `enable_nat` indicates whether NAT service should be enabled or not. # NAT service allows many machines to share a single public address. @@ -37,10 +53,6 @@ # Default is true. ## enable_relay = false - # `relay_addresses` provides the necessary relay addresses. These should be specified if 'enable_relay' is 'true'. - # Note: this parameter will be ignored if 'enable_relay' is 'false'. - ## relay_addresses = [] - # `enable_mdns` indicates whether MDNS should be enabled or not. # MDNS is a protocol to discover local peers quickly and efficiently. # Default is false. @@ -54,25 +66,6 @@ # Default is false. ## bootstrapper = false - # `network.bootstrap` contains configuration for bootstrapping the node. - [network.bootstrap] - - # `addresses` is a list of peer addresses needed for peer discovery. - # These addresses are used by the Pactus node to discover and connect to other peers on the network. - ## addresses = ["/ip4/172.104.46.145/tcp/21777/p2p/12D3KooWNYD4bB82YZRXv6oNyYPwc5ozabx2epv75ATV3D8VD3Mq"] - - # `min_threshold` is the minimum number of connections that the Pactus node should maintain. - # Default is 8 - ## min_threshold = 8 - - # `max_threshold` is the maximum number of connections that the Pactus node should maintain. - # Default is 16 - ## max_threshold = 16 - - # `period` periodically checks to see if the threshold is maintained. - # Default is 1 minute - ## period = "1m0s" - # `sync` contains configuration of sync module. [sync] diff --git a/network/dht.go b/network/dht.go index 305930257..d410a9c42 100644 --- a/network/dht.go +++ b/network/dht.go @@ -10,11 +10,11 @@ import ( ) type dhtService struct { - ctx context.Context - host lp2phost.Host - kademlia *lp2pdht.IpfsDHT - peerMgr *peerMgr - logger *logger.SubLogger + ctx context.Context + host lp2phost.Host + kademlia *lp2pdht.IpfsDHT + peerMgr *peerMgr + logger *logger.SubLogger } func newDHTService(ctx context.Context, host lp2phost.Host, protocolID lp2pcore.ProtocolID, @@ -48,11 +48,11 @@ func newDHTService(ctx context.Context, host lp2phost.Host, protocolID lp2pcore. bootsrapAddrs, conf.MinConns, conf.MaxConns, logger) return &dhtService{ - ctx: ctx, - host: host, - kademlia: kademlia, - peerMgr: bootstrap, - logger: logger, + ctx: ctx, + host: host, + kademlia: kademlia, + peerMgr: bootstrap, + logger: logger, } } diff --git a/network/utils.go b/network/utils.go index f493a0491..1e65fcbec 100644 --- a/network/utils.go +++ b/network/utils.go @@ -35,7 +35,7 @@ func MakeAddressInfo(addr string) (*lp2ppeer.AddrInfo, error) { func ConnectAsync(ctx context.Context, h lp2phost.Host, addrInfo lp2ppeer.AddrInfo, logger *logger.SubLogger) { go func() { - err := h.Connect(lp2pnetwork.WithDialPeerTimeout(ctx, 10*time.Second), addrInfo) + err := h.Connect(lp2pnetwork.WithDialPeerTimeout(ctx, 30*time.Second), addrInfo) if err != nil { if logger != nil { logger.Warn("connection failed", "addr", addrInfo.Addrs, "err", err) diff --git a/tests/main_test.go b/tests/main_test.go index e1d5ba292..b8ac5b9e6 100644 --- a/tests/main_test.go +++ b/tests/main_test.go @@ -85,9 +85,8 @@ func TestMain(m *testing.M) { tConfigs[i].Network.Bootstrapper = true tConfigs[i].Network.NetworkKey = util.TempFilePath() tConfigs[i].Network.Listens = []string{"/ip4/127.0.0.1/tcp/0", "/ip4/127.0.0.1/udp/0/quic-v1"} - tConfigs[i].Network.Bootstrap.Addresses = []string{} - tConfigs[i].Network.Bootstrap.Period = 10 * time.Second - tConfigs[i].Network.Bootstrap.MinThreshold = 3 + tConfigs[i].Network.BootstrapAddrs = []string{} + tConfigs[i].Network.MinConns = 3 tConfigs[i].HTTP.Enable = false tConfigs[i].GRPC.Enable = false