aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/whisperv5/whisper.go
diff options
context:
space:
mode:
authorgluk256 <gluk256@users.noreply.github.com>2017-02-14 22:44:47 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-02-14 22:44:47 +0800
commit15a609d5d6613e37e819975ceba01cb5ba735242 (patch)
tree1de23ad8c8d5885700164185f0d0d92f7ae95199 /whisper/whisperv5/whisper.go
parent72dcd3c58bec0a281280d5d42ed53b6e429ce4af (diff)
downloadgo-tangerine-15a609d5d6613e37e819975ceba01cb5ba735242.tar
go-tangerine-15a609d5d6613e37e819975ceba01cb5ba735242.tar.gz
go-tangerine-15a609d5d6613e37e819975ceba01cb5ba735242.tar.bz2
go-tangerine-15a609d5d6613e37e819975ceba01cb5ba735242.tar.lz
go-tangerine-15a609d5d6613e37e819975ceba01cb5ba735242.tar.xz
go-tangerine-15a609d5d6613e37e819975ceba01cb5ba735242.tar.zst
go-tangerine-15a609d5d6613e37e819975ceba01cb5ba735242.zip
whisper: interface changed to simplify the transition to v5
* whisper: mailserver test introduced, refactoring * whisper: validation test updated * whisper: max number of peers fixed * whisper: verification bug fixed * whisper: esthetic fix * whisper: interface changed to simplify the transition to v5 * whisper: preparation for version switch
Diffstat (limited to 'whisper/whisperv5/whisper.go')
-rw-r--r--whisper/whisperv5/whisper.go20
1 files changed, 18 insertions, 2 deletions
diff --git a/whisper/whisperv5/whisper.go b/whisper/whisperv5/whisper.go
index ff31aab2d..a027fd84b 100644
--- a/whisper/whisperv5/whisper.go
+++ b/whisper/whisperv5/whisper.go
@@ -31,6 +31,7 @@ import (
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/p2p"
+ "github.com/ethereum/go-ethereum/rpc"
"golang.org/x/crypto/pbkdf2"
set "gopkg.in/fatih/set.v0"
)
@@ -65,7 +66,7 @@ type Whisper struct {
// New creates a Whisper client ready to communicate through the Ethereum P2P network.
// Param s should be passed if you want to implement mail server, otherwise nil.
-func NewWhisper(server MailServer) *Whisper {
+func New() *Whisper {
whisper := &Whisper{
privateKeys: make(map[string]*ecdsa.PrivateKey),
symKeys: make(map[string][]byte),
@@ -73,7 +74,6 @@ func NewWhisper(server MailServer) *Whisper {
messages: make(map[common.Hash]*ReceivedMessage),
expirations: make(map[uint32]*set.SetNonTS),
peers: make(map[*Peer]struct{}),
- mailServer: server,
messageQueue: make(chan *Envelope, messageQueueLimit),
p2pMsgQueue: make(chan *Envelope, messageQueueLimit),
quit: make(chan struct{}),
@@ -91,6 +91,22 @@ func NewWhisper(server MailServer) *Whisper {
return whisper
}
+// APIs returns the RPC descriptors the Whisper implementation offers
+func (w *Whisper) APIs() []rpc.API {
+ return []rpc.API{
+ {
+ Namespace: ProtocolName,
+ Version: ProtocolVersionStr,
+ Service: NewPublicWhisperAPI(w),
+ Public: true,
+ },
+ }
+}
+
+func (w *Whisper) RegisterServer(server MailServer) {
+ w.mailServer = server
+}
+
// Protocols returns the whisper sub-protocols ran by this particular client.
func (w *Whisper) Protocols() []p2p.Protocol {
return []p2p.Protocol{w.protocol}