diff --git a/dot/network/config.go b/dot/network/config.go index c041b91138..1fd041e018 100644 --- a/dot/network/config.go +++ b/dot/network/config.go @@ -66,7 +66,7 @@ type Config struct { // Service interfaces BlockState BlockState Syncer Syncer - warpSyncHandler WarpSyncRequestHandler + warpSyncProvider WarpSyncProvider TransactionHandler TransactionHandler // Used to specify the address broadcasted to other peers, and avoids using pubip.Get diff --git a/dot/network/service.go b/dot/network/service.go index 3e6d32eca3..61c29f55f1 100644 --- a/dot/network/service.go +++ b/dot/network/service.go @@ -130,7 +130,7 @@ type Service struct { blockState BlockState syncer Syncer transactionHandler TransactionHandler - warpSyncHandler WarpSyncRequestHandler + warpSyncProvider WarpSyncProvider // Configuration options noBootstrap bool @@ -217,7 +217,7 @@ func NewService(cfg *Config) (*Service, error) { noBootstrap: cfg.NoBootstrap, noMDNS: cfg.NoMDNS, syncer: cfg.Syncer, - warpSyncHandler: cfg.warpSyncHandler, + warpSyncProvider: cfg.warpSyncProvider, notificationsProtocols: make(map[MessageType]*notificationsProtocol), lightRequest: make(map[peer.ID]struct{}), telemetryInterval: cfg.telemetryInterval, diff --git a/dot/network/warp_sync.go b/dot/network/warp_sync.go index 4ff277c6cb..8ae45c3e01 100644 --- a/dot/network/warp_sync.go +++ b/dot/network/warp_sync.go @@ -13,13 +13,9 @@ type WarpSyncProvider interface { generate(start common.Hash) (encodedProof []byte, err error) } -type WarpSyncRequestHandler struct { - backend WarpSyncProvider -} - -func (w *WarpSyncRequestHandler) handleRequest(req messages.WarpProofRequest) ([]byte, error) { +func (s *Service) handleWarpSyncRequest(req messages.WarpProofRequest) ([]byte, error) { // use the backend to generate the warp proof - proof, err := w.backend.generate(req.Begin) + proof, err := s.warpSyncProvider.generate(req.Begin) if err != nil { return nil, err } @@ -54,7 +50,7 @@ func (s *Service) handleWarpSyncMessage(stream libp2pnetwork.Stream, msg message }() if req, ok := msg.(*messages.WarpProofRequest); ok { - resp, err := s.warpSyncHandler.handleRequest(*req) + resp, err := s.handleWarpSyncRequest(*req) if err != nil { logger.Debugf("cannot create response for request: %s", err) return nil