mirror of
https://github.com/logos-blockchain/logos-blockchain-specs.git
synced 2026-01-11 01:23:13 +00:00
rename gossip to nomssip
This commit is contained in:
parent
78d4ab9ba2
commit
953b2d6875
@ -31,11 +31,11 @@ class NodeConfig:
|
||||
|
||||
private_key: X25519PrivateKey
|
||||
mix_path_length: int
|
||||
gossip: GossipConfig
|
||||
nomssip: NomssipConfig
|
||||
|
||||
|
||||
@dataclass
|
||||
class GossipConfig:
|
||||
class NomssipConfig:
|
||||
# The target number of peers a node should maintain in its p2p network
|
||||
peering_degree: int
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ from pysphinx.sphinx import (
|
||||
|
||||
from mixnet.config import GlobalConfig, NodeConfig
|
||||
from mixnet.connection import DuplexConnection, MixSimplexConnection
|
||||
from mixnet.gossip import GossipChannel
|
||||
from mixnet.nomssip import Nomssip
|
||||
from mixnet.packet import Fragment, MessageFlag, MessageReconstructor, PacketBuilder
|
||||
|
||||
BroadcastChannel: TypeAlias = asyncio.Queue[bytes]
|
||||
@ -29,7 +29,7 @@ class Node:
|
||||
|
||||
config: NodeConfig
|
||||
global_config: GlobalConfig
|
||||
mixgossip_channel: GossipChannel
|
||||
nomssip: Nomssip
|
||||
reconstructor: MessageReconstructor
|
||||
broadcast_channel: BroadcastChannel
|
||||
# The actual packet size is calculated based on the max length of mix path by Sphinx encoding
|
||||
@ -39,7 +39,7 @@ class Node:
|
||||
def __init__(self, config: NodeConfig, global_config: GlobalConfig):
|
||||
self.config = config
|
||||
self.global_config = global_config
|
||||
self.mixgossip_channel = GossipChannel(config.gossip, self.__process_msg)
|
||||
self.nomssip = Nomssip(config.nomssip, self.__process_msg)
|
||||
self.reconstructor = MessageReconstructor()
|
||||
self.broadcast_channel = asyncio.Queue()
|
||||
|
||||
@ -102,7 +102,7 @@ class Node:
|
||||
inbound_conn, outbound_conn = asyncio.Queue(), asyncio.Queue()
|
||||
|
||||
# Register a duplex connection for its own use
|
||||
self.mixgossip_channel.add_conn(
|
||||
self.nomssip.add_conn(
|
||||
DuplexConnection(
|
||||
inbound_conn,
|
||||
MixSimplexConnection(
|
||||
@ -113,7 +113,7 @@ class Node:
|
||||
)
|
||||
)
|
||||
# Register the same duplex connection for the peer
|
||||
peer.mixgossip_channel.add_conn(
|
||||
peer.nomssip.add_conn(
|
||||
DuplexConnection(
|
||||
outbound_conn,
|
||||
MixSimplexConnection(
|
||||
@ -135,9 +135,7 @@ class Node:
|
||||
self.global_config.membership,
|
||||
self.config.mix_path_length,
|
||||
):
|
||||
await self.mixgossip_channel.gossip(
|
||||
Node.__build_msg(MsgType.REAL, packet.bytes())
|
||||
)
|
||||
await self.nomssip.gossip(Node.__build_msg(MsgType.REAL, packet.bytes()))
|
||||
|
||||
@staticmethod
|
||||
def __build_msg(flag: MsgType, data: bytes) -> bytes:
|
||||
|
||||
@ -2,18 +2,17 @@ import asyncio
|
||||
import hashlib
|
||||
from typing import Awaitable, Callable
|
||||
|
||||
from mixnet.config import GossipConfig
|
||||
from mixnet.config import NomssipConfig
|
||||
from mixnet.connection import DuplexConnection
|
||||
|
||||
|
||||
class GossipChannel:
|
||||
class Nomssip:
|
||||
"""
|
||||
A gossip channel that broadcasts messages to all connected peers.
|
||||
A NomMix gossip channel that broadcasts messages to all connected peers.
|
||||
Peers are connected via DuplexConnection.
|
||||
This class simplifies and simulates the libp2p gossipsub.
|
||||
"""
|
||||
|
||||
config: GossipConfig
|
||||
config: NomssipConfig
|
||||
conns: list[DuplexConnection]
|
||||
# A handler to process inbound messages.
|
||||
handler: Callable[[bytes], Awaitable[bytes | None]]
|
||||
@ -22,7 +21,7 @@ class GossipChannel:
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
config: GossipConfig,
|
||||
config: NomssipConfig,
|
||||
handler: Callable[[bytes], Awaitable[bytes | None]],
|
||||
):
|
||||
self.config = config
|
||||
@ -2,10 +2,10 @@ from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey
|
||||
|
||||
from mixnet.config import (
|
||||
GlobalConfig,
|
||||
GossipConfig,
|
||||
MixMembership,
|
||||
NodeConfig,
|
||||
NodeInfo,
|
||||
NomssipConfig,
|
||||
)
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ def init_mixnet_config(
|
||||
) -> tuple[GlobalConfig, list[NodeConfig], dict[bytes, X25519PrivateKey]]:
|
||||
transmission_rate_per_sec = 3
|
||||
max_mix_path_length = 3
|
||||
gossip_config = GossipConfig(peering_degree=6)
|
||||
gossip_config = NomssipConfig(peering_degree=6)
|
||||
node_configs = [
|
||||
NodeConfig(X25519PrivateKey.generate(), max_mix_path_length, gossip_config)
|
||||
for _ in range(num_nodes)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user