Compare commits
2 Commits
c9245615cb
...
67ab504a40
| Author | SHA1 | Date | |
|---|---|---|---|
| 67ab504a40 | |||
| f2e7749c7b |
@@ -1,6 +1,6 @@
|
||||
rpc_url = 'arbitrum_dxod'
|
||||
ws_url = 'arbitrum_dxod_ws'
|
||||
archive_url = 'arbitrum_alchemy'
|
||||
concurrent_rpc_connections=20
|
||||
concurrent_rpc_connections=8
|
||||
metrics_port=9001
|
||||
metadata = '' # this setting approves no tokens
|
||||
|
||||
@@ -210,6 +210,9 @@ async def add_accounting_row(account: str, block_hash: Optional[str], tx_id: Opt
|
||||
"""
|
||||
if amount == 0:
|
||||
return dec(0)
|
||||
# Adjust database account if it exists
|
||||
if not is_tracked_address(account):
|
||||
return dec(0)
|
||||
if adjust_decimals:
|
||||
amount = await adj_dec(token, amount)
|
||||
# noinspection PyTypeChecker
|
||||
@@ -222,16 +225,12 @@ async def add_accounting_row(account: str, block_hash: Optional[str], tx_id: Opt
|
||||
token=token, amount=amount, value=value, note=note,
|
||||
chain_id=chain_id, tx_id=tx_id,
|
||||
))
|
||||
# Adjust database account if it exists
|
||||
if is_tracked_address(account):
|
||||
account_db = db.session.get(DbAccount, (current_chain.get(), account))
|
||||
new_amount = account_db.balances.get(token, dec(0)) + amount
|
||||
if new_amount < 0:
|
||||
log.error(f'negative balance for account {account} when applying accounting row {time} {category} {subcategory} {token} {amount} ${value}')
|
||||
account_db.balances[token] = new_amount
|
||||
db.session.add(account_db) # deep changes would not be detected by the ORM
|
||||
else:
|
||||
log.warning(f'No db account found for {account}')
|
||||
account_db = db.session.get(DbAccount, (current_chain.get(), account))
|
||||
new_amount = account_db.balances.get(token, dec(0)) + amount
|
||||
if new_amount < 0:
|
||||
log.error(f'negative balance for account {account} when applying accounting row {time} {category} {subcategory} {token} {amount} ${value}')
|
||||
account_db.balances[token] = new_amount
|
||||
db.session.add(account_db) # deep changes would not be detected by the ORM
|
||||
return value
|
||||
|
||||
async def adjust_balance(account: DbAccount, token=NATIVE_TOKEN, subcategory=AccountingSubcategory.InitialBalance, note=None):
|
||||
|
||||
@@ -82,7 +82,7 @@ class BlockStateRunner(BlockProgressor):
|
||||
log.debug('connecting to ws provider')
|
||||
await w3ws.provider.connect()
|
||||
subscription = await w3ws.eth.subscribe('newHeads') # the return value of this call is not consistent between anvil/hardhat/rpc.
|
||||
log.debug(f'subscribed to newHeads {subscription}')
|
||||
# log.debug(f'subscribed to newHeads {subscription}')
|
||||
while self.running:
|
||||
async for message in w3ws.ws.process_subscriptions():
|
||||
block = Block(chain_id, message['result'])
|
||||
|
||||
Reference in New Issue
Block a user