console
This commit is contained in:
parent
7870abaef4
commit
e64b108404
3 changed files with 18 additions and 8 deletions
|
@ -428,7 +428,7 @@ class BlockchainSync(Sync):
|
|||
self.advance_loop_event = asyncio.Event()
|
||||
|
||||
async def start(self):
|
||||
for _ in range(2):
|
||||
for _ in range(1): # range(2):
|
||||
# initial sync can take a long time, new blocks may have been
|
||||
# created while sync was running; therefore, run a second sync
|
||||
# after first one finishes to possibly sync those new blocks.
|
||||
|
|
|
@ -54,7 +54,7 @@ class Basic(Console):
|
|||
|
||||
class Advanced(Basic):
|
||||
|
||||
FORMAT = '{l_bar}{bar}| {n_fmt:>8}/{total_fmt:>8} [{elapsed:>7}<{remaining:>8}, {rate_fmt:>15}]'
|
||||
FORMAT = '{l_bar}{bar}| {n_fmt:>8}/{total_fmt:>8} [{elapsed:>7}<{remaining:>8}, {rate_fmt:>16}]'
|
||||
|
||||
def __init__(self, service: Service):
|
||||
super().__init__(service)
|
||||
|
@ -101,9 +101,11 @@ class Advanced(Basic):
|
|||
bar.close()
|
||||
|
||||
def update_other_bars(self, e, d):
|
||||
bar = self.get_or_create_bar(e, e, d['unit'], d['total'], leave=True)
|
||||
bar = self.get_or_create_bar(e, e[-13:], d['unit'], d['total'], leave=True)
|
||||
diff = d['step']-bar.last_print_n
|
||||
bar.update(diff)
|
||||
if d['step'] == d['total']:
|
||||
bar.close()
|
||||
|
||||
def on_sync_progress(self, event):
|
||||
e, d = event['event'], event.get('data', {})
|
||||
|
|
|
@ -36,12 +36,18 @@ class Simulator:
|
|||
"txs": self.txs
|
||||
}
|
||||
})
|
||||
blocks_synced = txs_synced = 0
|
||||
for starting_file in range(self.starting_file, self.ending_file, self.processes):
|
||||
tasks = []
|
||||
for b in range(starting_file, min(self.ending_file, starting_file+self.processes)):
|
||||
blocks = int(self.blocks / self.files)
|
||||
txs = int(self.txs / self.files)
|
||||
tasks.append(self.sync_block_file(b, blocks, txs))
|
||||
if b == (self.ending_file-1):
|
||||
tasks.append(self.sync_block_file(b, self.blocks-blocks_synced, self.txs-txs_synced))
|
||||
else:
|
||||
blocks = int(self.blocks / self.files)
|
||||
blocks_synced += blocks
|
||||
txs = int(self.txs / self.files)
|
||||
txs_synced += txs
|
||||
tasks.append(self.sync_block_file(b, blocks, txs))
|
||||
await asyncio.wait(tasks)
|
||||
await self.progress.add({
|
||||
"event": "blockchain.sync.block.done",
|
||||
|
@ -64,7 +70,7 @@ class Simulator:
|
|||
"event": "blockchain.sync.block.read",
|
||||
"data": {"step": blocks, "total": blocks, "unit": "blocks", "block_file": block_file}
|
||||
})
|
||||
|
||||
await asyncio.sleep(0.5)
|
||||
for i in range(0, txs, 10000):
|
||||
await self.progress.add({
|
||||
"event": "blockchain.sync.block.save",
|
||||
|
@ -82,12 +88,14 @@ class Simulator:
|
|||
"event": "db.sync.input",
|
||||
"data": {"step": i, "total": 2, "unit": "txis"}
|
||||
})
|
||||
await asyncio.sleep(1)
|
||||
claims = int(self.txs/4)
|
||||
for i in range(claims+1):
|
||||
for i in range(0, claims+1, 10_000):
|
||||
await self.progress.add({
|
||||
"event": "blockchain.sync.claim.update",
|
||||
"data": {"step": i, "total": claims, "unit": "claims"}
|
||||
})
|
||||
await asyncio.sleep(0.1)
|
||||
|
||||
|
||||
async def main():
|
||||
|
|
Loading…
Reference in a new issue