Fix tag search when inventory contains blobs

- recent changes caused the "tag" (and "payload") columns in the
inventory table in messages.dat to be stored as blobs. Searches by tag
(e.g. pubkey lookups) stopped working. This fixes it.
This commit is contained in:
Peter Šurda 2017-12-02 02:48:10 +01:00
parent a3398d6a17
commit 5605672f75
Signed by: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87

View File

@ -1,6 +1,7 @@
import collections import collections
from threading import current_thread, enumerate as threadingEnumerate, RLock from threading import current_thread, enumerate as threadingEnumerate, RLock
import Queue import Queue
import sqlite3
import time import time
from helper_sql import * from helper_sql import *
@ -50,7 +51,7 @@ class SqliteInventory(InventoryStorage):
def by_type_and_tag(self, objectType, tag): def by_type_and_tag(self, objectType, tag):
with self.lock: with self.lock:
values = [value for value in self._inventory.values() if value.type == objectType and value.tag == tag] values = [value for value in self._inventory.values() if value.type == objectType and value.tag == tag]
values += (InventoryItem(*value) for value in sqlQuery('SELECT objecttype, streamnumber, payload, expirestime, tag FROM inventory WHERE objecttype=? AND tag=?', objectType, tag)) values += (InventoryItem(*value) for value in sqlQuery('SELECT objecttype, streamnumber, payload, expirestime, tag FROM inventory WHERE objecttype=? AND tag=?', objectType, sqlite3.Binary(tag)))
return values return values
def hashes_by_stream(self, stream): def hashes_by_stream(self, stream):