mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-06-15 16:31:03 +00:00
Split msg into JSON and internal variant, and other bits
This commit is contained in:
@@ -17,6 +17,7 @@ log = "0.4"
|
||||
rustc-hash = "1.1.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = { version = "1.0", features = ["raw_value"] }
|
||||
primitive-types = { version = "0.9.0", features = ["serde"] }
|
||||
common = { path = "../common" }
|
||||
simple_logger = "1.11.0"
|
||||
soketto = "0.4.2"
|
||||
|
||||
@@ -6,8 +6,8 @@ use actix::prelude::*;
|
||||
use actix_http::http::Uri;
|
||||
use bincode::Options;
|
||||
use rustc_hash::FxHashMap;
|
||||
use common::util::{Hash, DenseMap};
|
||||
use common::types::{ConnId, NodeDetails, NodeId};
|
||||
use common::util::{DenseMap};
|
||||
use common::types::{ConnId, NodeDetails, NodeId, BlockHash};
|
||||
use common::node::Payload;
|
||||
use common::shard::{ShardConnId, ShardMessage, BackendMessage};
|
||||
use soketto::handshake::{Client, ServerResponse};
|
||||
@@ -22,7 +22,7 @@ type WsReceiver = soketto::Receiver<Compat<TcpStream>>;
|
||||
#[derive(Default)]
|
||||
pub struct Aggregator {
|
||||
url: Uri,
|
||||
chains: FxHashMap<Hash, UnboundedSender<ChainMessage>>,
|
||||
chains: FxHashMap<BlockHash, UnboundedSender<ChainMessage>>,
|
||||
}
|
||||
|
||||
impl Actor for Aggregator {
|
||||
@@ -42,13 +42,13 @@ pub struct Chain {
|
||||
/// Base URL of Backend Core
|
||||
url: Uri,
|
||||
/// Genesis hash of the chain, required to construct the URL to connect to the Backend Core
|
||||
genesis_hash: Hash,
|
||||
genesis_hash: BlockHash,
|
||||
/// Dense mapping of SharedConnId -> Addr<NodeConnector> + multiplexing ConnId sent from the node.
|
||||
nodes: DenseMap<(Addr<NodeConnector>, ConnId)>,
|
||||
}
|
||||
|
||||
impl Chain {
|
||||
pub fn new(url: Uri, genesis_hash: Hash) -> Self {
|
||||
pub fn new(url: Uri, genesis_hash: BlockHash) -> Self {
|
||||
Chain {
|
||||
url,
|
||||
genesis_hash,
|
||||
@@ -188,7 +188,7 @@ impl Actor for Chain {
|
||||
#[rtype(result = "()")]
|
||||
pub struct AddNode {
|
||||
pub ip: Option<Ipv4Addr>,
|
||||
pub genesis_hash: Hash,
|
||||
pub genesis_hash: BlockHash,
|
||||
pub node: NodeDetails,
|
||||
pub conn_id: ConnId,
|
||||
pub node_connector: Addr<NodeConnector>,
|
||||
|
||||
@@ -8,6 +8,7 @@ use actix::prelude::*;
|
||||
use actix_web_actors::ws::{self, CloseReason};
|
||||
use common::node::{NodeMessage, Payload};
|
||||
use common::types::{ConnId, NodeId};
|
||||
use common::json;
|
||||
use common::ws::{MultipartHandler, WsMessage};
|
||||
use tokio::sync::mpsc::UnboundedSender;
|
||||
|
||||
@@ -93,9 +94,10 @@ impl NodeConnector {
|
||||
|
||||
fn handle_message(
|
||||
&mut self,
|
||||
msg: NodeMessage,
|
||||
msg: json::NodeMessage,
|
||||
ctx: &mut <Self as Actor>::Context,
|
||||
) {
|
||||
let msg: NodeMessage = msg.into();
|
||||
let conn_id = msg.id();
|
||||
let payload = msg.into();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user