Skip to content

tatanka: add bootstrap list publishing#16

Open
martonp wants to merge 2 commits intobisoncraft:masterfrom
martonp:bootstrapList
Open

tatanka: add bootstrap list publishing#16
martonp wants to merge 2 commits intobisoncraft:masterfrom
martonp:bootstrapList

Conversation

@martonp
Copy link
Copy Markdown
Contributor

@martonp martonp commented Mar 1, 2026

tatanka: add bootstrap list publishing

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.
tatanka: reconcile peer addresses on identify updates

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.

Comment thread tatanka/bootstrap_list.go Outdated
Comment on lines +131 to +143
// 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()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@martonp martonp force-pushed the bootstrapList branch 3 times, most recently from f0ca0b2 to b7cf64c Compare March 14, 2026 14:59
martonp added 2 commits March 14, 2026 13:36
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.
Comment thread tatanka/bootstrap_list.go
whitelist := b.getWhitelist()
localID := b.host.ID()

entries := make([]bootstrapPeerEntry, 0, len(whitelist))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're going to be sorting these, shouldn't we use pointers?

Comment thread tatanka/bootstrap_list.go
Comment on lines +100 to +102
if addrStrs == nil {
addrStrs = []string{}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well just initialize it up top.

Comment thread tatanka/bootstrap_list.go
mux.HandleFunc("/bootstrap", b.handleHTTP)
b.httpServer = &http.Server{
Addr: fmt.Sprintf("0.0.0.0:%d", b.httpPort),
Handler: mux,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it matters, but you could do

BaseContext: func(_ net.Listener) context.Context {
    return ctx
},

Comment thread tatanka/bootstrap_list.go
host host.Host
getWhitelist func() map[peer.ID]struct{}
httpServer *http.Server
filePath string // empty = file publishing disabled
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not seeing the purpose in saving the data to file. Are we supposed to be loading from file on startup or something?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants