connector
This commit is contained in:
parent
a8c02720b4
commit
004fab03da
@ -363,10 +363,7 @@ class Connector:
|
|||||||
|
|
||||||
if self.utxo_data:
|
if self.utxo_data:
|
||||||
checkpoint = self.utxo.checkpoint
|
checkpoint = self.utxo.checkpoint
|
||||||
try:
|
try: self.utxo.checkpoints.append(block["checkpoint"])
|
||||||
self.log.critical("append checkpoint " + str( block["checkpoint"]))
|
|
||||||
|
|
||||||
self.utxo.checkpoints.append(block["checkpoint"])
|
|
||||||
except: pass
|
except: pass
|
||||||
if len(self.utxo.cached) > self.utxo.size_limit and \
|
if len(self.utxo.cached) > self.utxo.size_limit and \
|
||||||
not self.utxo.save_process and \
|
not self.utxo.save_process and \
|
||||||
@ -429,7 +426,7 @@ class Connector:
|
|||||||
self.utxo.deleted_utxo,
|
self.utxo.deleted_utxo,
|
||||||
self.utxo.loaded_utxo
|
self.utxo.loaded_utxo
|
||||||
))
|
))
|
||||||
self.log.debug("Preload coins cached/destoyed -> %s-%s [%s];" % (self.yy, self.aa, self.tt))
|
self.log.debug("Preload coins chached/destoyed -> %s-%s [%s];" % (self.yy, self.aa, self.tt))
|
||||||
self.log.debug("Coins %s; destroyed %s; unspent %s;" % (self.coins,
|
self.log.debug("Coins %s; destroyed %s; unspent %s;" % (self.coins,
|
||||||
self.destroyed_coins,
|
self.destroyed_coins,
|
||||||
self.coins - self.destroyed_coins))
|
self.coins - self.destroyed_coins))
|
||||||
|
|||||||
@ -93,6 +93,14 @@ class UTXO():
|
|||||||
self.log.critical("create checkpoint error")
|
self.log.critical("create checkpoint error")
|
||||||
self.log.critical(str(traceback.format_exc()))
|
self.log.critical(str(traceback.format_exc()))
|
||||||
|
|
||||||
|
def rocksdb_atomic_batch(self):
|
||||||
|
batch = rocksdb.WriteBatch()
|
||||||
|
[batch.delete(k) for k in self.pending_deleted]
|
||||||
|
for k in self.pending_utxo:
|
||||||
|
batch.put(k[0], k[1])
|
||||||
|
batch.put(b"last_block", int_to_bytes(self.checkpoint))
|
||||||
|
batch.put(b"last_cached_block", int_to_bytes(self.deleted_last_block))
|
||||||
|
self.db.write(batch)
|
||||||
|
|
||||||
async def save_checkpoint(self):
|
async def save_checkpoint(self):
|
||||||
# save to db tail from cache
|
# save to db tail from cache
|
||||||
@ -101,15 +109,7 @@ class UTXO():
|
|||||||
try:
|
try:
|
||||||
self.write_to_db = True
|
self.write_to_db = True
|
||||||
if not self.checkpoint: return
|
if not self.checkpoint: return
|
||||||
|
await self.loop.run_in_executor(None, self.rocksdb_atomic_batch, self)
|
||||||
batch = rocksdb.WriteBatch()
|
|
||||||
[batch.delete(k) for k in self.pending_deleted]
|
|
||||||
for k in self.pending_utxo:
|
|
||||||
batch.put(k[0], k[1])
|
|
||||||
batch.put(b"last_block", int_to_bytes(self.checkpoint))
|
|
||||||
batch.put(b"last_cached_block", int_to_bytes(self.deleted_last_block))
|
|
||||||
self.db.write(batch)
|
|
||||||
|
|
||||||
self.saved_utxo += len(self.pending_utxo)
|
self.saved_utxo += len(self.pending_utxo)
|
||||||
self.deleted_utxo += len(self.pending_deleted)
|
self.deleted_utxo += len(self.pending_deleted)
|
||||||
self.pending_deleted = set()
|
self.pending_deleted = set()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user