aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/whisperv6/api.go
diff options
context:
space:
mode:
authorJavier Peletier <jm@epiclabs.io>2018-03-05 23:00:03 +0800
committerJavier Peletier <jm@epiclabs.io>2018-03-05 23:00:03 +0800
commit13b566e06e9aae28bddde431c7d53a335272411a (patch)
treeb649ab64ca2c00327500aed5c826d5a6f454a6cf /whisper/whisperv6/api.go
parent1e72271f571f916691c5c18b8f0c4c5f7e0445c3 (diff)
parent1548518644071c8fa8eb98a8cb8a8c4603400acb (diff)
downloadgo-tangerine-13b566e06e9aae28bddde431c7d53a335272411a.tar
go-tangerine-13b566e06e9aae28bddde431c7d53a335272411a.tar.gz
go-tangerine-13b566e06e9aae28bddde431c7d53a335272411a.tar.bz2
go-tangerine-13b566e06e9aae28bddde431c7d53a335272411a.tar.lz
go-tangerine-13b566e06e9aae28bddde431c7d53a335272411a.tar.xz
go-tangerine-13b566e06e9aae28bddde431c7d53a335272411a.tar.zst
go-tangerine-13b566e06e9aae28bddde431c7d53a335272411a.zip
accounts/abi: Add one-parameter event test case from enriquefynn/unpack_one_arg_event
Diffstat (limited to 'whisper/whisperv6/api.go')
-rw-r--r--whisper/whisperv6/api.go36
1 files changed, 13 insertions, 23 deletions
diff --git a/whisper/whisperv6/api.go b/whisper/whisperv6/api.go
index a2c75a41c..96e2b17e7 100644
--- a/whisper/whisperv6/api.go
+++ b/whisper/whisperv6/api.go
@@ -61,32 +61,9 @@ func NewPublicWhisperAPI(w *Whisper) *PublicWhisperAPI {
w: w,
lastUsed: make(map[string]time.Time),
}
-
- go api.run()
return api
}
-// run the api event loop.
-// this loop deletes filter that have not been used within filterTimeout
-func (api *PublicWhisperAPI) run() {
- timeout := time.NewTicker(2 * time.Minute)
- for {
- <-timeout.C
-
- api.mu.Lock()
- for id, lastUsed := range api.lastUsed {
- if time.Since(lastUsed).Seconds() >= filterTimeout {
- delete(api.lastUsed, id)
- if err := api.w.Unsubscribe(id); err != nil {
- log.Error("could not unsubscribe whisper filter", "error", err)
- }
- log.Debug("delete whisper filter (timeout)", "id", id)
- }
- }
- api.mu.Unlock()
- }
-}
-
// Version returns the Whisper sub-protocol version.
func (api *PublicWhisperAPI) Version(ctx context.Context) string {
return ProtocolVersionStr
@@ -219,6 +196,19 @@ func (api *PublicWhisperAPI) DeleteSymKey(ctx context.Context, id string) bool {
return api.w.DeleteSymKey(id)
}
+// MakeLightClient turns the node into light client, which does not forward
+// any incoming messages, and sends only messages originated in this node.
+func (api *PublicWhisperAPI) MakeLightClient(ctx context.Context) bool {
+ api.w.lightClient = true
+ return api.w.lightClient
+}
+
+// CancelLightClient cancels light client mode.
+func (api *PublicWhisperAPI) CancelLightClient(ctx context.Context) bool {
+ api.w.lightClient = false
+ return !api.w.lightClient
+}
+
//go:generate gencodec -type NewMessage -field-override newMessageOverride -out gen_newmessage_json.go
// NewMessage represents a new whisper message that is posted through the RPC.