2018-11-01 16:51:19 +00:00
|
|
|
// Copyright (C) 2018 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2018-11-05 15:23:54 +00:00
|
|
|
package bwagreement
|
2018-11-01 16:51:19 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2018-11-15 19:06:09 +00:00
|
|
|
"github.com/zeebo/errs"
|
2018-11-01 16:51:19 +00:00
|
|
|
"go.uber.org/zap"
|
|
|
|
monkit "gopkg.in/spacemonkeygo/monkit.v2"
|
2018-11-15 18:36:57 +00:00
|
|
|
|
2018-11-01 16:51:19 +00:00
|
|
|
"storj.io/storj/pkg/pb"
|
|
|
|
"storj.io/storj/pkg/provider"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
mon = monkit.Package()
|
|
|
|
)
|
|
|
|
|
|
|
|
// Config is a configuration struct that is everything you need to start an
|
|
|
|
// agreement receiver responsibility
|
|
|
|
type Config struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
// Run implements the provider.Responsibility interface
|
|
|
|
func (c Config) Run(ctx context.Context, server *provider.Provider) (err error) {
|
|
|
|
defer mon.Task()(&ctx)(&err)
|
2018-11-12 21:59:30 +00:00
|
|
|
k := server.Identity().Leaf.PublicKey
|
|
|
|
|
2018-11-15 19:06:09 +00:00
|
|
|
zap.S().Debug("Starting Bandwidth Agreement Receiver...")
|
|
|
|
|
2018-12-07 09:59:31 +00:00
|
|
|
db, ok := ctx.Value("masterdb").(interface{ BandwidthAgreement() DB })
|
|
|
|
if !ok {
|
|
|
|
return errs.New("unable to get satellite master db instance")
|
2018-11-15 19:06:09 +00:00
|
|
|
}
|
2018-12-07 09:59:31 +00:00
|
|
|
pb.RegisterBandwidthServer(server.GRPC(), NewServer(db.BandwidthAgreement(), zap.L(), k))
|
2018-11-01 16:51:19 +00:00
|
|
|
|
|
|
|
return server.Run(ctx)
|
|
|
|
}
|