mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-29 06:35:07 +03:00
make the main library reconfiguration more actor-friendly
This commit is contained in:
parent
aa30c6cc98
commit
a3d4d8125b
9 changed files with 144 additions and 159 deletions
|
@ -65,11 +65,10 @@ type dhtReqKey struct {
|
|||
|
||||
// The main DHT struct.
|
||||
type dht struct {
|
||||
router *router
|
||||
reconfigure chan chan error
|
||||
nodeID crypto.NodeID
|
||||
reqs map[dhtReqKey]time.Time // Keeps track of recent outstanding requests
|
||||
callbacks map[dhtReqKey][]dht_callbackInfo // Search and admin lookup callbacks
|
||||
router *router
|
||||
nodeID crypto.NodeID
|
||||
reqs map[dhtReqKey]time.Time // Keeps track of recent outstanding requests
|
||||
callbacks map[dhtReqKey][]dht_callbackInfo // Search and admin lookup callbacks
|
||||
// These next two could be replaced by a single linked list or similar...
|
||||
table map[crypto.NodeID]*dhtInfo
|
||||
imp []*dhtInfo
|
||||
|
@ -78,18 +77,16 @@ type dht struct {
|
|||
// Initializes the DHT.
|
||||
func (t *dht) init(r *router) {
|
||||
t.router = r
|
||||
t.reconfigure = make(chan chan error, 1)
|
||||
go func() {
|
||||
for {
|
||||
e := <-t.reconfigure
|
||||
e <- nil
|
||||
}
|
||||
}()
|
||||
t.nodeID = *t.router.core.NodeID()
|
||||
t.callbacks = make(map[dhtReqKey][]dht_callbackInfo)
|
||||
t.reset()
|
||||
}
|
||||
|
||||
func (t *dht) reconfigure(e chan error) {
|
||||
defer close(e)
|
||||
// This is where reconfiguration would go, if we had anything to do
|
||||
}
|
||||
|
||||
// Resets the DHT in response to coord changes.
|
||||
// This empties all info from the DHT and drops outstanding requests.
|
||||
func (t *dht) reset() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue