Skip to content

Commit

Permalink
feat(network): add tx submission and tx monitor clients to network fa…
Browse files Browse the repository at this point in the history
…cades (#442)

* added txsubmission client to network facades
* added txmonitor::client to network facades
  • Loading branch information
thalerjonathan authored Jun 29, 2024
1 parent 07033eb commit 520079d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
19 changes: 17 additions & 2 deletions pallas-network/src/facades.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ use tokio::net::{unix::SocketAddr as UnixSocketAddr, UnixListener};
use crate::miniprotocols::handshake::{n2c, n2n, Confirmation, VersionNumber};

Check warning on line 12 in pallas-network/src/facades.rs

View workflow job for this annotation

GitHub Actions / Check (windows-latest, stable)

unused imports: `Confirmation`, `VersionNumber`, `n2c`

use crate::miniprotocols::{
blockfetch, chainsync, handshake, keepalive, localstate, txsubmission, PROTOCOL_N2C_CHAIN_SYNC,
PROTOCOL_N2C_HANDSHAKE, PROTOCOL_N2C_STATE_QUERY, PROTOCOL_N2N_BLOCK_FETCH,
blockfetch, chainsync, handshake, keepalive, localstate, localtxsubmission, txmonitor,
txsubmission, PROTOCOL_N2C_CHAIN_SYNC, PROTOCOL_N2C_HANDSHAKE, PROTOCOL_N2C_STATE_QUERY,
PROTOCOL_N2C_TX_MONITOR, PROTOCOL_N2C_TX_SUBMISSION, PROTOCOL_N2N_BLOCK_FETCH,
PROTOCOL_N2N_CHAIN_SYNC, PROTOCOL_N2N_HANDSHAKE, PROTOCOL_N2N_KEEP_ALIVE,
PROTOCOL_N2N_TX_SUBMISSION,
};
Expand Down Expand Up @@ -285,6 +286,8 @@ pub struct NodeClient {
handshake: handshake::N2CClient,
chainsync: chainsync::N2CClient,
statequery: localstate::Client,
submission: localtxsubmission::Client,
monitor: txmonitor::Client,
}

impl NodeClient {
Expand All @@ -294,6 +297,8 @@ impl NodeClient {
let hs_channel = plexer.subscribe_client(PROTOCOL_N2C_HANDSHAKE);
let cs_channel = plexer.subscribe_client(PROTOCOL_N2C_CHAIN_SYNC);
let sq_channel = plexer.subscribe_client(PROTOCOL_N2C_STATE_QUERY);
let tx_channel = plexer.subscribe_client(PROTOCOL_N2C_TX_SUBMISSION);
let mo_channel = plexer.subscribe_client(PROTOCOL_N2C_TX_MONITOR);

let plexer = plexer.spawn();

Expand All @@ -302,6 +307,8 @@ impl NodeClient {
handshake: handshake::Client::new(hs_channel),
chainsync: chainsync::Client::new(cs_channel),
statequery: localstate::Client::new(sq_channel),
submission: localtxsubmission::Client::new(tx_channel),
monitor: txmonitor::Client::new(mo_channel),
}
}

Expand Down Expand Up @@ -406,6 +413,14 @@ impl NodeClient {
&mut self.statequery
}

pub fn submission(&mut self) -> &mut localtxsubmission::Client {
&mut self.submission
}

pub fn monitor(&mut self) -> &mut txmonitor::Client {
&mut self.monitor
}

pub async fn abort(self) {
self.plexer.abort().await
}
Expand Down
3 changes: 3 additions & 0 deletions pallas-network/src/miniprotocols/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ pub const PROTOCOL_N2C_TX_SUBMISSION: u16 = 6;
// Protocol channel number for node-to-client state queries
pub const PROTOCOL_N2C_STATE_QUERY: u16 = 7;

// Protocol channel number for node-to-client mempool monitor
pub const PROTOCOL_N2C_TX_MONITOR: u16 = 9;

/// A point within a chain
#[derive(Clone, Eq, PartialEq, Hash)]
pub enum Point {
Expand Down

0 comments on commit 520079d

Please sign in to comment.