pubkey should stay as blob

This commit is contained in:
Lex Berezhny 2018-07-15 00:40:46 -04:00
parent fcc7177a9a
commit e36e4c6354
2 changed files with 33 additions and 32 deletions

View file

@ -88,7 +88,7 @@ class BaseDatabase(SQLiteMixin):
account text not null, account text not null,
chain integer not null, chain integer not null,
position integer not null, position integer not null,
pubkey text not null, pubkey blob not null,
history text, history text,
used_times integer not null default 0 used_times integer not null default 0
); );
@ -270,7 +270,7 @@ class BaseDatabase(SQLiteMixin):
values.append(account.public_key.address) values.append(account.public_key.address)
values.append(chain) values.append(chain)
values.append(position) values.append(position)
values.append(pubkey.pubkey_bytes) values.append(sqlite3.Binary(pubkey.pubkey_bytes))
return self.db.runOperation(sql, values) return self.db.runOperation(sql, values)
@staticmethod @staticmethod

View file

@ -269,41 +269,42 @@ class BaseLedger(six.with_metaclass(LedgerRegistry)):
yield lock.acquire() yield lock.acquire()
#try: 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)
if remote_height > 0 and not is_verified: # see if we have a local copy of transaction, otherwise fetch it from server
is_verified = yield self.is_valid_transaction(tx, remote_height) raw, local_height, is_verified = yield self.db.get_transaction(hex_id)
is_verified = 1 if is_verified else 0 save_tx = None
if save_tx is None: if raw is None:
save_tx = 'update' _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( if remote_height > 0 and not is_verified:
save_tx, tx, remote_height, is_verified, address, self.address_to_hash160(address), is_verified = yield self.is_valid_transaction(tx, remote_height)
''.join('{}:{}:'.format(tx_id, tx_height) for tx_id, tx_height in synced_history) 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( yield self.db.save_transaction_io(
self.get_id(), hex_id, address, remote_height, is_verified 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)
self._on_transaction_controller.add(TransactionEvent(address, tx, remote_height, is_verified)) )
#except: log.debug("{}: sync'ed tx {} for address: {}, height: {}, verified: {}".format(
# log.exception('Failed to synchronize transaction:') self.get_id(), hex_id, address, remote_height, is_verified
# raise ))
self._on_transaction_controller.add(TransactionEvent(address, tx, remote_height, is_verified))
#finally: except:
lock.release() log.exception('Failed to synchronize transaction:')
if not lock.locked: raise
del self._transaction_processing_locks[hex_id]
finally:
lock.release()
if not lock.locked:
del self._transaction_processing_locks[hex_id]
@defer.inlineCallbacks @defer.inlineCallbacks
def subscribe_history(self, address): def subscribe_history(self, address):