aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBas van Kervel <basvankervel@gmail.com>2017-06-21 16:08:47 +0800
committerBas van Kervel <basvankervel@gmail.com>2017-06-21 16:11:46 +0800
commit36e7963467eb2eb3cceff9fe1960db17a388e458 (patch)
tree0bf704f974f8ddd7a323318586459dc0589fd689
parentb58a5016738b92db19e08ec87ef34ce3250fae6b (diff)
downloaddexon-36e7963467eb2eb3cceff9fe1960db17a388e458.tar
dexon-36e7963467eb2eb3cceff9fe1960db17a388e458.tar.gz
dexon-36e7963467eb2eb3cceff9fe1960db17a388e458.tar.bz2
dexon-36e7963467eb2eb3cceff9fe1960db17a388e458.tar.lz
dexon-36e7963467eb2eb3cceff9fe1960db17a388e458.tar.xz
dexon-36e7963467eb2eb3cceff9fe1960db17a388e458.tar.zst
dexon-36e7963467eb2eb3cceff9fe1960db17a388e458.zip
whisper: move ShhClient to its own package
-rw-r--r--whisper/shhclient/client.go (renamed from whisper/whisperv5/client.go)19
1 files changed, 10 insertions, 9 deletions
diff --git a/whisper/whisperv5/client.go b/whisper/shhclient/client.go
index f53fe6143..61c1b7ab7 100644
--- a/whisper/whisperv5/client.go
+++ b/whisper/shhclient/client.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
-package whisperv5
+package shhclient
import (
"context"
@@ -22,9 +22,10 @@ import (
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rpc"
+ whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
)
-// Client defines typed wrappers for the Whisper RPC API.
+// Client defines typed wrappers for the Whisper v5 RPC API.
type Client struct {
c *rpc.Client
}
@@ -51,8 +52,8 @@ func (sc *Client) Version(ctx context.Context) (uint, error) {
}
// Info returns diagnostic information about the whisper node.
-func (sc *Client) Info(ctx context.Context) (Info, error) {
- var info Info
+func (sc *Client) Info(ctx context.Context) (whisper.Info, error) {
+ var info whisper.Info
err := sc.c.CallContext(ctx, &info, "shh_info")
return info, err
}
@@ -159,7 +160,7 @@ func (sc *Client) DeleteSymmetricKey(ctx context.Context, id string) error {
}
// Post a message onto the network.
-func (sc *Client) Post(ctx context.Context, message NewMessage) error {
+func (sc *Client) Post(ctx context.Context, message whisper.NewMessage) error {
var ignored bool
return sc.c.CallContext(ctx, &ignored, "shh_post", message)
}
@@ -167,14 +168,14 @@ func (sc *Client) Post(ctx context.Context, message NewMessage) error {
// SubscribeMessages subscribes to messages that match the given criteria. This method
// is only supported on bi-directional connections such as websockets and IPC.
// NewMessageFilter uses polling and is supported over HTTP.
-func (ec *Client) SubscribeMessages(ctx context.Context, criteria Criteria, ch chan<- *Message) (ethereum.Subscription, error) {
+func (ec *Client) SubscribeMessages(ctx context.Context, criteria whisper.Criteria, ch chan<- *whisper.Message) (ethereum.Subscription, error) {
return ec.c.ShhSubscribe(ctx, ch, "messages", criteria)
}
// NewMessageFilter creates a filter within the node. This filter can be used to poll
// for new messages (see FilterMessages) that satisfy the given criteria. A filter can
// timeout when it was polled for in whisper.filterTimeout.
-func (ec *Client) NewMessageFilter(ctx context.Context, criteria Criteria) (string, error) {
+func (ec *Client) NewMessageFilter(ctx context.Context, criteria whisper.Criteria) (string, error) {
var id string
return id, ec.c.CallContext(ctx, &id, "shh_newMessageFilter", criteria)
}
@@ -187,7 +188,7 @@ func (ec *Client) DeleteMessageFilter(ctx context.Context, id string) error {
// FilterMessages retrieves all messages that are received between the last call to
// this function and match the criteria that where given when the filter was created.
-func (ec *Client) FilterMessages(ctx context.Context, id string) ([]*Message, error) {
- var messages []*Message
+func (ec *Client) FilterMessages(ctx context.Context, id string) ([]*whisper.Message, error) {
+ var messages []*whisper.Message
return messages, ec.c.CallContext(ctx, &messages, "shh_getFilterMessages", id)
}