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