Perform serialised block writes to the state

As per the state design RFC 0005.
This commit is contained in:
teor 2020-09-04 19:05:53 +10:00 committed by Henry de Valence
parent 6a79953ab6
commit 1285561c3f
1 changed files with 6 additions and 1 deletions

View File

@ -133,7 +133,12 @@ impl Service<Request> for SledState {
Request::AddBlock { block } => {
let mut storage = self.clone();
async move { storage.insert(block).map(|hash| Response::Added { hash }) }.boxed()
// Make sure writes to the state are serialised, by performing
// them in the state's call.
// (See the state design RFC #0005 for details.)
let result = storage.insert(block).map(|hash| Response::Added { hash });
async { result }.boxed()
}
Request::GetBlock { hash } => {
let storage = self.clone();