Usage
This section provides guidance on how to setup and interact with the Discv5 protocol in a .NET project.
Setting Up
The Discv5Protocol
class exposes functions for interacting with the Node Discovery Protocol V5. Start by creating an instance of Discv5Protocol
:
using Lantern.Discv5.WireProtocol;
string[] bootstrapEnrs = new[]
{
"enr:-Ku4QImhMc1z8yCiNJ1TyUxdcfNucje3BGwEHzodEZUan8PherEo4sF7pPHPSIB1NNuSg5fZy7qFsjmUKs2ea1Whi0EBh2F0dG5ldHOIAAAAAAAAAACEZXRoMpD1pf1CAAAAAP__________gmlkgnY0gmlwhBLf22SJc2VjcDI1NmsxoQOVphkDqal4QzPMksc5wnpuC3gvSC8AfbFOnZY_On34wIN1ZHCCIyg",
"enr:-KG4QOtcP9X1FbIMOe17QNMKqDxCpm14jcX5tiOE4_TyMrFqbmhPZHK_ZPG2Gxb1GE2xdtodOfx9-cgvNtxnRyHEmC0ghGV0aDKQ9aX9QgAAAAD__________4JpZIJ2NIJpcIQDE8KdiXNlY3AyNTZrMaEDhpehBDbZjM_L9ek699Y7vhUJ-eAdMyQW_Fil522Y0fODdGNwgiMog3VkcIIjKA"
};
Discv5Protocol discv5 = Discv5Builder.CreateDefault(bootstrapEnrs);
The CreateDefault
method of Discv5Builder
is used to instantiate the Discv5 protocol with a list of bootstrap ENR nodes.
If more granular control is needed over the protocol's configuration, you can create an instance of Discv5Protocol
using the builder pattern provided by Discv5Builder
:
Discv5Protocol discv5 = new Discv5Builder()
.WithConnectionOptions(connectionOptions)
.WithSessionOptions(sessionOptions)
.WithTableOptions(tableOptions)
.WithBootstrapEnrs(bootstrapEnrs)
.WithEnrBuilder(enrBuilder)
.WithEnrEntryRegistry(enrEntryRegistry)
.WithLoggerFactory(loggerFactory)
.Build();
How To Use
Once Discv5Protocol
has been instantiated, the protocol is ready to be interacted by using the following functionalities:
Last updated