remove kademlia from vouchers package (#2589)

* remove kademlia from vouchers package
This commit is contained in:
Cameron 2019-07-18 10:09:25 -04:00 committed by GitHub
parent 8fb70aed11
commit 848eb8c02f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 11 deletions

View File

@ -272,7 +272,7 @@ func New(log *zap.Logger, full *identity.FullIdentity, db DB, config Config, ver
{ // setup vouchers
interval := config.Vouchers.Interval
buffer := interval + time.Hour
peer.Vouchers = vouchers.NewService(peer.Log.Named("vouchers"), peer.Kademlia.Service, peer.Transport, peer.DB.Vouchers(),
peer.Vouchers = vouchers.NewService(peer.Log.Named("vouchers"), peer.Transport, peer.DB.Vouchers(),
peer.Storage2.Trust, interval, buffer)
}

View File

@ -13,7 +13,6 @@ import (
monkit "gopkg.in/spacemonkeygo/monkit.v2"
"storj.io/storj/internal/sync2"
"storj.io/storj/pkg/kademlia"
"storj.io/storj/pkg/pb"
"storj.io/storj/pkg/storj"
"storj.io/storj/pkg/transport"
@ -46,7 +45,6 @@ type Config struct {
type Service struct {
log *zap.Logger
kademlia *kademlia.Kademlia
transport transport.Client
vouchersdb DB
@ -58,10 +56,9 @@ type Service struct {
}
// NewService creates a new voucher service
func NewService(log *zap.Logger, kad *kademlia.Kademlia, transport transport.Client, vouchersdb DB, trust *trust.Pool, interval, expirationBuffer time.Duration) *Service {
func NewService(log *zap.Logger, transport transport.Client, vouchersdb DB, trust *trust.Pool, interval, expirationBuffer time.Duration) *Service {
return &Service{
log: log,
kademlia: kad,
transport: transport,
vouchersdb: vouchersdb,
trust: trust,
@ -122,12 +119,17 @@ func (service *Service) Request(ctx context.Context, satelliteID storj.NodeID) {
func (service *Service) request(ctx context.Context, satelliteID storj.NodeID) (err error) {
defer mon.Task()(&ctx)(&err)
satellite, err := service.kademlia.FindNode(ctx, satelliteID)
address, err := service.trust.GetAddress(ctx, satelliteID)
if err != nil {
return VoucherError.New("unable to find satellite on the network: %v", err)
return err
}
conn, err := service.transport.DialNode(ctx, &satellite)
conn, err := service.transport.DialNode(ctx, &pb.Node{
Id: satelliteID,
Address: &pb.NodeAddress{
Transport: pb.NodeTransport_TCP_TLS_GRPC,
Address: address,
},
})
if err != nil {
return VoucherError.New("unable to connect to the satellite: %v", err)
}
@ -142,7 +144,6 @@ func (service *Service) request(ctx context.Context, satelliteID storj.NodeID) (
return VoucherError.New("failed to start request: %v", err)
}
// TODO: separate status for disqualified nodes?
switch resp.GetStatus() {
case pb.VoucherResponse_REJECTED:
service.log.Info("Voucher request denied. Vetting process not yet complete")

View File

@ -24,7 +24,7 @@ var (
func (service *Service) VerifyVoucher(ctx context.Context, satellite storj.NodeID, voucher *pb.Voucher) (err error) {
defer mon.Task()(&ctx)(&err)
if self := service.kademlia.Local().Id; voucher.StorageNodeId != self {
if self := service.transport.Identity().ID; voucher.StorageNodeId != self {
return ErrVerify.New("Storage node ID does not match expected: (%v) (%v)", voucher.StorageNodeId, self)
}