Organize peers by subnet.

This commit restructures PeerMaps to be a map from Subnet to
PeerID to Peer. This reduces the complexity require to gather peers from
the same subnet.
This commit is contained in:
Jimmy Zelinskie
2014-09-23 23:00:50 -04:00
parent 6a96245d90
commit b910fdabf5
7 changed files with 131 additions and 118 deletions
+5 -6
View File
@@ -19,9 +19,8 @@ import (
// Tracker represents the logic necessary to service BitTorrent announces,
// independently of the underlying data transports used.
type Tracker struct {
cfg *config.Config
backend backend.Conn
Config *config.Config
Backend backend.Conn
*Storage
}
@@ -34,8 +33,8 @@ func New(cfg *config.Config) (*Tracker, error) {
}
tkr := &Tracker{
cfg: cfg,
backend: bc,
Config: cfg,
Backend: bc,
Storage: NewStorage(),
}
@@ -54,7 +53,7 @@ func New(cfg *config.Config) (*Tracker, error) {
// Close gracefully shutdowns a Tracker by closing any database connections.
func (tkr *Tracker) Close() error {
return tkr.backend.Close()
return tkr.Backend.Close()
}
// LoadApprovedClients loads a list of client IDs into the tracker's storage.