mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-11-10 12:29:49 +03:00
log timing of applying additions and removals to the coin store (#8493)
This commit is contained in:
parent
55baeb532a
commit
b66db03528
@ -8,6 +8,10 @@ from chia.types.coin_record import CoinRecord
|
||||
from chia.util.db_wrapper import DBWrapper
|
||||
from chia.util.ints import uint32, uint64
|
||||
from chia.util.lru_cache import LRUCache
|
||||
from time import time
|
||||
import logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class CoinStore:
|
||||
@ -72,6 +76,8 @@ class CoinStore:
|
||||
Only called for blocks which are blocks (and thus have rewards and transactions)
|
||||
"""
|
||||
|
||||
start = time()
|
||||
|
||||
for coin in tx_additions:
|
||||
record: CoinRecord = CoinRecord(
|
||||
coin,
|
||||
@ -105,6 +111,13 @@ class CoinStore:
|
||||
|
||||
# Sanity check, already checked in block_body_validation
|
||||
assert sum([a.amount for a in tx_additions]) <= total_amount_spent
|
||||
end = time()
|
||||
if end - start > 10:
|
||||
log.warning(
|
||||
f"It took {end - start:0.2}s to apply {len(tx_additions)} additions and "
|
||||
+ f"{len(tx_removals)} removals to the coin store. Make sure "
|
||||
+ "blockchain database is on a fast drive"
|
||||
)
|
||||
|
||||
# Checks DB and DiffStores for CoinRecord with coin_name and returns it
|
||||
async def get_coin_record(self, coin_name: bytes32) -> Optional[CoinRecord]:
|
||||
|
Loading…
Reference in New Issue
Block a user