[ethereum/go-ethereum] mobile: implemented whisper client (#15922)

gballet requested changes on this pull request.

some minor nitpicks, but the whole thing should be updated to v6

> @@ -26,6 +26,7 @@ import (
«github.com/ethereum/go-ethereum/common»
«github.com/ethereum/go-ethereum/core/types»
«github.com/ethereum/go-ethereum/rlp»
+ whisper «github.com/ethereum/go-ethereum/whisper/whisperv5»

v6 has been released for a while. Let me know if you have questions making it work.

> +func (nm *NewMessage) GetTTL() int64 { return int64(nm.newMessage.TTL) }
+func (nm *NewMessage) SetTTL(ttl int64) { nm.newMessage.TTL = uint32(ttl) }
+func (nm *NewMessage) GetPayload() []byte { return nm.newMessage.Payload }
+func (nm *NewMessage) SetPayload(payload []byte) { nm.newMessage.Payload = common.CopyBytes(payload) }
+func (nm *NewMessage) GetPowTime() int64 { return int64(nm.newMessage.PowTime) }
+func (nm *NewMessage) SetPowTime(powTime int64) { nm.newMessage.PowTime = uint32(powTime) }
+func (nm *NewMessage) GetPowTarget() float64 { return nm.newMessage.PowTarget }
+func (nm *NewMessage) SetPowTarget(powTarget float64) { nm.newMessage.PowTarget = powTarget }
+func (nm *NewMessage) GetTargetPeer() string { return nm.newMessage.TargetPeer }
+func (nm *NewMessage) SetTargetPeer(targetPeer string) { nm.newMessage.TargetPeer = targetPeer }
+func (nm *NewMessage) GetTopic() []byte { return nm.newMessage.Topic[:] }
+func (nm *NewMessage) SetTopic(topic []byte) { nm.newMessage.Topic = whisper.BytesToTopic(topic) }
+
+// Message represents a whisper message.
+type Message struct {
+ message *whisper.Message

alright

> @@ -136,9 +136,9 @@ func (sc *Client) AddSymmetricKey(ctx context.Context, key []byte) (string, erro
}

// GenerateSymmetricKeyFromPassword generates the key from password, stores it, and returns its identifier.
-func (sc *Client) GenerateSymmetricKeyFromPassword(ctx context.Context, passwd []byte) (string, error) {
+func (sc *Client) GenerateSymmetricKeyFromPassword(ctx context.Context, passwd string) (string, error) {

agreed

> +
+// Info returns diagnostic information about the whisper node.
+func (wc *WhisperClient) GetInfo(ctx *Context) (info *Info, _ error) {
+ rawInfo, err := wc.client.Info(ctx.context)
+ return &Info{&rawInfo}, err
+}
+
+// SetMaxMessageSize sets the maximal message size allowed by this node. Incoming
+// and outgoing messages with a larger size will be rejected. Whisper message size
+// can never exceed the limit imposed by the underlying P2P protocol (10 Mb).
+func (wc *WhisperClient) SetMaxMessageSize(ctx *Context, size int32) error {
+ return wc.client.SetMaxMessageSize(ctx.context, uint32(size))
+}
+
+// SetMinimumPoW (experimental) sets the minimal PoW required by this node.
+

lint: extra line

Добавить комментарий