Просмотр исходного кода

gateway: don't panic when local slabstore index is higher than gateway's slabstore index

ghassmo 4 лет назад
Родитель
Сommit
eecf039924
1 измененных файлов с 8 добавлено и 1 удалено
  1. 8 1
      src/service/gateway.rs

+ 8 - 1
src/service/gateway.rs

@@ -220,11 +220,18 @@ impl GatewayClient {
 
     pub async fn sync(&mut self) -> Result<u64> {
         debug!(target: "GATEWAY CLIENT", "Start Syncing");
+
         let local_last_index = self.slabstore.get_last_index()?;
 
         let last_index = self.get_last_index().await?;
 
-        assert!(last_index >= local_last_index);
+        if last_index < local_last_index {
+            return Err(Error::SlabsStore(
+                "Local slabstore has higher index than gateway's slabstore.
+                 Delete slabstore database \"darkfid_client.db\" and wallet database 
+                 \" darkfid_wallet.db\" in config directory.".into(),
+            ));
+        }
 
         if last_index > 0 {
             for index in (local_last_index + 1)..(last_index + 1) {