refactor: improve gossip broker cleanup and enhance CLI wallet transaction handling
Some checks failed
AITBC CI/CD Pipeline / lint-and-test (3.11) (push) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.12) (push) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.13) (push) Has been cancelled
AITBC CI/CD Pipeline / test-cli (push) Has been cancelled
AITBC CI/CD Pipeline / test-services (push) Has been cancelled
AITBC CI/CD Pipeline / test-production-services (push) Has been cancelled
AITBC CI/CD Pipeline / security-scan (push) Has been cancelled
AITBC CI/CD Pipeline / build (push) Has been cancelled
AITBC CI/CD Pipeline / deploy-staging (push) Has been cancelled
AITBC CI/CD Pipeline / deploy-production (push) Has been cancelled
AITBC CI/CD Pipeline / performance-test (push) Has been cancelled
AITBC CI/CD Pipeline / docs (push) Has been cancelled
AITBC CI/CD Pipeline / release (push) Has been cancelled
AITBC CI/CD Pipeline / notify (push) Has been cancelled
Security Scanning / Bandit Security Scan (apps/coordinator-api/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (cli/aitbc_cli) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-core/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-crypto/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-sdk/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (tests) (push) Has been cancelled
Security Scanning / CodeQL Security Analysis (javascript) (push) Has been cancelled
Security Scanning / CodeQL Security Analysis (python) (push) Has been cancelled
Security Scanning / Dependency Security Scan (push) Has been cancelled
Security Scanning / Container Security Scan (push) Has been cancelled
Security Scanning / OSSF Scorecard (push) Has been cancelled
Security Scanning / Security Summary Report (push) Has been cancelled
AITBC CLI Level 1 Commands Test / test-cli-level1 (3.11) (push) Has been cancelled
AITBC CLI Level 1 Commands Test / test-cli-level1 (3.12) (push) Has been cancelled
AITBC CLI Level 1 Commands Test / test-cli-level1 (3.13) (push) Has been cancelled
AITBC CLI Level 1 Commands Test / test-summary (push) Has been cancelled

- Refactor _InProcessBroadcast.subscribe to use asynccontextmanager for cleaner resource cleanup
- Remove manual release callback in _InProcessSubscriber
- Update file-based wallet send to submit transactions via blockchain RPC
- Fetch balance and nonce from chain before sending transactions
- Add tx_hash and status tracking to local transaction history
- Enhance run_subprocess to support additional kwargs and return Comp
This commit is contained in:
2026-03-23 14:06:17 +01:00
parent 5dccaffbf9
commit bbe67239a1
9 changed files with 496 additions and 44 deletions

View File

@@ -4,7 +4,7 @@ import asyncio
import json
import warnings
from collections import defaultdict
from contextlib import suppress
from contextlib import suppress, asynccontextmanager
from dataclasses import dataclass
from typing import Any, Callable, Dict, List, Optional, Set
@@ -225,25 +225,15 @@ class GossipBroker:
class _InProcessSubscriber:
def __init__(self, queue: "asyncio.Queue[Any]", release: Callable[[], None]):
def __init__(self, queue: "asyncio.Queue[Any]"):
self._queue = queue
self._release = release
async def __aenter__(self):
return self
async def __aexit__(self, exc_type, exc, tb):
self._release()
def __aiter__(self): # type: ignore[override]
return self._iterator()
async def _iterator(self):
try:
while True:
yield await self._queue.get()
finally:
self._release()
while True:
yield await self._queue.get()
class _InProcessBroadcast:
@@ -262,23 +252,19 @@ class _InProcessBroadcast:
self._topics.clear()
self._running = False
async def subscribe(self, topic: str) -> _InProcessSubscriber:
@asynccontextmanager
async def subscribe(self, topic: str):
queue: "asyncio.Queue[Any]" = asyncio.Queue()
async with self._lock:
self._topics[topic].append(queue)
def release() -> None:
async def _remove() -> None:
async with self._lock:
queues = self._topics.get(topic)
if queues and queue in queues:
queues.remove(queue)
if not queues:
self._topics.pop(topic, None)
asyncio.create_task(_remove())
return _InProcessSubscriber(queue, release)
try:
yield _InProcessSubscriber(queue)
finally:
async with self._lock:
queues = self._topics.get(topic)
if queues and queue in queues:
queues.remove(queue)
async def publish(self, topic: str, message: Any) -> None:
if not self._running: