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
|
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{
|
peer.Services.Add(lifecycle.Item{
|
||||||
Name: "reputation",
|
Name: "reputation",
|
||||||
Close: peer.Reputation.Service.Close,
|
Close: peer.Reputation.Service.Close,
|
||||||
|
@ -343,7 +343,7 @@ func New(log *zap.Logger, full *identity.FullIdentity, db DB,
|
|||||||
reputationDB = cachingDB
|
reputationDB = cachingDB
|
||||||
}
|
}
|
||||||
peer.Reputation.Service = reputation.NewService(log.Named("reputation:service"),
|
peer.Reputation.Service = reputation.NewService(log.Named("reputation:service"),
|
||||||
peer.Overlay.DB,
|
peer.Overlay.Service,
|
||||||
reputationDB,
|
reputationDB,
|
||||||
config.Reputation,
|
config.Reputation,
|
||||||
)
|
)
|
||||||
|
@ -177,7 +177,7 @@ func NewRepairer(log *zap.Logger, full *identity.FullIdentity,
|
|||||||
reputationdb = cachingDB
|
reputationdb = cachingDB
|
||||||
}
|
}
|
||||||
peer.Reputation = reputation.NewService(log.Named("reputation:service"),
|
peer.Reputation = reputation.NewService(log.Named("reputation:service"),
|
||||||
overlayCache,
|
peer.Overlay,
|
||||||
reputationdb,
|
reputationdb,
|
||||||
config.Reputation,
|
config.Reputation,
|
||||||
)
|
)
|
||||||
|
@ -85,13 +85,13 @@ type Mutations struct {
|
|||||||
// the overlay cache when a node's status changes.
|
// the overlay cache when a node's status changes.
|
||||||
type Service struct {
|
type Service struct {
|
||||||
log *zap.Logger
|
log *zap.Logger
|
||||||
overlay overlay.DB
|
overlay *overlay.Service
|
||||||
db DB
|
db DB
|
||||||
config Config
|
config Config
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewService creates a new reputation service.
|
// 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{
|
return &Service{
|
||||||
log: log,
|
log: log,
|
||||||
overlay: overlay,
|
overlay: overlay,
|
||||||
@ -170,7 +170,21 @@ func (service *Service) TestSuspendNodeUnknownAudit(ctx context.Context, nodeID
|
|||||||
return err
|
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.
|
// TestDisqualifyNode disqualifies a storage node.
|
||||||
@ -182,7 +196,7 @@ func (service *Service) TestDisqualifyNode(ctx context.Context, nodeID storj.Nod
|
|||||||
return err
|
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.
|
// TestUnsuspendNodeUnknownAudit unsuspends a storage node for unknown audits.
|
||||||
@ -192,7 +206,21 @@ func (service *Service) TestUnsuspendNodeUnknownAudit(ctx context.Context, nodeI
|
|||||||
return err
|
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
|
// TestFlushAllNodeInfo flushes any and all cached information about all
|
||||||
|
Loading…
Reference in New Issue
Block a user