|
@ -135,15 +135,15 @@ func (a *AddrBook) OnStart() error { |
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (a *AddrBook) Wait() { |
|
|
|
|
|
a.wg.Wait() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// OnStop implements Service.
|
|
|
// OnStop implements Service.
|
|
|
func (a *AddrBook) OnStop() { |
|
|
func (a *AddrBook) OnStop() { |
|
|
a.BaseService.OnStop() |
|
|
a.BaseService.OnStop() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (a *AddrBook) Wait() { |
|
|
|
|
|
a.wg.Wait() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
func (a *AddrBook) AddOurAddress(addr *NetAddress) { |
|
|
func (a *AddrBook) AddOurAddress(addr *NetAddress) { |
|
|
a.mtx.Lock() |
|
|
a.mtx.Lock() |
|
|
defer a.mtx.Unlock() |
|
|
defer a.mtx.Unlock() |
|
@ -320,6 +320,8 @@ type addrBookJSON struct { |
|
|
func (a *AddrBook) saveToFile(filePath string) { |
|
|
func (a *AddrBook) saveToFile(filePath string) { |
|
|
log.Info("Saving AddrBook to file", "size", a.Size()) |
|
|
log.Info("Saving AddrBook to file", "size", a.Size()) |
|
|
|
|
|
|
|
|
|
|
|
a.mtx.Lock() |
|
|
|
|
|
defer a.mtx.Unlock() |
|
|
// Compile Addrs
|
|
|
// Compile Addrs
|
|
|
addrs := []*knownAddress{} |
|
|
addrs := []*knownAddress{} |
|
|
for _, ka := range a.addrLookup { |
|
|
for _, ka := range a.addrLookup { |
|
|