-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add ENR v5 bootnodes support for DiscV5 discovery #9970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b521f25
ad8b277
8c37051
a26f9cf
e484e48
63734c6
8e09351
a89f3d0
6756407
e771463
d159fb9
5614f90
7447039
6000bbe
74c7048
4d13fe6
d72eeb8
f53a376
67f64cc
c2866d5
3b3707e
932360d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ public class DiscoveryOptions { | |
| new DiscoveryOptions(JsonUtil.createEmptyObjectNode()); | ||
|
|
||
| private static final String ENODES_KEY = "bootnodes"; | ||
| private static final String V5_BOOTNODES_KEY = "v5bootnodes"; | ||
|
usmansaleem marked this conversation as resolved.
|
||
| private static final String DNS_KEY = "dns"; | ||
|
usmansaleem marked this conversation as resolved.
|
||
|
|
||
| private final ObjectNode discoveryConfigRoot; | ||
|
|
@@ -67,6 +68,32 @@ public Optional<List<String>> getBootNodes() { | |
| return Optional.of(bootNodes); | ||
| } | ||
|
|
||
| /** | ||
| * Gets V5 boot nodes (ENR format). | ||
| * | ||
| * @return optional list of ENR boot node strings | ||
| */ | ||
| public Optional<List<String>> getV5BootNodes() { | ||
| final Optional<ArrayNode> bootNodesArray = | ||
| JsonUtil.getArrayNode(discoveryConfigRoot, V5_BOOTNODES_KEY); | ||
|
usmansaleem marked this conversation as resolved.
|
||
| if (bootNodesArray.isEmpty()) { | ||
| return Optional.empty(); | ||
| } | ||
| final List<String> bootNodes = new ArrayList<>(); | ||
| bootNodesArray | ||
| .get() | ||
| .elements() | ||
| .forEachRemaining( | ||
| bootNodeElement -> { | ||
| if (!bootNodeElement.isTextual()) { | ||
| throw new IllegalArgumentException( | ||
| V5_BOOTNODES_KEY + " does not contain a string: " + bootNodeElement); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. think it would be more helpful to say "must contain strings of the form enr:-xyz"
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I followed how bootnodes were parsed from the genesis configuration file in getBootNodes in the same file. |
||
| } | ||
| bootNodes.add(bootNodeElement.asText()); | ||
| }); | ||
| return Optional.of(bootNodes); | ||
| } | ||
|
|
||
| /** | ||
| * Gets discovery dns url. | ||
| * | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.