chunks streadming, my network models
This commit is contained in:
1 parent
a2c3fe4f98
commit
dba359bb6a
15 files changed
+625
-20
No files matched your search
@@ -55,6 +55,7 @@ async def main_fn(memory):
|
||||
await asyncio.sleep(10)
|
||||
return await main_fn(memory)
|
||||
|
||||
# TODO: не деплоить если указан master_address и мы проверили что аккаунт существует. Сейчас platform у каждой ноды будет разным
|
||||
platform_state = await toncenter.get_account(platform.address.to_string(1, 1, 1))
|
||||
if not platform_state.get('code'):
|
||||
make_log("TON", "Platform contract is not deployed, send deploy transaction..", level="info")
|
||||
|
||||
@@ -10,3 +10,4 @@ from app.core.models.user_activity import UserActivity
|
||||
from app.core.models.content.user_content import UserContent, UserAction
|
||||
from app.core.models._config import ServiceConfigValue
|
||||
from app.core.models.asset import Asset
|
||||
from app.core.models.my_network import KnownNode, KnownNodeIncident, RemoteContentIndex
|
||||
@@ -12,6 +12,12 @@ class KnownTelegramMessage(AlchemyBase):
|
||||
|
||||
id = Column(Integer, autoincrement=True, primary_key=True)
|
||||
type = Column(String(64), nullable=True)
|
||||
# common: все сообщения (удаляются постоянно)
|
||||
# start_command: /start (остается одно)
|
||||
# notification (не удаляется): licenseWasBought, contentWasIndexed
|
||||
# content/audio, content/video (удаляются только если пришел еще раз этот же контент в лс)
|
||||
# hint
|
||||
|
||||
bot_id = Column(Integer, nullable=False, default=1) # 0 – uploader, 1 – client
|
||||
chat_id = Column(BigInteger, nullable=False)
|
||||
message_id = Column(BigInteger, nullable=False)
|
||||
@@ -20,5 +26,7 @@ class KnownTelegramMessage(AlchemyBase):
|
||||
created = Column(DateTime, nullable=False, default=0)
|
||||
deleted = Column(Boolean, nullable=True, default=False)
|
||||
meta = Column(JSON, nullable=False, default={})
|
||||
# можно записывать все что угодно о сообщениях
|
||||
|
||||
content_id = Column(Integer, ForeignKey('node_storage.id'), nullable=True)
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
from .base import AlchemyBase
|
||||
from sqlalchemy import Column, BigInteger, Integer, String, ForeignKey, DateTime, JSON, Boolean
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class KnownNode(AlchemyBase):
|
||||
__tablename__ = 'known_nodes'
|
||||
|
||||
id = Column(Integer, autoincrement=True, primary_key=True)
|
||||
ip = Column(String(64), nullable=False, unique=True)
|
||||
port = Column(Integer, nullable=False)
|
||||
public_key = Column(String(256), nullable=False)
|
||||
codebase_hash = Column(String(512), nullable=True) # Node software version
|
||||
reputation = Column(Integer, nullable=False, default=0)
|
||||
last_sync = Column(DateTime, nullable=False, default=datetime.now)
|
||||
meta = Column(JSON, nullable=False, default={})
|
||||
located_at = Column(DateTime, nullable=False, default=datetime.now)
|
||||
|
||||
|
||||
class KnownNodeIncident(AlchemyBase):
|
||||
__tablename__ = 'known_nodes_incidents'
|
||||
|
||||
id = Column(Integer, autoincrement=True, primary_key=True)
|
||||
node_id = Column(Integer, ForeignKey('known_nodes.id'), nullable=False) # Reference to the node
|
||||
incident_type = Column(String(64), nullable=False) # Type of incident, e.g., 'sync_failure', 'unreachable'
|
||||
description = Column(String(512), nullable=True) # Detailed description of the incident
|
||||
occurred_at = Column(DateTime, nullable=False, default=datetime.utcnow) # Timestamp when the incident occurred
|
||||
severity = Column(Integer, nullable=False, default=1) # Severity level (1-low to 5-critical)
|
||||
resolved = Column(Boolean, nullable=False, default=False) # Whether the incident has been resolved
|
||||
resolved_at = Column(DateTime, nullable=True) # Timestamp when the incident was resolved
|
||||
meta = Column(JSON, nullable=False, default={}) # Additional metadata if needed
|
||||
|
||||
|
||||
class RemoteContentIndex(AlchemyBase):
|
||||
__tablename__ = 'remote_content_index'
|
||||
|
||||
id = Column(Integer, autoincrement=True, primary_key=True)
|
||||
remote_node_id = Column(Integer, ForeignKey('known_nodes.id'), nullable=False) # Reference to the remote node
|
||||
content_type = Column(String(64), nullable=False) # Type of content (e.g., music, video, document)
|
||||
encrypted_hash = Column(String(128), nullable=False) # Encrypted content hash provided initially
|
||||
decrypted_hash = Column(String(128), nullable=True) # Decrypted content hash, available once permission is granted
|
||||
ton_address = Column(String(128), nullable=True) # TON network address for the content
|
||||
onchain_index = Column(Integer, nullable=True) # Onchain index or reference on a blockchain
|
||||
metadata = Column(JSON, nullable=False, default={}) # Additional metadata for flexible content description
|
||||
last_updated = Column(DateTime, nullable=False, default=datetime.utcnow) # Timestamp of the last update
|
||||
created_at = Column(DateTime, nullable=False, default=datetime.utcnow) # Record creation timestamp
|
||||
|
||||
Reference in new issue
Block a user