aboutsummaryrefslogtreecommitdiffstats
path: root/xeth/whisper_filter.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-04-17 21:45:44 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-04-28 15:47:35 +0800
commit3563c59b12b0b8b5fd15847bf97d71dfd8416207 (patch)
treef059a2bcbd7edb25c595bbad30514828fc1a5282 /xeth/whisper_filter.go
parent182d484aa70bcd5b22117f02333b1fd3b1535dcb (diff)
downloadgo-tangerine-3563c59b12b0b8b5fd15847bf97d71dfd8416207.tar.gz
go-tangerine-3563c59b12b0b8b5fd15847bf97d71dfd8416207.tar.zst
go-tangerine-3563c59b12b0b8b5fd15847bf97d71dfd8416207.zip
rpc, whisper, xeth: polish whisper RPC interface
Diffstat (limited to 'xeth/whisper_filter.go')
-rw-r--r--xeth/whisper_filter.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/xeth/whisper_filter.go b/xeth/whisper_filter.go
new file mode 100644
index 000000000..9d8a739b7
--- /dev/null
+++ b/xeth/whisper_filter.go
@@ -0,0 +1,26 @@
+// Contains the external API side message filter for watching, pooling and polling
+// matched whisper messages.
+
+package xeth
+
+import "time"
+
+// whisperFilter is the message cache matching a specific filter, accumulating
+// inbound messages until the are requested by the client.
+type whisperFilter struct {
+ id int // Filter identifier
+ cache []WhisperMessage // Cache of messages not yet polled
+ timeout time.Time // Time when the last message batch was queries
+}
+
+// insert injects a new batch of messages into the filter cache.
+func (w *whisperFilter) insert(msgs ...WhisperMessage) {
+ w.cache = append(w.cache, msgs...)
+}
+
+// retrieve fetches all the cached messages from the filter.
+func (w *whisperFilter) retrieve() (messages []WhisperMessage) {
+ messages, w.cache = w.cache, nil
+ w.timeout = time.Now()
+ return
+}