mirror of
https://github.com/logos-messaging/go-discover.git
synced 2026-01-06 23:13:10 +00:00
Allow setting fallback nodes after start
In some cases, we don't have fallback nodes when we start. That might be due to some connectivity issues. This commit adds a method to set the fallback nodes, and triggers a refresh so that they are picked up. The method is synchronous.
This commit is contained in:
parent
2f43d5f6c7
commit
14e8ef894a
@ -29,12 +29,13 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/waku-org/go-discover/discover/v5wire"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common/mclock"
|
"github.com/ethereum/go-ethereum/common/mclock"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/p2p/enode"
|
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||||
"github.com/ethereum/go-ethereum/p2p/enr"
|
"github.com/ethereum/go-ethereum/p2p/enr"
|
||||||
"github.com/ethereum/go-ethereum/p2p/netutil"
|
"github.com/ethereum/go-ethereum/p2p/netutil"
|
||||||
"github.com/waku-org/go-discover/discover/v5wire"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -846,6 +847,17 @@ func packNodes(reqid []byte, nodes []*enode.Node) []*v5wire.Nodes {
|
|||||||
return resp
|
return resp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *UDPv5) SetFallbackNodes(nodes []*enode.Node) error {
|
||||||
|
err := t.tab.setFallbackNodes(nodes)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
refreshDone := make(chan struct{})
|
||||||
|
t.tab.doRefresh(refreshDone)
|
||||||
|
<-refreshDone
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// handleTalkRequest runs the talk request handler of the requested protocol.
|
// handleTalkRequest runs the talk request handler of the requested protocol.
|
||||||
func (t *UDPv5) handleTalkRequest(p *v5wire.TalkRequest, fromID enode.ID, fromAddr *net.UDPAddr) {
|
func (t *UDPv5) handleTalkRequest(p *v5wire.TalkRequest, fromID enode.ID, fromAddr *net.UDPAddr) {
|
||||||
t.trlock.Lock()
|
t.trlock.Lock()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user