Scheduler Messages (#30976)

This commit is contained in:
Andrew Fitzgerald 2023-04-19 15:14:47 -07:00 committed by GitHub
parent 37ab00d361
commit 7a393e479d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 57 additions and 0 deletions

View File

@ -48,6 +48,8 @@ pub mod consumer;
mod decision_maker;
mod forwarder;
mod packet_receiver;
#[allow(dead_code)]
mod scheduler_messages;
#[allow(dead_code)]
mod thread_aware_account_locks;

View File

@ -0,0 +1,55 @@
use {
crate::immutable_deserialized_packet::ImmutableDeserializedPacket,
solana_sdk::{clock::Slot, transaction::SanitizedTransaction},
std::sync::Arc,
};
/// A unique identifier for a transaction batch.
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
pub struct TransactionBatchId(u64);
impl TransactionBatchId {
pub fn new(index: u64) -> Self {
Self(index)
}
}
/// A unique identifier for a transaction.
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
pub struct TransactionId(u64);
impl TransactionId {
pub fn new(index: u64) -> Self {
Self(index)
}
}
/// Message: [Scheduler -> Worker]
/// Transactions to be consumed (i.e. executed, recorded, and committed)
pub struct ConsumeWork {
pub batch_id: TransactionBatchId,
pub ids: Vec<TransactionId>,
pub transactions: Vec<SanitizedTransaction>,
pub max_age_slots: Vec<Slot>,
}
/// Message: [Scheduler -> Worker]
/// Transactions to be forwarded to the next leader(s)
pub struct ForwardWork {
pub ids: Vec<TransactionId>,
pub packets: Vec<Arc<ImmutableDeserializedPacket>>,
}
/// Message: [Worker -> Scheduler]
/// Processed transactions.
pub struct FinishedConsumeWork {
pub work: ConsumeWork,
pub retryable_indexes: Vec<usize>,
}
/// Message: [Worker -> Scheduler]
/// Forwarded transactions.
pub struct FinishedForwardWork {
pub work: ForwardWork,
pub successful: bool,
}