Perform serialised block writes to the state
As per the state design RFC 0005.
This commit is contained in:
parent
6a79953ab6
commit
1285561c3f
|
@ -133,7 +133,12 @@ impl Service<Request> for SledState {
|
||||||
Request::AddBlock { block } => {
|
Request::AddBlock { block } => {
|
||||||
let mut storage = self.clone();
|
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 } => {
|
Request::GetBlock { hash } => {
|
||||||
let storage = self.clone();
|
let storage = self.clone();
|
||||||
|
|
Loading…
Reference in New Issue