whisper: allow filter without topic for asymmetric encryption

This commit is contained in:
Vlad 2017-02-18 18:06:54 +01:00
parent dc63edcef0
commit e85268fcd1

View file

@ -168,7 +168,7 @@ func (api *PublicWhisperAPI) NewFilter(args WhisperFilterArgs) (string, error) {
} }
filter.Topics = append(filter.Topics, args.Topics...) filter.Topics = append(filter.Topics, args.Topics...)
if len(args.Topics) == 0 { if len(args.Topics) == 0 && len(args.KeyName) != 0 {
info := "NewFilter: at least one topic must be specified" info := "NewFilter: at least one topic must be specified"
glog.V(logger.Error).Infof(info) glog.V(logger.Error).Infof(info)
return "", errors.New(info) return "", errors.New(info)
@ -374,17 +374,17 @@ type PostArgs struct {
Payload hexutil.Bytes `json:"payload"` Payload hexutil.Bytes `json:"payload"`
WorkTime uint32 `json:"worktime"` WorkTime uint32 `json:"worktime"`
PoW float64 `json:"pow"` PoW float64 `json:"pow"`
FilterID string `json:"filterID"` FilterID string `json:"filterid"`
PeerID hexutil.Bytes `json:"peerID"` PeerID hexutil.Bytes `json:"peerid"`
} }
type WhisperFilterArgs struct { type WhisperFilterArgs struct {
To string To string `json:"to"`
From string From string `json:"from"`
KeyName string KeyName string `json:"keyname"`
PoW float64 PoW float64 `json:"pow"`
Topics []TopicType Topics []TopicType `json:"topics"`
AcceptP2P bool AcceptP2P bool `json:"p2p"`
} }
// UnmarshalJSON implements the json.Unmarshaler interface, invoked to convert a // UnmarshalJSON implements the json.Unmarshaler interface, invoked to convert a
@ -397,7 +397,7 @@ func (args *WhisperFilterArgs) UnmarshalJSON(b []byte) (err error) {
KeyName string `json:"keyname"` KeyName string `json:"keyname"`
PoW float64 `json:"pow"` PoW float64 `json:"pow"`
Topics []interface{} `json:"topics"` Topics []interface{} `json:"topics"`
AcceptP2P bool `json:"acceptP2P"` AcceptP2P bool `json:"p2p"`
} }
if err := json.Unmarshal(b, &obj); err != nil { if err := json.Unmarshal(b, &obj); err != nil {
return err return err