satellite,storagenode,bootstrap: add contact service to peer (#2951)

* satellite,storagenode,bootstrap: add contact service to peer
This commit is contained in:
paul cannon 2019-09-04 14:04:18 -05:00 committed by Cameron
parent adfa16188b
commit 9821a21e5c
3 changed files with 24 additions and 3 deletions

View File

@ -40,6 +40,7 @@ import (
"storj.io/storj/satellite/console"
"storj.io/storj/satellite/console/consoleauth"
"storj.io/storj/satellite/console/consoleweb"
"storj.io/storj/satellite/contact"
"storj.io/storj/satellite/dbcleanup"
"storj.io/storj/satellite/discovery"
"storj.io/storj/satellite/gc"
@ -159,6 +160,10 @@ type Peer struct {
Inspector *kademlia.Inspector
}
Contact struct {
Service *contact.Service
}
Overlay struct {
DB overlay.DB
Service *overlay.Service
@ -352,6 +357,11 @@ func New(log *zap.Logger, full *identity.FullIdentity, db DB, revocationDB exten
pb.RegisterKadInspectorServer(peer.Server.PrivateGRPC(), peer.Kademlia.Inspector)
}
{ // setup contact service
log.Debug("Setting up contact service")
peer.Contact.Service = contact.NewService(peer.Log.Named("contact"), peer.Overlay.Service, peer.Transport)
}
{ // setup discovery
log.Debug("Setting up discovery")
config := config.Discovery

View File

@ -20,7 +20,7 @@ var mon = monkit.Package()
// Service is the contact service between storage nodes and satellites
type Service struct {
log *zap.Logger
self *overlay.NodeDossier
self overlay.NodeDossier
transport transport.Client
mu sync.Mutex
@ -30,7 +30,7 @@ type Service struct {
}
// NewService creates a new contact service
func NewService(log *zap.Logger, self *overlay.NodeDossier, transport transport.Client) *Service {
func NewService(log *zap.Logger, self overlay.NodeDossier, transport transport.Client) *Service {
return &Service{
log: log,
self: self,
@ -56,5 +56,5 @@ func (service *Service) wasPinged(when time.Time, srcNodeID storj.NodeID, srcAdd
// Local returns the local node
func (service *Service) Local() overlay.NodeDossier {
return *service.self
return service.self
}

View File

@ -29,6 +29,7 @@ import (
"storj.io/storj/storagenode/collector"
"storj.io/storj/storagenode/console"
"storj.io/storj/storagenode/console/consoleserver"
"storj.io/storj/storagenode/contact"
"storj.io/storj/storagenode/inspector"
"storj.io/storj/storagenode/monitor"
"storj.io/storj/storagenode/nodestats"
@ -117,6 +118,11 @@ type Peer struct {
Inspector *kademlia.Inspector
}
Contact struct {
Service *contact.Service
Endpoint *contact.Endpoint
}
Storage2 struct {
// TODO: lift things outside of it to organize better
Trust *trust.Pool
@ -237,6 +243,11 @@ func New(log *zap.Logger, full *identity.FullIdentity, db DB, revocationDB exten
pb.RegisterKadInspectorServer(peer.Server.PrivateGRPC(), peer.Kademlia.Inspector)
}
{ // setup contact service
peer.Contact.Service = contact.NewService(peer.Log.Named("contact"), peer.Kademlia.RoutingTable.Local(), peer.Transport)
peer.Contact.Endpoint = contact.NewEndpoint(peer.Log.Named("contact:endpoint"), peer.Contact.Service)
}
{ // setup storage
peer.Storage2.BlobsCache = pieces.NewBlobsUsageCache(peer.DB.Pieces())