-
Notifications
You must be signed in to change notification settings - Fork 15
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
chore: update example #291
Changes from all commits
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 |
---|---|---|
|
@@ -14,29 +14,26 @@ Included is a libp2p peer-discovery compatibility module. | |
#### Example | ||
|
||
```typescript | ||
import { Discv5Discovery, ENR } from "@chainsafe/discv5"; | ||
import Libp2p from "libp2p"; | ||
import {Discv5Discovery} from "@chainsafe/discv5"; | ||
import {ENR, SignableENR} from "@chainsafe/enr"; | ||
import {createLibp2p} from "libp2p"; | ||
import PeerId from "peer-id"; | ||
|
||
const myPeerId: PeerId = ...; | ||
|
||
const bootstrapEnrs: ENR[] = [...]; | ||
const bootEnrs: ENR[] = [...]; | ||
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. can you add an import for this type? 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. we have a general issue with our readme examples also in the Lodestar repo, might wanna spend some time investigating ChainSafe/lodestar#6300. This would ensure the examples are runnable and detect issues due to code refactoring / dependency updates. 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. @wemeetagain done! |
||
|
||
const libp2p = new Libp2p({ | ||
const libp2p = createLibp2p({ | ||
peerId: myPeerId, | ||
modules: { | ||
peerDiscovery: [Discv5Discovery], | ||
}, | ||
config: { | ||
discv5: { | ||
enr: ENR.createFromPeerId(myPeerInfo.id), | ||
bindAddr: "/ip4/0.0.0.0/udp/9000", | ||
bootstrapEnrs: bootstrapEnrs, | ||
searchInterval: 30000, // wait 30s between searches | ||
}, | ||
}, | ||
peerDiscovery: [() => new Discv5Discovery({ | ||
enabled: true, | ||
enr: SignableENR.createFromPeerId(myPeerId), | ||
peerId: myPeerId, | ||
bindAddrs: {ip4: "/ip4/0.0.0.0/udp/9000"}, | ||
bootEnrs, | ||
searchInterval: 30000, // wait 30s between searches | ||
})] | ||
}); | ||
|
||
``` | ||
|
||
## Additional features | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have to import these from enr package or does discv5 re-export? the later seems better devex to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't seen them being re-exported. Maybe @wemeetagain knows better?