**Motivations:** - Anchor API requests were being aborted with 'This operation was aborted' error - API anchorage had performance issues causing long response times (30-60s) - Mutex could block indefinitely if a previous request crashed or timed out **Root causes:** - No timeout on mutex acquisition, causing indefinite blocking - Sequential RPC calls (8+ getNewAddress calls) instead of parallel - Expensive fee calculation making N RPC calls (one per input) instead of using known UTXO amounts - RPC timeout too short (30s) for slow Bitcoin node operations - No guarantee of mutex release in error cases **Correctifs:** - Added 180s timeout on mutex acquisition with Promise.race() to prevent indefinite blocking - Parallelized getNewAddress() calls with Promise.all() (9 sequential calls → 1 parallel call) - Optimized fee calculation to use known UTXO amounts instead of getRawTransaction() per input (saves N RPC calls, up to 20+) - Increased RPC timeout from 30s to 120s in .env.example - Added finally block to guarantee mutex release in all cases (success, error, timeout) - Added timeout and explicit error handling in api-filigrane callAnchorAPI() with AbortController (120s timeout) **Evolutions:** - Performance improvement: execution time reduced from ~30-60s to ~10-20s - RPC calls reduction: from ~15-35 calls to ~8-12 calls per anchor transaction - Better resilience: mutex cannot block indefinitely anymore - Improved error messages with explicit timeout/abort information **Pages affectées:** - api-anchorage/src/bitcoin-rpc.js: mutex timeout, parallel address generation, optimized fee calculation, finally block - api-anchorage/.env.example: increased RPC timeout to 120s - api-filigrane/src/routes/watermark.js: timeout and error handling for anchor API calls - fixKnowledge/api-filigrane-anchor-request-aborted.md: documentation of issues and fixes
21 lines
390 B
Plaintext
21 lines
390 B
Plaintext
# Bitcoin RPC Configuration
|
|
BITCOIN_RPC_HOST=127.0.0.1
|
|
BITCOIN_RPC_PORT=38332
|
|
BITCOIN_RPC_USER=bitcoin
|
|
BITCOIN_RPC_PASSWORD=bitcoin
|
|
BITCOIN_RPC_TIMEOUT=120000
|
|
|
|
# API Configuration
|
|
API_PORT=3010
|
|
API_HOST=0.0.0.0
|
|
|
|
# API Keys (séparées par des virgules)
|
|
API_KEYS=your-api-key-here,another-api-key
|
|
|
|
# Logging
|
|
LOG_LEVEL=info
|
|
|
|
# Mining Configuration
|
|
MINING_ENABLED=true
|
|
MINING_FEE_RATE=0.00001
|