Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch OverflowError on API calls #2905

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions counterparty-core/counterpartycore/lib/api/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,10 @@ def handle_route(**kwargs):
CBitcoinAddressError,
script.AddressError,
exceptions.ElectrsError,
OverflowError,
) as e:
import traceback

print(traceback.format_exc())
# import traceback
# print(traceback.format_exc())
return return_result(400, error=str(e), start_time=start_time, query_args=query_args)
except Exception as e:
capture_exception(e)
Expand Down
12 changes: 10 additions & 2 deletions counterparty-core/counterpartycore/lib/mempool.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import time

from counterpartycore.lib import blocks, config, deserialize, exceptions, ledger, util
from counterpartycore.lib import backend, blocks, config, deserialize, exceptions, ledger, util
from counterpartycore.lib.api.api_watcher import EVENTS_ADDRESS_FIELDS

logger = logging.getLogger(config.LOGGER_NAME)
Expand Down Expand Up @@ -119,7 +119,7 @@ def clean_transaction_events(db, tx_hash):


def clean_mempool(db):
logger.debug("Cleaning mempool...")
logger.debug("Remove validated transactions from mempool...")
cursor = db.cursor()
cursor.execute("SELECT * FROM mempool")
mempool_events = cursor.fetchall()
Expand All @@ -128,3 +128,11 @@ def clean_mempool(db):
tx = ledger.get_transaction(db, event["tx_hash"])
if tx:
clean_transaction_events(db, event["tx_hash"])
# remove transactions removed from the mempool
logger.debug("Remove transactions removed from the mempool...")
cursor.execute("SELECT distinct tx_hash FROM mempool")
tx_hashes = cursor.fetchall()
raw_mempool = backend.bitcoind.getrawmempool(verbose=False)
for tx_hash in tx_hashes:
if tx_hash["tx_hash"] not in raw_mempool:
clean_transaction_events(db, tx_hash["tx_hash"])
1 change: 1 addition & 0 deletions release-notes/release-notes-v10.9.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
- Don't put null values in API cache
- Fix Get Sends By Address endpoint, return also `detach` and `move`
- Fix `transactions.transaction_type` field when destination is `1CounterpartyXXXXXXXXXXXXXXXUWLpVr`
- Catch `OverflowError` on API calls

## Codebase

Expand Down
Loading