sdatellite/reputation: add overlay service to reputation service
Change-Id: I7b1af819f9e1989578335247730378a8658bfe7f
This commit is contained in:
parent
08052b38bd
commit
4be042154c
@ -307,7 +307,7 @@ func NewAPI(log *zap.Logger, full *identity.FullIdentity, db DB,
|
||||
})
|
||||
reputationDB = cachingDB
|
||||
}
|
||||
peer.Reputation.Service = reputation.NewService(peer.Log.Named("reputation"), peer.Overlay.DB, reputationDB, config.Reputation)
|
||||
peer.Reputation.Service = reputation.NewService(peer.Log.Named("reputation"), peer.Overlay.Service, reputationDB, config.Reputation)
|
||||
peer.Services.Add(lifecycle.Item{
|
||||
Name: "reputation",
|
||||
Close: peer.Reputation.Service.Close,
|
||||
|
@ -343,7 +343,7 @@ func New(log *zap.Logger, full *identity.FullIdentity, db DB,
|
||||
reputationDB = cachingDB
|
||||
}
|
||||
peer.Reputation.Service = reputation.NewService(log.Named("reputation:service"),
|
||||
peer.Overlay.DB,
|
||||
peer.Overlay.Service,
|
||||
reputationDB,
|
||||
config.Reputation,
|
||||
)
|
||||
|
@ -177,7 +177,7 @@ func NewRepairer(log *zap.Logger, full *identity.FullIdentity,
|
||||
reputationdb = cachingDB
|
||||
}
|
||||
peer.Reputation = reputation.NewService(log.Named("reputation:service"),
|
||||
overlayCache,
|
||||
peer.Overlay,
|
||||
reputationdb,
|
||||
config.Reputation,
|
||||
)
|
||||
|
@ -85,13 +85,13 @@ type Mutations struct {
|
||||
// the overlay cache when a node's status changes.
|
||||
type Service struct {
|
||||
log *zap.Logger
|
||||
overlay overlay.DB
|
||||
overlay *overlay.Service
|
||||
db DB
|
||||
config Config
|
||||
}
|
||||
|
||||
// NewService creates a new reputation service.
|
||||
func NewService(log *zap.Logger, overlay overlay.DB, db DB, config Config) *Service {
|
||||
func NewService(log *zap.Logger, overlay *overlay.Service, db DB, config Config) *Service {
|
||||
return &Service{
|
||||
log: log,
|
||||
overlay: overlay,
|
||||
@ -170,7 +170,21 @@ func (service *Service) TestSuspendNodeUnknownAudit(ctx context.Context, nodeID
|
||||
return err
|
||||
}
|
||||
|
||||
return service.overlay.TestSuspendNodeUnknownAudit(ctx, nodeID, suspendedAt)
|
||||
n, err := service.overlay.Get(ctx, nodeID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
update := overlay.ReputationUpdate{
|
||||
Disqualified: n.Disqualified,
|
||||
UnknownAuditSuspended: &suspendedAt,
|
||||
OfflineSuspended: n.OfflineSuspended,
|
||||
VettedAt: n.Reputation.Status.VettedAt,
|
||||
}
|
||||
if n.DisqualificationReason != nil {
|
||||
update.DisqualificationReason = *n.DisqualificationReason
|
||||
}
|
||||
return service.overlay.UpdateReputation(ctx, nodeID, update)
|
||||
}
|
||||
|
||||
// TestDisqualifyNode disqualifies a storage node.
|
||||
@ -182,7 +196,7 @@ func (service *Service) TestDisqualifyNode(ctx context.Context, nodeID storj.Nod
|
||||
return err
|
||||
}
|
||||
|
||||
return service.overlay.DisqualifyNode(ctx, nodeID, disqualifiedAt, reason)
|
||||
return service.overlay.DisqualifyNode(ctx, nodeID, reason)
|
||||
}
|
||||
|
||||
// TestUnsuspendNodeUnknownAudit unsuspends a storage node for unknown audits.
|
||||
@ -192,7 +206,21 @@ func (service *Service) TestUnsuspendNodeUnknownAudit(ctx context.Context, nodeI
|
||||
return err
|
||||
}
|
||||
|
||||
return service.overlay.TestUnsuspendNodeUnknownAudit(ctx, nodeID)
|
||||
n, err := service.overlay.Get(ctx, nodeID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
update := overlay.ReputationUpdate{
|
||||
Disqualified: n.Disqualified,
|
||||
UnknownAuditSuspended: nil,
|
||||
OfflineSuspended: n.OfflineSuspended,
|
||||
VettedAt: n.Reputation.Status.VettedAt,
|
||||
}
|
||||
if n.DisqualificationReason != nil {
|
||||
update.DisqualificationReason = *n.DisqualificationReason
|
||||
}
|
||||
return service.overlay.UpdateReputation(ctx, nodeID, update)
|
||||
}
|
||||
|
||||
// TestFlushAllNodeInfo flushes any and all cached information about all
|
||||
|
Loading…
Reference in New Issue
Block a user