diff --git a/cmd/satellite/fetchpieces.go b/cmd/satellite/fetchpieces.go index a25fac3ea..9493b71fc 100644 --- a/cmd/satellite/fetchpieces.go +++ b/cmd/satellite/fetchpieces.go @@ -89,6 +89,7 @@ func cmdFetchPieces(cmd *cobra.Command, args []string) (err error) { db.RepairQueue(), db.Buckets(), db.OverlayCache(), + db.NodeEvents(), db.Reputation(), db.Containment(), rollupsWriteCache, diff --git a/cmd/satellite/repair_segment.go b/cmd/satellite/repair_segment.go index 8e31f498d..cae589373 100644 --- a/cmd/satellite/repair_segment.go +++ b/cmd/satellite/repair_segment.go @@ -80,6 +80,7 @@ func cmdRepairSegment(cmd *cobra.Command, args []string) (err error) { db.RepairQueue(), db.Buckets(), db.OverlayCache(), + db.NodeEvents(), db.Reputation(), db.Containment(), rollupsWriteCache, diff --git a/cmd/satellite/repairer.go b/cmd/satellite/repairer.go index bedc1fc40..3cfebd6a4 100644 --- a/cmd/satellite/repairer.go +++ b/cmd/satellite/repairer.go @@ -69,6 +69,7 @@ func cmdRepairerRun(cmd *cobra.Command, args []string) (err error) { db.RepairQueue(), db.Buckets(), db.OverlayCache(), + db.NodeEvents(), db.Reputation(), db.Containment(), rollupsWriteCache, diff --git a/cmd/tools/segment-verify/main.go b/cmd/tools/segment-verify/main.go index 25eeaad38..2de903257 100644 --- a/cmd/tools/segment-verify/main.go +++ b/cmd/tools/segment-verify/main.go @@ -149,7 +149,7 @@ func verifySegmentsRange(cmd *cobra.Command, args []string) error { dialer := rpc.NewDefaultDialer(tlsOptions) // setup dependencies for verification - overlay, err := overlay.NewService(log.Named("overlay"), db.OverlayCache(), nil, "", "", satelliteCfg.Overlay) + overlay, err := overlay.NewService(log.Named("overlay"), db.OverlayCache(), db.NodeEvents(), nil, "", "", satelliteCfg.Overlay) if err != nil { return Error.Wrap(err) } diff --git a/private/testplanet/satellite.go b/private/testplanet/satellite.go index 505811637..123476c8d 100644 --- a/private/testplanet/satellite.go +++ b/private/testplanet/satellite.go @@ -673,7 +673,7 @@ func (planet *Planet) newRepairer(ctx context.Context, index int, identity *iden rollupsWriteCache := orders.NewRollupsWriteCache(log.Named("orders-write-cache"), db.Orders(), config.Orders.FlushBatchSize) planet.databases = append(planet.databases, rollupsWriteCacheCloser{rollupsWriteCache}) - return satellite.NewRepairer(log, identity, metabaseDB, revocationDB, db.RepairQueue(), db.Buckets(), db.OverlayCache(), db.Reputation(), db.Containment(), rollupsWriteCache, versionInfo, &config, nil) + return satellite.NewRepairer(log, identity, metabaseDB, revocationDB, db.RepairQueue(), db.Buckets(), db.OverlayCache(), db.NodeEvents(), db.Reputation(), db.Containment(), rollupsWriteCache, versionInfo, &config, nil) } type rollupsWriteCacheCloser struct { diff --git a/satellite/api.go b/satellite/api.go index 361443ab9..84f52de1c 100644 --- a/satellite/api.go +++ b/satellite/api.go @@ -291,7 +291,7 @@ func NewAPI(log *zap.Logger, full *identity.FullIdentity, db DB, { // setup overlay peer.Overlay.DB = peer.DB.OverlayCache() - peer.Overlay.Service, err = overlay.NewService(peer.Log.Named("overlay"), peer.Overlay.DB, peer.Mail.Service, config.Console.ExternalAddress, config.Console.SatelliteName, config.Overlay) + peer.Overlay.Service, err = overlay.NewService(peer.Log.Named("overlay"), peer.Overlay.DB, peer.DB.NodeEvents(), peer.Mail.Service, config.Console.ExternalAddress, config.Console.SatelliteName, config.Overlay) if err != nil { return nil, errs.Combine(err, peer.Close()) } diff --git a/satellite/core.go b/satellite/core.go index f9d47c109..4258123e7 100644 --- a/satellite/core.go +++ b/satellite/core.go @@ -252,7 +252,7 @@ func New(log *zap.Logger, full *identity.FullIdentity, db DB, { // setup overlay peer.Overlay.DB = peer.DB.OverlayCache() - peer.Overlay.Service, err = overlay.NewService(peer.Log.Named("overlay"), peer.Overlay.DB, peer.Mail.Service, config.Console.ExternalAddress, config.Console.SatelliteName, config.Overlay) + peer.Overlay.Service, err = overlay.NewService(peer.Log.Named("overlay"), peer.Overlay.DB, peer.DB.NodeEvents(), peer.Mail.Service, config.Console.ExternalAddress, config.Console.SatelliteName, config.Overlay) if err != nil { return nil, errs.Combine(err, peer.Close()) } diff --git a/satellite/overlay/benchmark_test.go b/satellite/overlay/benchmark_test.go index 9a95c4bd2..fe42470df 100644 --- a/satellite/overlay/benchmark_test.go +++ b/satellite/overlay/benchmark_test.go @@ -359,7 +359,7 @@ func BenchmarkNodeSelection(b *testing.B) { } }) - service, err := overlay.NewService(zap.NewNop(), overlaydb, nil, "", "", overlay.Config{ + service, err := overlay.NewService(zap.NewNop(), overlaydb, db.NodeEvents(), nil, "", "", overlay.Config{ Node: nodeSelectionConfig, NodeSelectionCache: overlay.UploadSelectionCacheConfig{ Staleness: time.Hour, diff --git a/satellite/overlay/service.go b/satellite/overlay/service.go index 6af746b0f..785726abe 100644 --- a/satellite/overlay/service.go +++ b/satellite/overlay/service.go @@ -20,6 +20,7 @@ import ( "storj.io/storj/satellite/geoip" "storj.io/storj/satellite/mailservice" "storj.io/storj/satellite/metabase" + "storj.io/storj/satellite/nodeevents" ) // ErrEmptyNode is returned when the nodeID is empty. @@ -293,6 +294,7 @@ func (node *SelectedNode) Clone() *SelectedNode { type Service struct { log *zap.Logger db DB + nodeEvents nodeevents.DB mail *mailservice.Service satelliteName string satelliteAddress string @@ -304,7 +306,7 @@ type Service struct { } // NewService returns a new Service. -func NewService(log *zap.Logger, db DB, mailService *mailservice.Service, satelliteAddr, satelliteName string, config Config) (*Service, error) { +func NewService(log *zap.Logger, db DB, nodeEvents nodeevents.DB, mailService *mailservice.Service, satelliteAddr, satelliteName string, config Config) (*Service, error) { err := config.Node.AsOfSystemTime.isValid() if err != nil { return nil, errs.Wrap(err) @@ -336,6 +338,7 @@ func NewService(log *zap.Logger, db DB, mailService *mailservice.Service, satell return &Service{ log: log, db: db, + nodeEvents: nodeEvents, mail: mailService, satelliteAddress: satelliteAddr, satelliteName: satelliteName, diff --git a/satellite/overlay/service_test.go b/satellite/overlay/service_test.go index f34cc0075..da8c8f08d 100644 --- a/satellite/overlay/service_test.go +++ b/satellite/overlay/service_test.go @@ -25,6 +25,7 @@ import ( "storj.io/storj/private/testplanet" "storj.io/storj/satellite" "storj.io/storj/satellite/console/consoleweb/consoleapi" + "storj.io/storj/satellite/nodeevents" "storj.io/storj/satellite/overlay" "storj.io/storj/satellite/reputation" "storj.io/storj/satellite/satellitedb/satellitedbtest" @@ -34,7 +35,7 @@ func TestCache_Database(t *testing.T) { t.Parallel() satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) { - testCache(ctx, t, db.OverlayCache()) + testCache(ctx, t, db.OverlayCache(), db.NodeEvents()) }) } @@ -57,7 +58,7 @@ func testAuditHistoryConfig() reputation.AuditHistoryConfig { } } -func testCache(ctx *testcontext.Context, t *testing.T, store overlay.DB) { +func testCache(ctx *testcontext.Context, t *testing.T, store overlay.DB, nodeEvents nodeevents.DB) { valid1ID := testrand.NodeID() valid2ID := testrand.NodeID() valid3ID := testrand.NodeID() @@ -76,7 +77,7 @@ func testCache(ctx *testcontext.Context, t *testing.T, store overlay.DB) { serviceCtx, serviceCancel := context.WithCancel(ctx) defer serviceCancel() - service, err := overlay.NewService(zaptest.NewLogger(t), store, nil, "", "", serviceConfig) + service, err := overlay.NewService(zaptest.NewLogger(t), store, nodeEvents, nil, "", "", serviceConfig) require.NoError(t, err) ctx.Go(func() error { return service.Run(serviceCtx) }) defer ctx.Check(service.Close) diff --git a/satellite/repair/checker/online_test.go b/satellite/repair/checker/online_test.go index 2a914c067..f92ba9ca8 100644 --- a/satellite/repair/checker/online_test.go +++ b/satellite/repair/checker/online_test.go @@ -16,6 +16,7 @@ import ( "storj.io/common/testcontext" "storj.io/common/testrand" "storj.io/storj/satellite/metabase" + "storj.io/storj/satellite/nodeevents" "storj.io/storj/satellite/overlay" ) @@ -23,7 +24,7 @@ func TestReliabilityCache_Concurrent(t *testing.T) { ctx := testcontext.New(t) defer ctx.Cleanup() - overlayCache, err := overlay.NewService(zap.NewNop(), fakeOverlayDB{}, nil, "", "", overlay.Config{ + overlayCache, err := overlay.NewService(zap.NewNop(), fakeOverlayDB{}, fakeNodeEvents{}, nil, "", "", overlay.Config{ NodeSelectionCache: overlay.UploadSelectionCacheConfig{ Staleness: 2 * time.Nanosecond, }, @@ -52,6 +53,7 @@ func TestReliabilityCache_Concurrent(t *testing.T) { } type fakeOverlayDB struct{ overlay.DB } +type fakeNodeEvents struct{ nodeevents.DB } func (fakeOverlayDB) Reliable(context.Context, *overlay.NodeCriteria) (storj.NodeIDList, error) { return storj.NodeIDList{ diff --git a/satellite/repairer.go b/satellite/repairer.go index e0080b89b..84a1b635f 100644 --- a/satellite/repairer.go +++ b/satellite/repairer.go @@ -28,6 +28,7 @@ import ( "storj.io/storj/satellite/buckets" "storj.io/storj/satellite/mailservice" "storj.io/storj/satellite/metabase" + "storj.io/storj/satellite/nodeevents" "storj.io/storj/satellite/orders" "storj.io/storj/satellite/overlay" "storj.io/storj/satellite/repair/queue" @@ -82,6 +83,7 @@ func NewRepairer(log *zap.Logger, full *identity.FullIdentity, repairQueue queue.RepairQueue, bucketsDB buckets.DB, overlayCache overlay.DB, + nodeEvents nodeevents.DB, reputationdb reputation.DB, containmentDB audit.Containment, rollupsWriteCache *orders.RollupsWriteCache, @@ -156,7 +158,7 @@ func NewRepairer(log *zap.Logger, full *identity.FullIdentity, { // setup overlay var err error - peer.Overlay, err = overlay.NewService(log.Named("overlay"), overlayCache, peer.Mail, config.Console.ExternalAddress, config.Console.SatelliteName, config.Overlay) + peer.Overlay, err = overlay.NewService(log.Named("overlay"), overlayCache, nodeEvents, peer.Mail, config.Console.ExternalAddress, config.Console.SatelliteName, config.Overlay) if err != nil { return nil, errs.Combine(err, peer.Close()) }