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 untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87
1 changed files with 2 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import collections
from threading import current_thread, enumerate as threadingEnumerate, RLock
import Queue
import sqlite3
import time
from helper_sql import *
@ -50,7 +51,7 @@ class SqliteInventory(InventoryStorage):
def by_type_and_tag(self, objectType, tag):
with self.lock:
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
def hashes_by_stream(self, stream):