Settings
This section explains the various options available for configuration when creating the Discv5 protocol.
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.
Connection Options
ConnectionOptions allows you to adjust settings related to the connection manager:
Port: Specifies the port for the local node. Default value is9000millisecondsIpAddress: Indicates the IP address of the local machine on which the node is runningReceiveTimeoutMs: Specifies the timeout in milliseconds for receiving a response to a request message. Default value is1000millisecondsRequestTimeoutMs: Specifies the timeout in milliseconds to remove pending messages for which a response has not been received. Default value is2000millisecondsCheckPendingRequestsDelayMs: Specifies the time interval in milliseconds to check for pending messages. Default value is500millisecondsRemoveCompletedRequestsDelayMs: Specifies the time interval in milliseconds for the removal of completed requests. Default value is1000milliseconds
Example
var connectionOptions = new ConnectionOptions()
.SetPort(9000)
.SetIpAddress(IPAddress.Parse("192.168.1.100"))
.SetReceiveTimeoutMs(1000)
.SetRequestTimeoutMs(2000)
.SetCheckPendingRequestsDelayMs(500)
.SetRemoveCompletedRequestsDelayMs(1000);Session Options
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 sessionSessionCacheSize: Specifies the size of the cache for storing session objects. Default value is1000
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);Table Options
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 is5000RefreshIntervalMilliseconds: 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 is300000LookupTimeoutMilliseconds: Specifies the maximum time in milliseconds to perform a lookup operation. Default value is10000ConcurrencyParameter: Specifies the concurrency factor (k) when performing lookups. This is the number of nodes that are queried eachFINDNODErequest during the lookup. Default value is3LookupParallelism: Specifies the maximum number of lookup operations (path buckets) that can be performed in parallel while maintaining the concurrency parameter (k). Default value is2.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 is3BootstrapEnrs: 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:..." });Last updated