whisper: clean up and integrate topics

This commit is contained in:
Péter Szilágyi
2015-04-13 12:16:51 +03:00
parent 7b501906db
commit 9a53390f49
7 changed files with 85 additions and 43 deletions

View File

@ -119,7 +119,7 @@ func (self *Whisper) Watch(opts Filter) int {
return self.filters.Install(filter.Generic{
Str1: string(crypto.FromECDSAPub(opts.To)),
Str2: string(crypto.FromECDSAPub(opts.From)),
Data: bytesToMap(opts.Topics),
Data: NewTopicSet(opts.Topics),
Fn: func(data interface{}) {
opts.Fn(data.(*Message))
},
@ -272,9 +272,9 @@ func (self *Whisper) Protocol() p2p.Protocol {
return self.protocol
}
func createFilter(message *Message, topics [][]byte, key *ecdsa.PrivateKey) filter.Filter {
func createFilter(message *Message, topics []Topic, key *ecdsa.PrivateKey) filter.Filter {
return filter.Generic{
Str1: string(crypto.FromECDSAPub(&key.PublicKey)), Str2: string(crypto.FromECDSAPub(message.Recover())),
Data: bytesToMap(topics),
Data: NewTopicSet(topics),
}
}