Availability store pruning (#1820)

* Initial commit

* Move tests to separate module

* Move timestamps to the newtype

* Change idx name

* Use Duration for consts and update chunk records

* Ordering::Equal

* Update node/core/av-store/src/lib.rs

Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>

* put_ methods do the array sorting

* Fix get_block_number

* Change StoreChunk message type and relay parent method

* Add chunk tests

* Fix block number computation for StoreChunk

* Duration instead of u64 everywhere

* Add a clarifying comment

Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
This commit is contained in:
Fedor Sakharov
2020-10-24 09:03:57 +03:00
committed by GitHub
parent da121e4183
commit ec49d81307
6 changed files with 1575 additions and 278 deletions
@@ -661,6 +661,7 @@ where
if let Err(_e) = store_chunk(
ctx,
message.candidate_hash.clone(),
live_candidate.descriptor.relay_parent.clone(),
message.erasure_chunk.index,
message.erasure_chunk.clone(),
).await? {
@@ -949,6 +950,7 @@ where
async fn store_chunk<Context>(
ctx: &mut Context,
candidate_hash: Hash,
relay_parent: Hash,
validator_index: ValidatorIndex,
erasure_chunk: ErasureChunk,
) -> Result<std::result::Result<(), ()>>
@@ -957,7 +959,13 @@ where
{
let (tx, rx) = oneshot::channel();
ctx.send_message(AllMessages::AvailabilityStore(
AvailabilityStoreMessage::StoreChunk(candidate_hash, validator_index, erasure_chunk, tx),
AvailabilityStoreMessage::StoreChunk {
candidate_hash,
relay_parent,
validator_index,
chunk: erasure_chunk,
tx,
}
)).await?;
rx.await.map_err::<Error, _>(Into::into)
}