Allow specify topic in rpc endpoint (#1328)

This commit is contained in:
Andrea Maria Piana 2018-12-18 16:27:12 +01:00 committed by GitHub
parent 2c5a1a7710
commit 79bf92bea5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -17,6 +17,7 @@ type SendPublicMessageRPC struct {
// SendDirectMessageRPC represents the RPC payload for the SendDirectMessage RPC method
type SendDirectMessageRPC struct {
Sig string
Chat string
Payload hexutil.Bytes
PubKey hexutil.Bytes
}

View File

@ -34,10 +34,17 @@ func PublicMessageToWhisper(rpcMsg SendPublicMessageRPC, payload []byte) whisper
}
func DirectMessageToWhisper(rpcMsg SendDirectMessageRPC, payload []byte) whisper.NewMessage {
var topicBytes whisper.TopicType
if rpcMsg.Chat == "" {
topicBytes = discoveryTopicBytes
} else {
topicBytes = toTopic(rpcMsg.Chat)
}
msg := defaultWhisperMessage()
msg.Topic = discoveryTopicBytes
msg.Topic = topicBytes
msg.Payload = payload
msg.Sig = rpcMsg.Sig