From 1285561c3f108f1e054a254a283c96e360bb0604 Mon Sep 17 00:00:00 2001 From: teor Date: Fri, 4 Sep 2020 19:05:53 +1000 Subject: [PATCH] Perform serialised block writes to the state As per the state design RFC 0005. --- zebra-state/src/on_disk.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/zebra-state/src/on_disk.rs b/zebra-state/src/on_disk.rs index e1ac5a35d..84bb58468 100644 --- a/zebra-state/src/on_disk.rs +++ b/zebra-state/src/on_disk.rs @@ -133,7 +133,12 @@ impl Service 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();