From d30df5a6fd353d86cc344dbfb58c0fd2d11d9a80 Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Mon, 28 Jun 2021 09:28:59 +0200 Subject: [PATCH] Fix hash & start moving to lifecycle Fix typeddata has and start moving from the legacy geth services interfaces to the new Lifecycle interface --- services/nodebridge/node_service.go | 10 +++--- services/nodebridge/waku_service.go | 8 ++--- services/nodebridge/whisper_service.go | 45 -------------------------- services/peer/service.go | 6 ++-- services/typeddata/hash.go | 6 ++-- 5 files changed, 15 insertions(+), 60 deletions(-) delete mode 100644 services/nodebridge/whisper_service.go diff --git a/services/nodebridge/node_service.go b/services/nodebridge/node_service.go index b8ef9e791..dad4849f3 100644 --- a/services/nodebridge/node_service.go +++ b/services/nodebridge/node_service.go @@ -8,8 +8,8 @@ import ( "github.com/status-im/status-go/eth-node/types" ) -// Make sure that NodeService implements node.Service interface. -var _ node.Service = (*NodeService)(nil) +// Make sure that NodeService implements node.Lifecycle interface. +var _ node.Lifecycle = (*NodeService)(nil) type NodeService struct { Node types.Node @@ -33,13 +33,13 @@ func (w *NodeService) APIs() []rpc.API { } // Start is run when a service is started. -// It does nothing in this case but is required by `node.Service` interface. -func (w *NodeService) Start(server *p2p.Server) error { +// It does nothing in this case but is required by `node.Lifecycle` interface. +func (w *NodeService) Start() error { return nil } // Stop is run when a service is stopped. -// It does nothing in this case but is required by `node.Service` interface. +// It does nothing in this case but is required by `node.Lifecycle` interface. func (w *NodeService) Stop() error { return nil } diff --git a/services/nodebridge/waku_service.go b/services/nodebridge/waku_service.go index a6a80b49e..a1fcd979a 100644 --- a/services/nodebridge/waku_service.go +++ b/services/nodebridge/waku_service.go @@ -8,8 +8,8 @@ import ( "github.com/status-im/status-go/eth-node/types" ) -// Make sure that WakuService implements node.Service interface. -var _ node.Service = (*WakuService)(nil) +// Make sure that WakuService implements node.Lifecycle interface. +var _ node.Lifecycle = (*WakuService)(nil) type WakuService struct { Waku types.Waku @@ -33,8 +33,8 @@ func (w *WakuService) APIs() []rpc.API { } // Start is run when a service is started. -// It does nothing in this case but is required by `node.Service` interface. -func (w *WakuService) Start(server *p2p.Server) error { +// It does nothing in this case but is required by `node.Lifecycle` interface. +func (w *WakuService) Start() error { return nil } diff --git a/services/nodebridge/whisper_service.go b/services/nodebridge/whisper_service.go deleted file mode 100644 index 5527c3172..000000000 --- a/services/nodebridge/whisper_service.go +++ /dev/null @@ -1,45 +0,0 @@ -package nodebridge - -import ( - "github.com/ethereum/go-ethereum/node" - "github.com/ethereum/go-ethereum/p2p" - "github.com/ethereum/go-ethereum/rpc" - - "github.com/status-im/status-go/eth-node/types" -) - -// Make sure that WhisperService implements node.Service interface. -var _ node.Service = (*WhisperService)(nil) - -type WhisperService struct { - Whisper types.Whisper -} - -// Protocols returns a new protocols list. In this case, there are none. -func (w *WhisperService) Protocols() []p2p.Protocol { - return []p2p.Protocol{} -} - -// APIs returns a list of new APIs. -func (w *WhisperService) APIs() []rpc.API { - return []rpc.API{ - { - Namespace: "status", - Version: "1.0", - Service: w.Whisper, - Public: false, - }, - } -} - -// Start is run when a service is started. -// It does nothing in this case but is required by `node.Service` interface. -func (w *WhisperService) Start(server *p2p.Server) error { - return nil -} - -// Stop is run when a service is stopped. -// It does nothing in this case but is required by `node.Service` interface. -func (w *WhisperService) Stop() error { - return nil -} diff --git a/services/peer/service.go b/services/peer/service.go index 89dc35eee..49d83cc0f 100644 --- a/services/peer/service.go +++ b/services/peer/service.go @@ -6,8 +6,8 @@ import ( "github.com/ethereum/go-ethereum/rpc" ) -// Make sure that Service implements node.Service interface. -var _ node.Service = (*Service)(nil) +// Make sure that Service implements node.Lifecycle interface. +var _ node.Lifecycle = (*Service)(nil) // Discoverer manages peer discovery. type Discoverer interface { @@ -48,7 +48,7 @@ func (s *Service) SetDiscoverer(d Discoverer) { // Start is run when a service is started. // It does nothing in this case but is required by `node.Service` interface. -func (s *Service) Start(server *p2p.Server) error { +func (s *Service) Start() error { return nil } diff --git a/services/typeddata/hash.go b/services/typeddata/hash.go index fe9b0f53e..4f8787c11 100644 --- a/services/typeddata/hash.go +++ b/services/typeddata/hash.go @@ -15,8 +15,8 @@ import ( ) var ( - bytes32Type, _ = abi.NewType("bytes32", nil) - int256Type, _ = abi.NewType("int256", nil) + bytes32Type, _ = abi.NewType("bytes32", "", nil) + int256Type, _ = abi.NewType("int256", "", nil) errNotInteger = errors.New("not an integer") ) @@ -137,7 +137,7 @@ func toABITypeAndValue(f Field, data map[string]json.RawMessage, types Types) (v } func atomicType(f Field, data map[string]json.RawMessage) (val interface{}, typ abi.Type, err error) { - typ, err = abi.NewType(f.Type, nil) + typ, err = abi.NewType(f.Type, "", nil) if err != nil { return }