tatanka: add bootstrap list publishing#16
Conversation
| // Re-publish a few times during startup to pick up NAT-mapped | ||
| // addresses once UPnP/NAT-PMP discovery completes (~10s). | ||
| startup := time.NewTicker(5 * time.Second) | ||
| for i := 0; i < 6; i++ { | ||
| select { | ||
| case <-ctx.Done(): | ||
| startup.Stop() | ||
| return | ||
| case <-startup.C: | ||
| b.publish() | ||
| } | ||
| } | ||
| startup.Stop() |
There was a problem hiding this comment.
Using the EvtLocalAddressesUpdated event provides more control here instead of publishing at set intervals. From the documentation the event should be emitted when UPnP/NAT-PMP discovery completes. This way, publishing only happens when addresses actually change.
f0ca0b2 to
b7cf64c
Compare
Publish the whitelist peer set to a bootstrap file and optional HTTP endpoint. Serialize file writes, keep the JSON output deterministic, and allow local-only addresses in local dev mode so the test harness can bootstrap correctly.
Replace a peer's stored addresses when identify completes and persist the updated view into the peerstore cache and bootstrap list. Prefer signed peer record addresses, fall back to identify listen addresses, and ignore empty filtered results to avoid clearing the last known usable addresses when identify yields no replacement.
| whitelist := b.getWhitelist() | ||
| localID := b.host.ID() | ||
|
|
||
| entries := make([]bootstrapPeerEntry, 0, len(whitelist)) |
There was a problem hiding this comment.
If you're going to be sorting these, shouldn't we use pointers?
| if addrStrs == nil { | ||
| addrStrs = []string{} | ||
| } |
There was a problem hiding this comment.
Might as well just initialize it up top.
| mux.HandleFunc("/bootstrap", b.handleHTTP) | ||
| b.httpServer = &http.Server{ | ||
| Addr: fmt.Sprintf("0.0.0.0:%d", b.httpPort), | ||
| Handler: mux, |
There was a problem hiding this comment.
I'm not sure if it matters, but you could do
BaseContext: func(_ net.Listener) context.Context {
return ctx
},
| host host.Host | ||
| getWhitelist func() map[peer.ID]struct{} | ||
| httpServer *http.Server | ||
| filePath string // empty = file publishing disabled |
There was a problem hiding this comment.
I'm not seeing the purpose in saving the data to file. Are we supposed to be loading from file on startup or something?
There was a problem hiding this comment.
This is in case someone wants to host the bootstrap list on another server than where the tatanka node is running. They could have a shell script that sends the file to another location.
Uh oh!
There was an error while loading. Please reload this page.