aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/shhapi
diff options
context:
space:
mode:
authorgluk256 <gluk256@users.noreply.github.com>2016-12-20 07:58:01 +0800
committerFelix Lange <fjl@users.noreply.github.com>2016-12-20 07:58:01 +0800
commitba996f5e27572e853bcc5c815ae72082a15c9183 (patch)
tree16d6fd41d3d77208597683c71bdc9af603d43a77 /whisper/shhapi
parent64bf5bafe9ced66bfb11f34fed9181aa89399473 (diff)
downloaddexon-ba996f5e27572e853bcc5c815ae72082a15c9183.tar.gz
dexon-ba996f5e27572e853bcc5c815ae72082a15c9183.tar.zst
dexon-ba996f5e27572e853bcc5c815ae72082a15c9183.zip
whisper: refactoring (#3411)
* whisper: refactored message processing * whisper: final polishing * whisper: logging updated * whisper: moved the check, changed the default PoW * whisper: refactoring of message queuing * whisper: refactored parameters
Diffstat (limited to 'whisper/shhapi')
-rw-r--r--whisper/shhapi/api.go16
-rw-r--r--whisper/shhapi/api_test.go9
2 files changed, 25 insertions, 0 deletions
diff --git a/whisper/shhapi/api.go b/whisper/shhapi/api.go
index 6ed3e17c2..f2597e133 100644
--- a/whisper/shhapi/api.go
+++ b/whisper/shhapi/api.go
@@ -55,6 +55,22 @@ func APIs() []rpc.API {
}
}
+// Start starts the Whisper worker threads.
+func (api *PublicWhisperAPI) Start() error {
+ if api.whisper == nil {
+ return whisperOffLineErr
+ }
+ return api.whisper.Start(nil)
+}
+
+// Stop stops the Whisper worker threads.
+func (api *PublicWhisperAPI) Stop() error {
+ if api.whisper == nil {
+ return whisperOffLineErr
+ }
+ return api.whisper.Stop()
+}
+
// Version returns the Whisper version this node offers.
func (api *PublicWhisperAPI) Version() (*rpc.HexNumber, error) {
if api.whisper == nil {
diff --git a/whisper/shhapi/api_test.go b/whisper/shhapi/api_test.go
index 13a7cee66..a10e2e476 100644
--- a/whisper/shhapi/api_test.go
+++ b/whisper/shhapi/api_test.go
@@ -277,6 +277,9 @@ func TestIntegrationAsym(t *testing.T) {
t.Fatalf("failed to create API.")
}
+ api.Start()
+ defer api.Stop()
+
sig, err := api.NewIdentity()
if err != nil {
t.Fatalf("failed NewIdentity: %s.", err)
@@ -375,6 +378,9 @@ func TestIntegrationSym(t *testing.T) {
t.Fatalf("failed to create API.")
}
+ api.Start()
+ defer api.Stop()
+
keyname := "schluessel"
err := api.GenerateSymKey(keyname)
if err != nil {
@@ -471,6 +477,9 @@ func TestIntegrationSymWithFilter(t *testing.T) {
t.Fatalf("failed to create API.")
}
+ api.Start()
+ defer api.Stop()
+
keyname := "schluessel"
err := api.GenerateSymKey(keyname)
if err != nil {