use multi_get to make status hash
This commit is contained in:
parent
92c3d3840d
commit
0877e34289
1 changed files with 7 additions and 4 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import hashlib
|
||||||
import asyncio
|
import asyncio
|
||||||
import array
|
import array
|
||||||
import time
|
import time
|
||||||
|
@ -38,10 +39,12 @@ class PrimaryDB(SecondaryDB):
|
||||||
tx_counts = self.tx_counts
|
tx_counts = self.tx_counts
|
||||||
hist_tx_nums = array.array('I')
|
hist_tx_nums = array.array('I')
|
||||||
hist_tx_nums.frombytes(history)
|
hist_tx_nums.frombytes(history)
|
||||||
hist = ''
|
digest = hashlib.sha256()
|
||||||
for tx_num in hist_tx_nums:
|
for tx_num, tx_hash in zip(
|
||||||
hist += f'{self.get_tx_hash(tx_num)[::-1].hex()}:{bisect_right(tx_counts, tx_num)}:'
|
hist_tx_nums,
|
||||||
return sha256(hist.encode())
|
self.prefix_db.tx_hash.multi_get([(tx_num,) for tx_num in hist_tx_nums], deserialize_value=False)):
|
||||||
|
digest.update(f'{tx_hash[::-1].hex()}:{bisect_right(tx_counts, tx_num)}:'.encode())
|
||||||
|
return digest.digest()
|
||||||
|
|
||||||
start = time.perf_counter()
|
start = time.perf_counter()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue