mirror of
https://github.com/status-im/status-go.git
synced 2025-02-19 18:28:18 +00:00
Implement AddPeer/RemovePeer on eth-node
This commit is contained in:
parent
41a6502340
commit
7f11030896
@ -2,6 +2,7 @@ package gethbridge
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
|
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||||
gethens "github.com/status-im/status-go/eth-node/bridge/geth/ens"
|
gethens "github.com/status-im/status-go/eth-node/bridge/geth/ens"
|
||||||
"github.com/status-im/status-go/eth-node/types"
|
"github.com/status-im/status-go/eth-node/types"
|
||||||
enstypes "github.com/status-im/status-go/eth-node/types/ens"
|
enstypes "github.com/status-im/status-go/eth-node/types/ens"
|
||||||
@ -43,3 +44,25 @@ func (w *gethNodeWrapper) GetWhisper(ctx interface{}) (types.Whisper, error) {
|
|||||||
|
|
||||||
return NewGethWhisperWrapper(nativeWhisper), nil
|
return NewGethWhisperWrapper(nativeWhisper), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *gethNodeWrapper) AddPeer(url string) error {
|
||||||
|
parsedNode, err := enode.ParseV4(url)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
w.stack.Server().AddPeer(parsedNode)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *gethNodeWrapper) RemovePeer(url string) error {
|
||||||
|
parsedNode, err := enode.ParseV4(url)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
w.stack.Server().RemovePeer(parsedNode)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -61,3 +61,17 @@ func (w *nimbusNodeWrapper) NewENSVerifier(_ *zap.Logger) enstypes.ENSVerifier {
|
|||||||
func (w *nimbusNodeWrapper) GetWhisper(ctx interface{}) (types.Whisper, error) {
|
func (w *nimbusNodeWrapper) GetWhisper(ctx interface{}) (types.Whisper, error) {
|
||||||
return w.w, nil
|
return w.w, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *nimbusNodeWrapper) AddPeer(url string) error {
|
||||||
|
urlC := C.CString(url)
|
||||||
|
defer C.free(unsafe.Pointer(urlC))
|
||||||
|
if !C.nimbus_add_peer(urlC) {
|
||||||
|
return fmt.Errorf("failed to add peer: %s", url)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *nimbusNodeWrapper) RemovePeer(url string) error {
|
||||||
|
panic("TODO: RemovePeer")
|
||||||
|
}
|
||||||
|
@ -18,4 +18,6 @@ func (n EnodeID) String() string {
|
|||||||
type Node interface {
|
type Node interface {
|
||||||
NewENSVerifier(logger *zap.Logger) enstypes.ENSVerifier
|
NewENSVerifier(logger *zap.Logger) enstypes.ENSVerifier
|
||||||
GetWhisper(ctx interface{}) (Whisper, error)
|
GetWhisper(ctx interface{}) (Whisper, error)
|
||||||
|
AddPeer(url string) error
|
||||||
|
RemovePeer(url string) error
|
||||||
}
|
}
|
||||||
|
@ -401,6 +401,14 @@ func (w *testNodeWrapper) GetWhisper(_ interface{}) (types.Whisper, error) {
|
|||||||
return w.w, nil
|
return w.w, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *testNodeWrapper) AddPeer(url string) error {
|
||||||
|
panic("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *testNodeWrapper) RemovePeer(url string) error {
|
||||||
|
panic("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
type WhisperNodeMockSuite struct {
|
type WhisperNodeMockSuite struct {
|
||||||
suite.Suite
|
suite.Suite
|
||||||
|
|
||||||
|
23
vendor/github.com/status-im/status-go/eth-node/bridge/geth/node.go
generated
vendored
23
vendor/github.com/status-im/status-go/eth-node/bridge/geth/node.go
generated
vendored
@ -2,6 +2,7 @@ package gethbridge
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
|
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||||
gethens "github.com/status-im/status-go/eth-node/bridge/geth/ens"
|
gethens "github.com/status-im/status-go/eth-node/bridge/geth/ens"
|
||||||
"github.com/status-im/status-go/eth-node/types"
|
"github.com/status-im/status-go/eth-node/types"
|
||||||
enstypes "github.com/status-im/status-go/eth-node/types/ens"
|
enstypes "github.com/status-im/status-go/eth-node/types/ens"
|
||||||
@ -43,3 +44,25 @@ func (w *gethNodeWrapper) GetWhisper(ctx interface{}) (types.Whisper, error) {
|
|||||||
|
|
||||||
return NewGethWhisperWrapper(nativeWhisper), nil
|
return NewGethWhisperWrapper(nativeWhisper), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *gethNodeWrapper) AddPeer(url string) error {
|
||||||
|
parsedNode, err := enode.ParseV4(url)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
w.stack.Server().AddPeer(parsedNode)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *gethNodeWrapper) RemovePeer(url string) error {
|
||||||
|
parsedNode, err := enode.ParseV4(url)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
w.stack.Server().RemovePeer(parsedNode)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
2
vendor/github.com/status-im/status-go/eth-node/types/node.go
generated
vendored
2
vendor/github.com/status-im/status-go/eth-node/types/node.go
generated
vendored
@ -18,4 +18,6 @@ func (n EnodeID) String() string {
|
|||||||
type Node interface {
|
type Node interface {
|
||||||
NewENSVerifier(logger *zap.Logger) enstypes.ENSVerifier
|
NewENSVerifier(logger *zap.Logger) enstypes.ENSVerifier
|
||||||
GetWhisper(ctx interface{}) (Whisper, error)
|
GetWhisper(ctx interface{}) (Whisper, error)
|
||||||
|
AddPeer(url string) error
|
||||||
|
RemovePeer(url string) error
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user