fix: improve blockchain node RPC responses and database path consistency
- Add transaction data to RPC responses (get_block, get_blocks_range) - Fix import_block to handle transactions parameter - Change database paths to absolute paths for consistency - Make dev_heartbeat.py executable
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
APP_ENV=dev
|
||||
APP_HOST=127.0.0.1
|
||||
APP_PORT=8011
|
||||
DATABASE_URL=sqlite:///./data/coordinator.db
|
||||
DATABASE_URL=sqlite:////opt/aitbc/data/coordinator.db
|
||||
CLIENT_API_KEYS=${CLIENT_API_KEY},client_dev_key_2
|
||||
MINER_API_KEYS=${MINER_API_KEY},miner_dev_key_2
|
||||
ADMIN_API_KEYS=${ADMIN_API_KEY}
|
||||
|
||||
@@ -8,7 +8,7 @@ import json
|
||||
from decimal import Decimal
|
||||
|
||||
# Database configurations
|
||||
SQLITE_DB = "coordinator.db"
|
||||
SQLITE_DB = "/opt/aitbc/data/coordinator.db"
|
||||
PG_CONFIG = {
|
||||
"host": "localhost",
|
||||
"database": "aitbc_coordinator",
|
||||
|
||||
@@ -16,7 +16,7 @@ from decimal import Decimal
|
||||
import json
|
||||
|
||||
# Database configurations
|
||||
SQLITE_DB = "coordinator.db"
|
||||
SQLITE_DB = "/opt/aitbc/data/coordinator.db"
|
||||
PG_CONFIG = {
|
||||
"host": "localhost",
|
||||
"database": "aitbc_coordinator",
|
||||
|
||||
@@ -30,7 +30,7 @@ class DatabaseConfig(BaseSettings):
|
||||
|
||||
# Default SQLite path - consistent with blockchain-node pattern
|
||||
if self.adapter == "sqlite":
|
||||
return "sqlite:///./data/coordinator.db"
|
||||
return "sqlite:////opt/aitbc/data/coordinator.db"
|
||||
|
||||
# Default PostgreSQL connection string
|
||||
return f"{self.adapter}://localhost:5432/coordinator"
|
||||
@@ -187,7 +187,7 @@ class Settings(BaseSettings):
|
||||
if self.database.url:
|
||||
return self.database.url
|
||||
# Default SQLite path - consistent with blockchain-node pattern
|
||||
return "sqlite:///./data/coordinator.db"
|
||||
return "sqlite:////opt/aitbc/data/coordinator.db"
|
||||
|
||||
@database_url.setter
|
||||
def database_url(self, value: str):
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
|
||||
from sqlmodel import create_engine, SQLModel
|
||||
from sqlalchemy import StaticPool
|
||||
from .config import settings
|
||||
|
||||
# Create in-memory SQLite database for now
|
||||
# Create database engine using URL from config
|
||||
engine = create_engine(
|
||||
"sqlite:///./data/coordinator.db",
|
||||
connect_args={"check_same_thread": False},
|
||||
poolclass=StaticPool,
|
||||
echo=True # Enable SQL logging for debugging
|
||||
settings.database_url,
|
||||
connect_args={"check_same_thread": False} if settings.database_url.startswith("sqlite") else {},
|
||||
poolclass=StaticPool if settings.database_url.startswith("sqlite") else None,
|
||||
echo=settings.test_mode # Enable SQL logging for debugging in test mode
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user