mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2026-09-27 17:46:28 -04:00
Start working on local api
This commit is contained in:
@@ -10,6 +10,7 @@ __pycache__/
|
||||
|
||||
# Database
|
||||
nohup.out
|
||||
mongod.log
|
||||
|
||||
# Keys and plot files
|
||||
config/keys.yaml
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file
|
||||
!.gitignore
|
||||
@@ -175,11 +175,14 @@ class FullNode:
|
||||
|
||||
async def introducer_client():
|
||||
async def on_connect():
|
||||
log.info("on connect")
|
||||
msg = Message("request_peers", peer_protocol.RequestPeers())
|
||||
yield OutboundMessage(NodeType.INTRODUCER, msg, Delivery.RESPOND)
|
||||
|
||||
while not self._shut_down:
|
||||
log.info("looping")
|
||||
if self._num_needed_peers():
|
||||
log.info("Conncting")
|
||||
if not await self.server.start_client(
|
||||
introducer_peerinfo, on_connect
|
||||
):
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import List
|
||||
from src.types.full_block import FullBlock
|
||||
from src.types.header_block import HeaderBlock
|
||||
from src.types.peer_info import PeerInfo
|
||||
from src.server.connection import NodeType
|
||||
from src.util.cbor_message import cbor_message
|
||||
from src.types.sized_bytes import bytes32
|
||||
from src.util.ints import uint16, uint64
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@cbor_message
|
||||
class StopNodeRequest:
|
||||
pass
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@cbor_message
|
||||
class StopNodeResponse:
|
||||
pass
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@cbor_message
|
||||
class GetConnectionsRequest:
|
||||
pass
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@cbor_message
|
||||
class GetConnectionsResponse:
|
||||
peer_info: PeerInfo
|
||||
node_type: NodeType
|
||||
node_id: bytes32
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@cbor_message
|
||||
class AddConnectionRequest:
|
||||
host: str
|
||||
port: uint16
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@cbor_message
|
||||
class AddConnectionResponse:
|
||||
pass
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@cbor_message
|
||||
class GetBlockchainInfoRequest:
|
||||
pass
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@cbor_message
|
||||
class GetBlockchainInfoResponse:
|
||||
lca_header_hash: bytes32
|
||||
next_difficulty: uint64
|
||||
next_ips: uint64
|
||||
tips_header_hashes: List[bytes32]
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@cbor_message
|
||||
class GetBlockRequest:
|
||||
header_hash: bytes32
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@cbor_message
|
||||
class GetBlockResponse:
|
||||
block: FullBlock
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@cbor_message
|
||||
class GetHeaderBlockRequest:
|
||||
header_hash: bytes32
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@cbor_message
|
||||
class GetHeaderBlockResponse:
|
||||
header_block: HeaderBlock
|
||||
@@ -131,7 +131,7 @@ class ChiaServer:
|
||||
asyncio.TimeoutError,
|
||||
) as e:
|
||||
log.warning(
|
||||
f"Could not connct to {target_node}. {type(e)}{e}. Retrying."
|
||||
f"Could not connect to {target_node}. {type(e)}{e}. Retrying."
|
||||
)
|
||||
open_con_task.cancel()
|
||||
await asyncio.sleep(RETRY_INTERVAL)
|
||||
|
||||
Reference in New Issue
Block a user