Fix unstarted pointerdb responsibility (#1033)

This commit is contained in:
Michal Niewrzal 2019-01-11 13:45:11 +01:00 committed by GitHub
parent 8893884044
commit e13f7c7a7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 5 deletions

View File

@ -85,10 +85,10 @@ func cmdRun(cmd *cobra.Command, args []string) (err error) {
errch <- satellite.Server.Run(satelliteCtx,
grpcauth.NewAPIKeyInterceptor(),
satellite.Kademlia,
satellite.Audit,
satellite.Overlay,
satellite.Discovery,
satellite.PointerDB,
satellite.Audit,
satellite.Checker,
satellite.Repairer,
satellite.BwAgreement,

View File

@ -25,7 +25,13 @@ type Config struct {
// Initialize a tally struct
func (c Config) initialize(ctx context.Context) (Tally, error) {
pointerdb := pointerdb.LoadFromContext(ctx)
if pointerdb == nil {
return nil, Error.New("programmer error: pointerdb responsibility unstarted")
}
overlay := overlay.LoadServerFromContext(ctx)
if overlay == nil {
return nil, Error.New("programmer error: overlay responsibility unstarted")
}
db, ok := ctx.Value("masterdb").(interface {
BandwidthAgreement() bwagreement.DB
Accounting() accounting.DB

View File

@ -36,9 +36,10 @@ type Config struct {
func (c Config) Run(ctx context.Context, server *provider.Provider) (err error) {
identity := server.Identity()
pointers := pointerdb.LoadFromContext(ctx)
if err != nil {
return err
if pointers == nil {
return Error.New("programmer error: pointerdb responsibility unstarted")
}
overlay, err := overlay.NewClient(identity, c.SatelliteAddr)
if err != nil {
return err

View File

@ -32,8 +32,14 @@ type Config struct {
func (c Config) Run(ctx context.Context, server *provider.Provider) (err error) {
defer mon.Task()(&ctx)(&err)
ol := overlay.LoadFromContext(ctx)
overlay := overlay.LoadFromContext(ctx)
if overlay == nil {
return Error.New("programmer error: overlay responsibility unstarted")
}
kad := kademlia.LoadFromContext(ctx)
if kad == nil {
return Error.New("programmer error: kademlia responsibility unstarted")
}
stat, ok := ctx.Value("masterdb").(interface {
StatDB() statdb.DB
})
@ -42,7 +48,7 @@ func (c Config) Run(ctx context.Context, server *provider.Provider) (err error)
return Error.New("unable to get master db instance")
}
discovery := NewDiscovery(zap.L().Named("discovery"), ol, kad, stat.StatDB())
discovery := NewDiscovery(zap.L().Named("discovery"), overlay, kad, stat.StatDB())
zap.L().Debug("Starting discovery")