|
@ -27,6 +27,7 @@ const ( |
|
|
// AddrBook is an address book used for tracking peers
|
|
|
// AddrBook is an address book used for tracking peers
|
|
|
// so we can gossip about them to others and select
|
|
|
// so we can gossip about them to others and select
|
|
|
// peers to dial.
|
|
|
// peers to dial.
|
|
|
|
|
|
// TODO: break this up?
|
|
|
type AddrBook interface { |
|
|
type AddrBook interface { |
|
|
cmn.Service |
|
|
cmn.Service |
|
|
|
|
|
|
|
@ -53,6 +54,9 @@ type AddrBook interface { |
|
|
|
|
|
|
|
|
// TODO: remove
|
|
|
// TODO: remove
|
|
|
ListOfKnownAddresses() []*knownAddress |
|
|
ListOfKnownAddresses() []*knownAddress |
|
|
|
|
|
|
|
|
|
|
|
// Persist to disk
|
|
|
|
|
|
Save() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var _ AddrBook = (*addrBook)(nil) |
|
|
var _ AddrBook = (*addrBook)(nil) |
|
@ -314,6 +318,11 @@ func (a *addrBook) size() int { |
|
|
|
|
|
|
|
|
//----------------------------------------------------------
|
|
|
//----------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
// Save persists the address book to disk.
|
|
|
|
|
|
func (a *addrBook) Save() { |
|
|
|
|
|
a.saveToFile(a.filePath) // thread safe
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
func (a *addrBook) saveRoutine() { |
|
|
func (a *addrBook) saveRoutine() { |
|
|
defer a.wg.Done() |
|
|
defer a.wg.Done() |
|
|
|
|
|
|
|
|