mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-10-13 02:50:35 -04:00
immutable config
This commit is contained in:
parent
45dffe0d9f
commit
681fdf9f7c
79 changed files with 733 additions and 1319 deletions
|
@ -16,14 +16,14 @@ async def test_connect(api_connection: veilid.VeilidAPI):
|
|||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_public_keys(api_connection: veilid.VeilidAPI):
|
||||
async def test_get_node_ids(api_connection: veilid.VeilidAPI):
|
||||
state = await api_connection.get_state()
|
||||
public_keys = state.config.config.network.routing_table.public_keys
|
||||
node_ids = state.network.node_ids
|
||||
|
||||
assert len(public_keys) >= 1
|
||||
assert len(node_ids) >= 1
|
||||
|
||||
for public_key in public_keys:
|
||||
assert public_key[4] == ":"
|
||||
for node_id in node_ids:
|
||||
assert node_id[4] == ":"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
2
veilid-python/uv.lock
generated
2
veilid-python/uv.lock
generated
|
@ -210,7 +210,7 @@ wheels = [
|
|||
|
||||
[[package]]
|
||||
name = "veilid"
|
||||
version = "0.4.7"
|
||||
version = "0.4.8"
|
||||
source = { editable = "." }
|
||||
dependencies = [
|
||||
{ name = "appdirs" },
|
||||
|
|
|
@ -4758,6 +4758,13 @@
|
|||
"description": "The total number of bytes per second used by Veilid currently in the upload direction.",
|
||||
"$ref": "#/$defs/ByteCount"
|
||||
},
|
||||
"node_ids": {
|
||||
"description": "The list of node ids for this node",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"peers": {
|
||||
"description": "The list of most recently accessed peers.\nThis is not an active connection table, nor is representative of the entire routing table.",
|
||||
"type": "array",
|
||||
|
@ -4774,7 +4781,8 @@
|
|||
"started",
|
||||
"bps_down",
|
||||
"bps_up",
|
||||
"peers"
|
||||
"peers",
|
||||
"node_ids"
|
||||
]
|
||||
},
|
||||
"VeilidUpdate": {
|
||||
|
|
|
@ -7,7 +7,7 @@ from .types import (
|
|||
BareRouteId,
|
||||
Timestamp,
|
||||
TimestampDuration,
|
||||
PublicKey,
|
||||
NodeId,
|
||||
RecordKey,
|
||||
ValueData,
|
||||
ValueSubkey,
|
||||
|
@ -382,11 +382,11 @@ class PeerStats:
|
|||
|
||||
|
||||
class PeerTableData:
|
||||
node_ids: list[str]
|
||||
node_ids: list[NodeId]
|
||||
peer_address: str
|
||||
peer_stats: PeerStats
|
||||
|
||||
def __init__(self, node_ids: list[str], peer_address: str, peer_stats: PeerStats):
|
||||
def __init__(self, node_ids: list[NodeId], peer_address: str, peer_stats: PeerStats):
|
||||
self.node_ids = node_ids
|
||||
self.peer_address = peer_address
|
||||
self.peer_stats = peer_stats
|
||||
|
@ -394,7 +394,9 @@ class PeerTableData:
|
|||
@classmethod
|
||||
def from_json(cls, j: dict) -> Self:
|
||||
"""JSON object hook"""
|
||||
return cls(j["node_ids"], j["peer_address"], PeerStats.from_json(j["peer_stats"]))
|
||||
return cls([NodeId(node_id) for node_id in j["node_ids"]],
|
||||
j["peer_address"],
|
||||
PeerStats.from_json(j["peer_stats"]))
|
||||
|
||||
def to_json(self) -> dict:
|
||||
return self.__dict__
|
||||
|
@ -405,6 +407,7 @@ class VeilidStateNetwork:
|
|||
bps_down: ByteCount
|
||||
bps_up: ByteCount
|
||||
peers: list[PeerTableData]
|
||||
node_ids: list[NodeId]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
@ -412,11 +415,13 @@ class VeilidStateNetwork:
|
|||
bps_down: ByteCount,
|
||||
bps_up: ByteCount,
|
||||
peers: list[PeerTableData],
|
||||
node_ids: list[NodeId],
|
||||
):
|
||||
self.started = started
|
||||
self.bps_down = bps_down
|
||||
self.bps_up = bps_up
|
||||
self.peers = peers
|
||||
self.node_ids = node_ids
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, j: dict) -> Self:
|
||||
|
@ -426,6 +431,7 @@ class VeilidStateNetwork:
|
|||
ByteCount(j["bps_down"]),
|
||||
ByteCount(j["bps_up"]),
|
||||
[PeerTableData.from_json(peer) for peer in j["peers"]],
|
||||
[NodeId(node_id) for node_id in j["node_ids"]],
|
||||
)
|
||||
|
||||
def to_json(self) -> dict:
|
||||
|
@ -495,11 +501,11 @@ class VeilidLog:
|
|||
|
||||
|
||||
class VeilidAppMessage:
|
||||
sender: Optional[PublicKey]
|
||||
sender: Optional[NodeId]
|
||||
route_id: Optional[BareRouteId]
|
||||
message: bytes
|
||||
|
||||
def __init__(self, sender: Optional[PublicKey], route_id: Optional[BareRouteId], message: bytes):
|
||||
def __init__(self, sender: Optional[NodeId], route_id: Optional[BareRouteId], message: bytes):
|
||||
self.sender = sender
|
||||
self.route_id = route_id
|
||||
self.message = message
|
||||
|
@ -508,7 +514,7 @@ class VeilidAppMessage:
|
|||
def from_json(cls, j: dict) -> Self:
|
||||
"""JSON object hook"""
|
||||
return cls(
|
||||
None if j["sender"] is None else PublicKey(j["sender"]),
|
||||
None if j["sender"] is None else NodeId(j["sender"]),
|
||||
None if j["route_id"] is None else BareRouteId(j["route_id"]),
|
||||
urlsafe_b64decode_no_pad(j["message"]),
|
||||
)
|
||||
|
@ -518,12 +524,12 @@ class VeilidAppMessage:
|
|||
|
||||
|
||||
class VeilidAppCall:
|
||||
sender: Optional[PublicKey]
|
||||
sender: Optional[NodeId]
|
||||
route_id: Optional[BareRouteId]
|
||||
message: bytes
|
||||
call_id: OperationId
|
||||
|
||||
def __init__(self, sender: Optional[PublicKey], route_id: Optional[BareRouteId], message: bytes, call_id: OperationId):
|
||||
def __init__(self, sender: Optional[NodeId], route_id: Optional[BareRouteId], message: bytes, call_id: OperationId):
|
||||
self.sender = sender
|
||||
self.route_id = route_id
|
||||
self.message = message
|
||||
|
@ -533,7 +539,7 @@ class VeilidAppCall:
|
|||
def from_json(cls, j: dict) -> Self:
|
||||
"""JSON object hook"""
|
||||
return cls(
|
||||
None if j["sender"] is None else PublicKey(j["sender"]),
|
||||
None if j["sender"] is None else NodeId(j["sender"]),
|
||||
None if j["route_id"] is None else BareRouteId(j["route_id"]),
|
||||
urlsafe_b64decode_no_pad(j["message"]),
|
||||
OperationId(j["call_id"]),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue