aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/whisperv5
diff options
context:
space:
mode:
Diffstat (limited to 'whisper/whisperv5')
-rw-r--r--whisper/whisperv5/api.go12
-rw-r--r--whisper/whisperv5/peer_test.go5
2 files changed, 8 insertions, 9 deletions
diff --git a/whisper/whisperv5/api.go b/whisper/whisperv5/api.go
index 2ce464220..7d963df8d 100644
--- a/whisper/whisperv5/api.go
+++ b/whisper/whisperv5/api.go
@@ -28,7 +28,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
- "github.com/ethereum/go-ethereum/p2p/discover"
+ "github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum/go-ethereum/rpc"
)
@@ -96,12 +96,12 @@ func (api *PublicWhisperAPI) SetMinPoW(ctx context.Context, pow float64) (bool,
// MarkTrustedPeer marks a peer trusted. , which will allow it to send historic (expired) messages.
// Note: This function is not adding new nodes, the node needs to exists as a peer.
-func (api *PublicWhisperAPI) MarkTrustedPeer(ctx context.Context, enode string) (bool, error) {
- n, err := discover.ParseNode(enode)
+func (api *PublicWhisperAPI) MarkTrustedPeer(ctx context.Context, url string) (bool, error) {
+ n, err := enode.ParseV4(url)
if err != nil {
return false, err
}
- return true, api.w.AllowP2PMessagesFromPeer(n.ID[:])
+ return true, api.w.AllowP2PMessagesFromPeer(n.ID().Bytes())
}
// NewKeyPair generates a new public and private key pair for message decryption and encryption.
@@ -270,11 +270,11 @@ func (api *PublicWhisperAPI) Post(ctx context.Context, req NewMessage) (bool, er
// send to specific node (skip PoW check)
if len(req.TargetPeer) > 0 {
- n, err := discover.ParseNode(req.TargetPeer)
+ n, err := enode.ParseV4(req.TargetPeer)
if err != nil {
return false, fmt.Errorf("failed to parse target peer: %s", err)
}
- return true, api.w.SendP2PMessage(n.ID[:], env)
+ return true, api.w.SendP2PMessage(n.ID().Bytes(), env)
}
// ensure that the message PoW meets the node's minimum accepted PoW
diff --git a/whisper/whisperv5/peer_test.go b/whisper/whisperv5/peer_test.go
index 256a670aa..35616aaaf 100644
--- a/whisper/whisperv5/peer_test.go
+++ b/whisper/whisperv5/peer_test.go
@@ -27,7 +27,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/p2p"
- "github.com/ethereum/go-ethereum/p2p/discover"
+ "github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum/go-ethereum/p2p/nat"
)
@@ -146,8 +146,7 @@ func initialize(t *testing.T) {
peerNodeId := nodes[j].id
address, _ := net.ResolveTCPAddr("tcp", nodes[j].server.ListenAddr)
peerPort := uint16(address.Port)
- peerNode := discover.PubkeyID(&peerNodeId.PublicKey)
- peer := discover.NewNode(peerNode, address.IP, peerPort, peerPort)
+ peer := enode.NewV4(&peerNodeId.PublicKey, address.IP, int(peerPort), int(peerPort))
node.server.AddPeer(peer)
}