mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-09 17:37:26 +00:00
Availability store subsystem (#1404)
* Initial commit * WIP * Make atomic transactions * Remove pruning code * Fix build and add a Nop to bridge * Fixes from review * Move config struct around for clarity * Rename constructor and warn on missing docs * Fix a test and rename a message * Fix some more reviews * Obviously failed to rebase cleanly
This commit is contained in:
@@ -25,11 +25,11 @@
|
||||
use futures::channel::{mpsc, oneshot};
|
||||
|
||||
use polkadot_primitives::v1::{
|
||||
BlockNumber, Hash,
|
||||
CandidateReceipt, CommittedCandidateReceipt, PoV, ErasureChunk, BackedCandidate, Id as ParaId,
|
||||
BlockNumber, Hash, CommittedCandidateReceipt,
|
||||
CandidateReceipt, PoV, ErasureChunk, BackedCandidate, Id as ParaId,
|
||||
SignedAvailabilityBitfield, SigningContext, ValidatorId, ValidationCode, ValidatorIndex,
|
||||
CoreAssignment, CoreOccupied, HeadData, CandidateDescriptor,
|
||||
ValidatorSignature, OmittedValidationData,
|
||||
ValidatorSignature, OmittedValidationData, AvailableData,
|
||||
};
|
||||
use polkadot_node_primitives::{
|
||||
MisbehaviorReport, SignedFullStatement, View, ProtocolId, ValidationResult,
|
||||
@@ -235,31 +235,40 @@ impl BitfieldSigningMessage {
|
||||
/// Availability store subsystem message.
|
||||
#[derive(Debug)]
|
||||
pub enum AvailabilityStoreMessage {
|
||||
/// Query a `PoV` from the AV store.
|
||||
QueryPoV(Hash, oneshot::Sender<Option<PoV>>),
|
||||
/// Query a `AvailableData` from the AV store.
|
||||
QueryAvailableData(Hash, oneshot::Sender<Option<AvailableData>>),
|
||||
|
||||
/// Query whether a `PoV` exists within the AV Store.
|
||||
/// Query whether a `AvailableData` exists within the AV Store.
|
||||
///
|
||||
/// This is useful in cases like bitfield signing, when existence
|
||||
/// matters, but we don't want to necessarily pass around multiple
|
||||
/// megabytes of data to get a single bit of information.
|
||||
QueryPoVAvailable(Hash, oneshot::Sender<bool>),
|
||||
QueryDataAvailability(Hash, oneshot::Sender<bool>),
|
||||
|
||||
/// Query an `ErasureChunk` from the AV store.
|
||||
QueryChunk(Hash, ValidatorIndex, oneshot::Sender<ErasureChunk>),
|
||||
QueryChunk(Hash, ValidatorIndex, oneshot::Sender<Option<ErasureChunk>>),
|
||||
|
||||
/// Store an `ErasureChunk` in the AV store.
|
||||
StoreChunk(Hash, ValidatorIndex, ErasureChunk),
|
||||
///
|
||||
/// Return `Ok(())` if the store operation succeeded, `Err(())` if it failed.
|
||||
StoreChunk(Hash, ValidatorIndex, ErasureChunk, oneshot::Sender<Result<(), ()>>),
|
||||
|
||||
/// Store a `AvailableData` in the AV store.
|
||||
/// If `ValidatorIndex` is present store corresponding chunk also.
|
||||
///
|
||||
/// Return `Ok(())` if the store operation succeeded, `Err(())` if it failed.
|
||||
StoreAvailableData(Hash, Option<ValidatorIndex>, u32, AvailableData, oneshot::Sender<Result<(), ()>>),
|
||||
}
|
||||
|
||||
impl AvailabilityStoreMessage {
|
||||
/// If the current variant contains the relay parent hash, return it.
|
||||
pub fn relay_parent(&self) -> Option<Hash> {
|
||||
match self {
|
||||
Self::QueryPoV(hash, _) => Some(*hash),
|
||||
Self::QueryPoVAvailable(hash, _) => Some(*hash),
|
||||
Self::QueryAvailableData(hash, _) => Some(*hash),
|
||||
Self::QueryDataAvailability(hash, _) => Some(*hash),
|
||||
Self::QueryChunk(hash, _, _) => Some(*hash),
|
||||
Self::StoreChunk(hash, _, _) => Some(*hash),
|
||||
Self::StoreChunk(hash, _, _, _) => Some(*hash),
|
||||
Self::StoreAvailableData(hash, _, _, _, _) => Some(*hash),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user