mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 04:41:02 +00:00
Strip out old XCMP primitives (#823)
* WIP * WIp * Mostly get tests to compile * Fix adder collator * Remove more stuff * Revert some changes to av store * Fix av store tests * Nitpicks * Restore some things * Small changes * Remvoe unused error variants
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
use codec::{Encode, Decode};
|
||||
use reed_solomon::galois_16::{self, ReedSolomon};
|
||||
use primitives::{Hash as H256, BlakeTwo256, HashT};
|
||||
use primitives::parachain::{BlockData, AvailableMessages};
|
||||
use primitives::parachain::BlockData;
|
||||
use sp_core::Blake2Hasher;
|
||||
use trie::{EMPTY_PREFIX, MemoryDB, Trie, TrieMut, trie_types::{TrieDBMut, TrieDB}};
|
||||
|
||||
@@ -125,11 +125,11 @@ fn code_params(n_validators: usize) -> Result<CodeParams, Error> {
|
||||
/// Obtain erasure-coded chunks, one for each validator.
|
||||
///
|
||||
/// Works only up to 65536 validators, and `n_validators` must be non-zero.
|
||||
pub fn obtain_chunks(n_validators: usize, block_data: &BlockData, outgoing: Option<&AvailableMessages>)
|
||||
pub fn obtain_chunks(n_validators: usize, block_data: &BlockData)
|
||||
-> Result<Vec<Vec<u8>>, Error>
|
||||
{
|
||||
let params = code_params(n_validators)?;
|
||||
let encoded = (block_data, outgoing).encode();
|
||||
let encoded = block_data.encode();
|
||||
|
||||
if encoded.is_empty() {
|
||||
return Err(Error::BadPayload);
|
||||
@@ -151,7 +151,7 @@ pub fn obtain_chunks(n_validators: usize, block_data: &BlockData, outgoing: Opti
|
||||
///
|
||||
/// Works only up to 65536 validators, and `n_validators` must be non-zero.
|
||||
pub fn reconstruct<'a, I: 'a>(n_validators: usize, chunks: I)
|
||||
-> Result<(BlockData, Option<AvailableMessages>), Error>
|
||||
-> Result<BlockData, Error>
|
||||
where I: IntoIterator<Item=(&'a [u8], usize)>
|
||||
{
|
||||
let params = code_params(n_validators)?;
|
||||
@@ -402,11 +402,9 @@ mod tests {
|
||||
#[test]
|
||||
fn round_trip_block_data() {
|
||||
let block_data = BlockData((0..255).collect());
|
||||
let ex = Some(AvailableMessages(Vec::new()));
|
||||
let chunks = obtain_chunks(
|
||||
10,
|
||||
&block_data,
|
||||
ex.as_ref(),
|
||||
).unwrap();
|
||||
|
||||
assert_eq!(chunks.len(), 10);
|
||||
@@ -422,18 +420,16 @@ mod tests {
|
||||
].iter().cloned(),
|
||||
).unwrap();
|
||||
|
||||
assert_eq!(reconstructed, (block_data, ex));
|
||||
assert_eq!(reconstructed, block_data);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn construct_valid_branches() {
|
||||
let block_data = BlockData(vec![2; 256]);
|
||||
let ex = Some(AvailableMessages(Vec::new()));
|
||||
|
||||
let chunks = obtain_chunks(
|
||||
10,
|
||||
&block_data,
|
||||
ex.as_ref(),
|
||||
).unwrap();
|
||||
|
||||
assert_eq!(chunks.len(), 10);
|
||||
|
||||
Reference in New Issue
Block a user