Settings
This section explains the various options available for configuration when creating the Discv5 protocol.
Last updated
This section explains the various options available for configuration when creating the Discv5 protocol.
Last updated
Please note the customization and settings of mentioned options are optional and only recommended for certain scenarios, as it may affect the performance of the application during runtime.
ConnectionOptions
allows you to adjust settings related to the connection manager:
Port
: Specifies the port for the local node. Default value is 9000
milliseconds
IpAddress
: Indicates the IP address of the local machine on which the node is running
ReceiveTimeoutMs
: Specifies the timeout in milliseconds for receiving a response to a request message. Default value is 1000
milliseconds
RequestTimeoutMs
: Specifies the timeout in milliseconds to remove pending messages for which a response has not been received. Default value is 2000
milliseconds
CheckPendingRequestsDelayMs
: Specifies the time interval in milliseconds to check for pending messages. Default value is 500
milliseconds
RemoveCompletedRequestsDelayMs
: Specifies the time interval in milliseconds for the removal of completed requests. Default value is 1000
milliseconds
Example
var connectionOptions = new ConnectionOptions()
.SetPort(9000)
.SetIpAddress(IPAddress.Parse("192.168.1.100"))
.SetReceiveTimeoutMs(1000)
.SetRequestTimeoutMs(2000
SessionOptions
allows you to adjust settings related to the session manager:
Signer
: The signer for the identity scheme (v4 as per the ENR Specification)
Verifier
: The verifier for the identity scheme (v4 as per the ENR Specification)
SessionKeys
: The private keys used for securing the session
SessionCacheSize
: Specifies the size of the cache for storing session objects. Default value is 1000
Example
byte[] privateKey = ...; // Random 32 byte private key
ISessionKeys sessionKeys = new SessionKeys(privateKey);
IIdentitySchemeV4Signer signer = new IdentitySchemeV4Signer(privateKey);
IIdentitySchemeV4Verifier verifier = new IdentitySchemeV4Verifier();
SessionOptions sessionOptions = new()
.SetSigner(signer)
.SetVerifier(verifier)
.SetSessionKeys(sessionKeys)
.SetCacheSize(1500);
TableOptions
allows you to configure the settings related to the node table manager:
PingIntervalMilliseconds
: Specifies the time interval in milliseconds at which ping messages are sent to active peers. Default value is 5000
RefreshIntervalMilliseconds
: Specifies the time interval in milliseconds at which the node table is refreshed by performing a lookup to ensure that the knowledge of active peers is up-to-date. Default value is 300000
LookupTimeoutMilliseconds
: Specifies the maximum time in milliseconds to perform a lookup operation. Default value is 10000
ConcurrencyParameter
: Specifies the concurrency factor (k) when performing lookups. This is the number of nodes that are queried each FINDNODE
request during the lookup. Default value is 3
LookupParallelism
: Specifies the maximum number of lookup operations (path buckets) that can be performed in parallel while maintaining the concurrency parameter (k). Default value is 2
.
MaxAllowedFailures
: Specifies the maximum number of allowed unsuccessful interaction attempts with a peer before it is considered as non-responsive and added to the blacklisting mechanism. Default value is 3
BootstrapEnrs
: Specifies an array of ENRs (Ethereum Node Record) for bootstrap peers.
TableOptions tableOptions = new()
.SetPingIntervalMilliseconds(6000)
.SetRefreshIntervalMilliseconds(360000)
.SetLookupTimeoutMilliseconds(12000)
.SetMaxAllowedFailures(4)
.SetReplacementCacheSize(250)
.SetConcurrencyParameter(4)
.SetLookupParallelism(3)
.SetBootstrapEnrs(new string[] { "enr:...", "enr:..." });