Remove unused service fields (#2139)

This commit is contained in:
terence tsao 2019-04-03 07:59:18 -07:00 committed by GitHub
parent 89531c1667
commit fa063c85ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 47 deletions

View File

@ -29,13 +29,11 @@ type attestationStore struct {
// Service represents a service that handles the internal
// logic of managing single and aggregated attestation.
type Service struct {
ctx context.Context
cancel context.CancelFunc
beaconDB *db.BeaconDB
broadcastFeed *event.Feed
broadcastChan chan *pb.Attestation
incomingFeed *event.Feed
incomingChan chan *pb.Attestation
ctx context.Context
cancel context.CancelFunc
beaconDB *db.BeaconDB
incomingFeed *event.Feed
incomingChan chan *pb.Attestation
// store is the mapping of individual
// validator's public key to it's latest attestation.
store attestationStore
@ -51,14 +49,12 @@ type Config struct {
func NewAttestationService(ctx context.Context, cfg *Config) *Service {
ctx, cancel := context.WithCancel(ctx)
return &Service{
ctx: ctx,
cancel: cancel,
beaconDB: cfg.BeaconDB,
broadcastFeed: new(event.Feed),
broadcastChan: make(chan *pb.Attestation, params.BeaconConfig().DefaultBufferSize),
incomingFeed: new(event.Feed),
incomingChan: make(chan *pb.Attestation, params.BeaconConfig().DefaultBufferSize),
store: attestationStore{m: make(map[[48]byte]*pb.Attestation)},
ctx: ctx,
cancel: cancel,
beaconDB: cfg.BeaconDB,
incomingFeed: new(event.Feed),
incomingChan: make(chan *pb.Attestation, params.BeaconConfig().DefaultBufferSize),
store: attestationStore{m: make(map[[48]byte]*pb.Attestation)},
}
}

View File

@ -17,7 +17,6 @@ import (
"github.com/prysmaticlabs/prysm/shared/event"
"github.com/prysmaticlabs/prysm/shared/hashutil"
"github.com/prysmaticlabs/prysm/shared/p2p"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/sirupsen/logrus"
"go.opencensus.io/trace"
)
@ -40,7 +39,6 @@ type ChainService struct {
attsService *attestation.Service
opsPoolService operations.OperationFeeds
chainStartChan chan time.Time
canonicalBlockChan chan *pb.BeaconBlock
canonicalBlockFeed *event.Feed
genesisTime time.Time
finalizedEpoch uint64
@ -71,7 +69,6 @@ func NewChainService(ctx context.Context, cfg *Config) (*ChainService, error) {
opsPoolService: cfg.OpsPoolService,
attsService: cfg.AttsService,
canonicalBlockFeed: new(event.Feed),
canonicalBlockChan: make(chan *pb.BeaconBlock, params.BeaconConfig().DefaultBufferSize),
chainStartChan: make(chan time.Time),
stateInitializedFeed: new(event.Feed),
p2p: cfg.P2p,

View File

@ -57,22 +57,20 @@ type powChainService interface {
// Service defining an RPC server for a beacon node.
type Service struct {
ctx context.Context
cancel context.CancelFunc
beaconDB *db.BeaconDB
chainService chainService
powChainService powChainService
operationService operationService
port string
listener net.Listener
withCert string
withKey string
grpcServer *grpc.Server
canonicalBlockChan chan *pbp2p.BeaconBlock
canonicalStateChan chan *pbp2p.BeaconState
incomingAttestation chan *pbp2p.Attestation
slotAlignmentDuration time.Duration
credentialError error
ctx context.Context
cancel context.CancelFunc
beaconDB *db.BeaconDB
chainService chainService
powChainService powChainService
operationService operationService
port string
listener net.Listener
withCert string
withKey string
grpcServer *grpc.Server
canonicalStateChan chan *pbp2p.BeaconState
incomingAttestation chan *pbp2p.Attestation
credentialError error
}
// Config options for the beacon node RPC server.
@ -91,19 +89,17 @@ type Config struct {
func NewRPCService(ctx context.Context, cfg *Config) *Service {
ctx, cancel := context.WithCancel(ctx)
return &Service{
ctx: ctx,
cancel: cancel,
beaconDB: cfg.BeaconDB,
chainService: cfg.ChainService,
powChainService: cfg.POWChainService,
operationService: cfg.OperationService,
port: cfg.Port,
withCert: cfg.CertFlag,
withKey: cfg.KeyFlag,
slotAlignmentDuration: time.Duration(params.BeaconConfig().SecondsPerSlot) * time.Second,
canonicalBlockChan: make(chan *pbp2p.BeaconBlock, params.BeaconConfig().DefaultBufferSize),
canonicalStateChan: make(chan *pbp2p.BeaconState, params.BeaconConfig().DefaultBufferSize),
incomingAttestation: make(chan *pbp2p.Attestation, params.BeaconConfig().DefaultBufferSize),
ctx: ctx,
cancel: cancel,
beaconDB: cfg.BeaconDB,
chainService: cfg.ChainService,
powChainService: cfg.POWChainService,
operationService: cfg.OperationService,
port: cfg.Port,
withCert: cfg.CertFlag,
withKey: cfg.KeyFlag,
canonicalStateChan: make(chan *pbp2p.BeaconState, params.BeaconConfig().DefaultBufferSize),
incomingAttestation: make(chan *pbp2p.Attestation, params.BeaconConfig().DefaultBufferSize),
}
}