[Fixes: #2068] Pass topics for mailserver

We were not actually passing the topics in the request, therefore we
were using bloom filter for query, which resulted in long syncing times
for some users.
This commit is contained in:
Andrea Maria Piana 2020-11-23 08:18:53 +01:00
parent d8307a60cf
commit 0304b3fa46
2 changed files with 16 additions and 3 deletions

View File

@ -1 +1 @@
0.64.1
0.64.2

View File

@ -597,9 +597,12 @@ func MakeMessagesRequestPayload(r MessagesRequest) ([]byte, error) {
}
payload := mailserver.MessagesRequestPayload{
Lower: r.From,
Upper: r.To,
Lower: r.From,
Upper: r.To,
// We need to pass bloom filter for
// backward compatibility
Bloom: createBloomFilter(r),
Topics: topicsToByteArray(r.Topics),
Limit: r.Limit,
Cursor: cursor,
// Client must tell the MailServer if it supports batch responses.
@ -610,6 +613,16 @@ func MakeMessagesRequestPayload(r MessagesRequest) ([]byte, error) {
return rlp.EncodeToBytes(payload)
}
func topicsToByteArray(topics []types.TopicType) [][]byte {
var response [][]byte
for idx := range topics {
response = append(response, topics[idx][:])
}
return response
}
func createBloomFilter(r MessagesRequest) []byte {
if len(r.Topics) > 0 {
return topicsToBloom(r.Topics...)