mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-07-20 13:55:44 +00:00
AFG messaging (#210)
* First draft of afg messaging * AfgReceivedPrevote, AfgReceivedPrecommit and AfgFinalized added to rust backend * Tidy up
This commit is contained in:
@@ -2,7 +2,7 @@ use std::time::{Duration, Instant};
|
||||
use bytes::Bytes;
|
||||
use actix::prelude::*;
|
||||
use actix_web_actors::ws;
|
||||
use crate::aggregator::{Aggregator, Connect, Disconnect, Subscribe};
|
||||
use crate::aggregator::{Aggregator, Connect, Disconnect, Subscribe, SendFinality, NoMoreFinality};
|
||||
use crate::chain::Unsubscribe;
|
||||
use crate::feed::{FeedMessageSerializer, Pong};
|
||||
use crate::util::fnv;
|
||||
@@ -76,7 +76,7 @@ impl FeedConnector {
|
||||
}
|
||||
|
||||
fn handle_cmd(&mut self, cmd: &str, payload: &str, ctx: &mut <Self as Actor>::Context) {
|
||||
match cmd {
|
||||
match cmd {
|
||||
"subscribe" => {
|
||||
match fnv(payload) {
|
||||
hash if hash == self.chain_hash => return,
|
||||
@@ -99,6 +99,18 @@ impl FeedConnector {
|
||||
})
|
||||
.wait(ctx);
|
||||
}
|
||||
"send-finality" => {
|
||||
self.aggregator.do_send(SendFinality {
|
||||
chain: payload.into(),
|
||||
fid: self.fid_chain,
|
||||
});
|
||||
}
|
||||
"no-more-finality" => {
|
||||
self.aggregator.do_send(NoMoreFinality {
|
||||
chain: payload.into(),
|
||||
fid: self.fid_chain,
|
||||
});
|
||||
}
|
||||
"ping" => {
|
||||
self.serializer.push(Pong(payload));
|
||||
if let Some(serialized) = self.serializer.finalize() {
|
||||
@@ -141,6 +153,8 @@ impl StreamHandler<ws::Message, ws::ProtocolError> for FeedConnector {
|
||||
let cmd = &text[..idx];
|
||||
let payload = &text[idx+1..];
|
||||
|
||||
info!("New FEED message: {}", cmd);
|
||||
|
||||
self.handle_cmd(cmd, payload, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user