forked from LBRYCommunity/lbry-sdk
pubkey should stay as blob
This commit is contained in:
parent
fcc7177a9a
commit
e36e4c6354
2 changed files with 33 additions and 32 deletions
|
@ -88,7 +88,7 @@ class BaseDatabase(SQLiteMixin):
|
|||
account text not null,
|
||||
chain integer not null,
|
||||
position integer not null,
|
||||
pubkey text not null,
|
||||
pubkey blob not null,
|
||||
history text,
|
||||
used_times integer not null default 0
|
||||
);
|
||||
|
@ -270,7 +270,7 @@ class BaseDatabase(SQLiteMixin):
|
|||
values.append(account.public_key.address)
|
||||
values.append(chain)
|
||||
values.append(position)
|
||||
values.append(pubkey.pubkey_bytes)
|
||||
values.append(sqlite3.Binary(pubkey.pubkey_bytes))
|
||||
return self.db.runOperation(sql, values)
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -269,41 +269,42 @@ class BaseLedger(six.with_metaclass(LedgerRegistry)):
|
|||
|
||||
yield lock.acquire()
|
||||
|
||||
#try:
|
||||
# see if we have a local copy of transaction, otherwise fetch it from server
|
||||
raw, local_height, is_verified = yield self.db.get_transaction(hex_id)
|
||||
save_tx = None
|
||||
if raw is None:
|
||||
_raw = yield self.network.get_transaction(hex_id)
|
||||
tx = self.transaction_class(unhexlify(_raw))
|
||||
save_tx = 'insert'
|
||||
else:
|
||||
tx = self.transaction_class(raw)
|
||||
try:
|
||||
|
||||
if remote_height > 0 and not is_verified:
|
||||
is_verified = yield self.is_valid_transaction(tx, remote_height)
|
||||
is_verified = 1 if is_verified else 0
|
||||
if save_tx is None:
|
||||
save_tx = 'update'
|
||||
# see if we have a local copy of transaction, otherwise fetch it from server
|
||||
raw, local_height, is_verified = yield self.db.get_transaction(hex_id)
|
||||
save_tx = None
|
||||
if raw is None:
|
||||
_raw = yield self.network.get_transaction(hex_id)
|
||||
tx = self.transaction_class(unhexlify(_raw))
|
||||
save_tx = 'insert'
|
||||
else:
|
||||
tx = self.transaction_class(raw)
|
||||
|
||||
yield self.db.save_transaction_io(
|
||||
save_tx, tx, remote_height, is_verified, address, self.address_to_hash160(address),
|
||||
''.join('{}:{}:'.format(tx_id, tx_height) for tx_id, tx_height in synced_history)
|
||||
)
|
||||
if remote_height > 0 and not is_verified:
|
||||
is_verified = yield self.is_valid_transaction(tx, remote_height)
|
||||
is_verified = 1 if is_verified else 0
|
||||
if save_tx is None:
|
||||
save_tx = 'update'
|
||||
|
||||
log.debug("{}: sync'ed tx {} for address: {}, height: {}, verified: {}".format(
|
||||
self.get_id(), hex_id, address, remote_height, is_verified
|
||||
))
|
||||
self._on_transaction_controller.add(TransactionEvent(address, tx, remote_height, is_verified))
|
||||
yield self.db.save_transaction_io(
|
||||
save_tx, tx, remote_height, is_verified, address, self.address_to_hash160(address),
|
||||
''.join('{}:{}:'.format(tx_id, tx_height) for tx_id, tx_height in synced_history)
|
||||
)
|
||||
|
||||
#except:
|
||||
# log.exception('Failed to synchronize transaction:')
|
||||
# raise
|
||||
log.debug("{}: sync'ed tx {} for address: {}, height: {}, verified: {}".format(
|
||||
self.get_id(), hex_id, address, remote_height, is_verified
|
||||
))
|
||||
self._on_transaction_controller.add(TransactionEvent(address, tx, remote_height, is_verified))
|
||||
|
||||
#finally:
|
||||
lock.release()
|
||||
if not lock.locked:
|
||||
del self._transaction_processing_locks[hex_id]
|
||||
except:
|
||||
log.exception('Failed to synchronize transaction:')
|
||||
raise
|
||||
|
||||
finally:
|
||||
lock.release()
|
||||
if not lock.locked:
|
||||
del self._transaction_processing_locks[hex_id]
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def subscribe_history(self, address):
|
||||
|
|
Loading…
Reference in a new issue