mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 17:31:05 +00:00
Improve Network Spans (#2169)
* utility functions for erasure-coding threshold * add candidate-hash tag to candidate jaeger spans * debug implementation for jaeger span * add a span to each live candidate in availability dist. * availability span covers only our piece * fix tests * keep span alive slightly longer * remove spammy bitfield-gossip-received log * Revert "remove spammy bitfield-gossip-received log" This reverts commit 831a2db506d66f64ea516af3caf891e8643f5c43. * add claimed validator to bitfield-gossip span * add peer-id to handle-incoming span * add peer-id to availability distribution span * Update node/network/availability-distribution/src/lib.rs Co-authored-by: Bernhard Schuster <bernhard@ahoi.io> * Update erasure-coding/src/lib.rs Co-authored-by: Bernhard Schuster <bernhard@ahoi.io> * Update node/subsystem/src/jaeger.rs Co-authored-by: Bernhard Schuster <bernhard@ahoi.io> Co-authored-by: Bernhard Schuster <bernhard@ahoi.io>
This commit is contained in:
committed by
GitHub
parent
a864eaa093
commit
41102a6ff9
@@ -119,12 +119,18 @@ impl CodeParams {
|
||||
.expect("this struct is not created with invalid shard number; qed")
|
||||
}
|
||||
}
|
||||
|
||||
fn code_params(n_validators: usize) -> Result<CodeParams, Error> {
|
||||
/// Returns the maximum number of allowed, faulty chunks
|
||||
/// which does not prevent recovery given all other pieces
|
||||
/// are correct.
|
||||
const fn n_faulty(n_validators: usize) -> Result<usize, Error> {
|
||||
if n_validators > MAX_VALIDATORS { return Err(Error::TooManyValidators) }
|
||||
if n_validators <= 1 { return Err(Error::NotEnoughValidators) }
|
||||
|
||||
let n_faulty = n_validators.saturating_sub(1) / 3;
|
||||
Ok(n_validators.saturating_sub(1) / 3)
|
||||
}
|
||||
|
||||
fn code_params(n_validators: usize) -> Result<CodeParams, Error> {
|
||||
let n_faulty = n_faulty(n_validators)?;
|
||||
let n_good = n_validators - n_faulty;
|
||||
|
||||
Ok(CodeParams {
|
||||
@@ -133,6 +139,13 @@ fn code_params(n_validators: usize) -> Result<CodeParams, Error> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Obtain a threshold of chunks that should be enough to recover the data.
|
||||
pub fn recovery_threshold(n_validators: usize) -> Result<usize, Error> {
|
||||
let n_faulty = n_faulty(n_validators)?;
|
||||
|
||||
Ok(n_faulty + 1)
|
||||
}
|
||||
|
||||
/// Obtain erasure-coded chunks for v0 `AvailableData`, one for each validator.
|
||||
///
|
||||
/// Works only up to 65536 validators, and `n_validators` must be non-zero.
|
||||
|
||||
Reference in New Issue
Block a user