Making all transfered types repr(C), renaming dispatch
This commit is contained in:
parent
a8d5bd03f1
commit
38e70b06de
|
@ -148,7 +148,7 @@ mod tests {
|
|||
notify_server_start.notify_one();
|
||||
notify_subscription.notified().await;
|
||||
for msg in msgs {
|
||||
connection_manager.dispach(msg, 10).await;
|
||||
connection_manager.dispatch(msg, 10).await;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[repr(C)]
|
||||
pub enum CompressionType {
|
||||
None,
|
||||
Lz4Fast(u32),
|
||||
|
|
|
@ -6,6 +6,7 @@ use solana_sdk::{pubkey::Pubkey, signature::Signature};
|
|||
use crate::message::Message;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
|
||||
#[repr(C)]
|
||||
pub enum Filter {
|
||||
Account(AccountFilter),
|
||||
Slot,
|
||||
|
@ -39,6 +40,7 @@ impl Filter {
|
|||
|
||||
// setting owner to 11111111111111111111111111111111 will subscribe to all the accounts
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
|
||||
#[repr(C)]
|
||||
pub struct AccountFilter {
|
||||
pub owner: Option<Pubkey>,
|
||||
pub accounts: Option<HashSet<Pubkey>>,
|
||||
|
|
|
@ -11,6 +11,7 @@ use crate::{
|
|||
};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
|
||||
#[repr(C)]
|
||||
pub enum Message {
|
||||
AccountMsg(Account),
|
||||
SlotMsg(SlotMeta),
|
||||
|
|
|
@ -187,7 +187,7 @@ impl ConnectionManager {
|
|||
});
|
||||
}
|
||||
|
||||
pub async fn dispach(&self, message: Message, retry_count: u64) {
|
||||
pub async fn dispatch(&self, message: Message, retry_count: u64) {
|
||||
let lk = self.connections.read().await;
|
||||
|
||||
for connection_data in lk.iter() {
|
||||
|
|
|
@ -93,15 +93,15 @@ impl QuicServer {
|
|||
parent,
|
||||
commitment_level,
|
||||
});
|
||||
quic_connection_manager.dispach(message, retry_count).await;
|
||||
quic_connection_manager.dispatch(message, retry_count).await;
|
||||
}
|
||||
ChannelMessage::BlockMeta(block_meta) => {
|
||||
let message = Message::BlockMetaMsg(block_meta);
|
||||
quic_connection_manager.dispach(message, retry_count).await;
|
||||
quic_connection_manager.dispatch(message, retry_count).await;
|
||||
}
|
||||
ChannelMessage::Transaction(transaction) => {
|
||||
let message = Message::TransactionMsg(transaction);
|
||||
quic_connection_manager.dispach(message, retry_count).await;
|
||||
quic_connection_manager.dispatch(message, retry_count).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -140,6 +140,6 @@ fn process_account_message(
|
|||
);
|
||||
|
||||
let message = Message::AccountMsg(geyser_account);
|
||||
quic_connection_manager.dispach(message, retry_count).await;
|
||||
quic_connection_manager.dispatch(message, retry_count).await;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ pub async fn recv_message(
|
|||
let size_bytes: [u8; 8] = size_bytes.try_into().unwrap();
|
||||
let size = u64::from_le_bytes(size_bytes) as usize;
|
||||
let mut buffer: Vec<u8> = vec![0; size];
|
||||
while let Some(data) = recv_stream.read_chunk(size, false).await? {
|
||||
while let Some(data) = tokio::time::timeout(Duration::from_secs(1), recv_stream.read_chunk(size, false)).await?? {
|
||||
let bytes = data.bytes.to_vec();
|
||||
let offset = data.offset - 8;
|
||||
let begin_offset = offset as usize;
|
||||
|
|
|
@ -6,6 +6,7 @@ use crate::compression::CompressionType;
|
|||
use super::slot_identifier::SlotIdentifier;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[repr(C)]
|
||||
pub struct Account {
|
||||
pub slot_identifier: SlotIdentifier,
|
||||
pub pubkey: Pubkey,
|
||||
|
|
|
@ -3,6 +3,7 @@ use solana_sdk::commitment_config::CommitmentLevel;
|
|||
use solana_transaction_status::Reward;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
|
||||
#[repr(C)]
|
||||
pub struct SlotMeta {
|
||||
pub slot: u64,
|
||||
pub parent: u64,
|
||||
|
@ -10,6 +11,7 @@ pub struct SlotMeta {
|
|||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
|
||||
#[repr(C)]
|
||||
pub struct BlockMeta {
|
||||
pub parent_slot: u64,
|
||||
pub slot: u64,
|
||||
|
|
|
@ -5,6 +5,7 @@ use crate::quic::configure_client::{
|
|||
};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
|
||||
#[repr(C)]
|
||||
pub struct ConnectionParameters {
|
||||
pub max_number_of_streams: u32,
|
||||
pub streams_for_slot_data: u32,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[repr(C)]
|
||||
pub struct SlotIdentifier {
|
||||
pub slot: u64,
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ use solana_transaction_status::{InnerInstructions, Rewards};
|
|||
use super::slot_identifier::SlotIdentifier;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
|
||||
#[repr(C)]
|
||||
pub struct TransactionMeta {
|
||||
pub error: Option<TransactionError>,
|
||||
pub fee: u64,
|
||||
|
@ -24,6 +25,7 @@ pub struct TransactionMeta {
|
|||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
|
||||
#[repr(C)]
|
||||
pub struct Transaction {
|
||||
pub slot_identifier: SlotIdentifier,
|
||||
pub signatures: Vec<Signature>,
|
||||
|
|
Loading…
Reference in New Issue