mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 09:21:05 +00:00
Vendored
+2
-1
@@ -342,8 +342,9 @@ impl<Block: BlockT> BlockchainCache<Block> for DbCacheSync<Block> {
|
||||
EntryType::Genesis,
|
||||
)?;
|
||||
let tx_ops = tx.into_ops();
|
||||
db.commit(dbtx);
|
||||
db.commit(dbtx)?;
|
||||
cache.commit(tx_ops)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -719,7 +719,7 @@ mod tests {
|
||||
None,
|
||||
None,
|
||||
).unwrap();
|
||||
backend.storage.db.commit(tx);
|
||||
backend.storage.db.commit(tx).unwrap();
|
||||
backend.changes_tries_storage.post_commit(Some(cache_ops));
|
||||
};
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ mod tests {
|
||||
children2.push(1_6);
|
||||
write_children(&mut tx, 0, PREFIX, 1_2, children2);
|
||||
|
||||
db.commit(tx.clone());
|
||||
db.commit(tx.clone()).unwrap();
|
||||
|
||||
let r1: Vec<u32> = read_children(&*db, 0, PREFIX, 1_1).expect("(1) Getting r1 failed");
|
||||
let r2: Vec<u32> = read_children(&*db, 0, PREFIX, 1_2).expect("(1) Getting r2 failed");
|
||||
@@ -108,7 +108,7 @@ mod tests {
|
||||
assert_eq!(r2, vec![1_4, 1_6]);
|
||||
|
||||
remove_children(&mut tx, 0, PREFIX, 1_2);
|
||||
db.commit(tx);
|
||||
db.commit(tx).unwrap();
|
||||
|
||||
let r1: Vec<u32> = read_children(&*db, 0, PREFIX, 1_1).expect("(2) Getting r1 failed");
|
||||
let r2: Vec<u32> = read_children(&*db, 0, PREFIX, 1_2).expect("(2) Getting r2 failed");
|
||||
|
||||
@@ -1243,7 +1243,7 @@ impl<Block: BlockT> Backend<Block> {
|
||||
None
|
||||
};
|
||||
|
||||
self.storage.db.commit(transaction);
|
||||
self.storage.db.commit(transaction)?;
|
||||
|
||||
if let Some((
|
||||
number,
|
||||
@@ -1356,7 +1356,7 @@ impl<Block> sc_client_api::backend::AuxStore for Backend<Block> where Block: Blo
|
||||
for k in delete {
|
||||
transaction.remove(columns::AUX, k);
|
||||
}
|
||||
self.storage.db.commit(transaction);
|
||||
self.storage.db.commit(transaction)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1438,7 +1438,7 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
|
||||
&mut changes_trie_cache_ops,
|
||||
&mut displaced,
|
||||
)?;
|
||||
self.storage.db.commit(transaction);
|
||||
self.storage.db.commit(transaction)?;
|
||||
self.blockchain.update_meta(hash, number, is_best, is_finalized);
|
||||
self.changes_tries_storage.post_commit(changes_trie_cache_ops);
|
||||
Ok(())
|
||||
@@ -1536,7 +1536,7 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
|
||||
transaction.set_from_vec(columns::META, meta_keys::BEST_BLOCK, key);
|
||||
transaction.remove(columns::KEY_LOOKUP, removed.hash().as_ref());
|
||||
children::remove_children(&mut transaction, columns::META, meta_keys::CHILDREN_PREFIX, best_hash);
|
||||
self.storage.db.commit(transaction);
|
||||
self.storage.db.commit(transaction)?;
|
||||
self.changes_tries_storage.post_commit(Some(changes_trie_cache_ops));
|
||||
self.blockchain.update_meta(best_hash, best_number, true, update_finalized);
|
||||
}
|
||||
@@ -1555,7 +1555,7 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
|
||||
|
||||
leaves.revert(best_hash, best_number);
|
||||
leaves.prepare_transaction(&mut transaction, columns::META, meta_keys::LEAF_PREFIX);
|
||||
self.storage.db.commit(transaction);
|
||||
self.storage.db.commit(transaction)?;
|
||||
|
||||
Ok(())
|
||||
};
|
||||
|
||||
@@ -402,7 +402,8 @@ impl<Block> AuxStore for LightStorage<Block>
|
||||
for k in delete {
|
||||
transaction.remove(columns::AUX, k);
|
||||
}
|
||||
self.db.commit(transaction);
|
||||
self.db.commit(transaction)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -495,7 +496,7 @@ impl<Block> Storage<Block> for LightStorage<Block>
|
||||
|
||||
debug!("Light DB Commit {:?} ({})", hash, number);
|
||||
|
||||
self.db.commit(transaction);
|
||||
self.db.commit(transaction)?;
|
||||
cache.commit(cache_ops)
|
||||
.expect("only fails if cache with given name isn't loaded yet;\
|
||||
cache is already loaded because there are cache_ops; qed");
|
||||
@@ -513,8 +514,9 @@ impl<Block> Storage<Block> for LightStorage<Block>
|
||||
|
||||
let mut transaction = Transaction::new();
|
||||
self.set_head_with_transaction(&mut transaction, hash.clone(), (number.clone(), hash.clone()))?;
|
||||
self.db.commit(transaction);
|
||||
self.db.commit(transaction)?;
|
||||
self.update_meta(hash, header.number().clone(), true, false);
|
||||
|
||||
Ok(())
|
||||
} else {
|
||||
Err(ClientError::UnknownBlock(format!("Cannot set head {:?}", id)))
|
||||
@@ -552,7 +554,7 @@ impl<Block> Storage<Block> for LightStorage<Block>
|
||||
)?
|
||||
.into_ops();
|
||||
|
||||
self.db.commit(transaction);
|
||||
self.db.commit(transaction)?;
|
||||
cache.commit(cache_ops)
|
||||
.expect("only fails if cache with given name isn't loaded yet;\
|
||||
cache is already loaded because there are cache_ops; qed");
|
||||
|
||||
@@ -25,6 +25,7 @@ use std::{
|
||||
|
||||
use crate::{columns, Database, DbHash, Transaction};
|
||||
use parking_lot::Mutex;
|
||||
use log::error;
|
||||
|
||||
/// Offchain local storage
|
||||
#[derive(Clone)]
|
||||
@@ -64,7 +65,9 @@ impl sp_core::offchain::OffchainStorage for LocalStorage {
|
||||
let mut tx = Transaction::new();
|
||||
tx.set(columns::OFFCHAIN, &key, value);
|
||||
|
||||
self.db.commit(tx);
|
||||
if let Err(err) = self.db.commit(tx) {
|
||||
error!("Error setting on local storage: {}", err)
|
||||
}
|
||||
}
|
||||
|
||||
fn remove(&mut self, prefix: &[u8], key: &[u8]) {
|
||||
@@ -72,7 +75,9 @@ impl sp_core::offchain::OffchainStorage for LocalStorage {
|
||||
let mut tx = Transaction::new();
|
||||
tx.remove(columns::OFFCHAIN, &key);
|
||||
|
||||
self.db.commit(tx);
|
||||
if let Err(err) = self.db.commit(tx) {
|
||||
error!("Error removing on local storage: {}", err)
|
||||
}
|
||||
}
|
||||
|
||||
fn get(&self, prefix: &[u8], key: &[u8]) -> Option<Vec<u8>> {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
/// A `Database` adapter for parity-db.
|
||||
|
||||
use sp_database::{Database, Change, Transaction, ColumnId};
|
||||
use sp_database::{Database, Change, ColumnId, Transaction, error::DatabaseError};
|
||||
use crate::utils::NUM_COLUMNS;
|
||||
use crate::columns;
|
||||
|
||||
@@ -44,7 +44,7 @@ pub fn open<H: Clone>(path: &std::path::Path) -> parity_db::Result<std::sync::Ar
|
||||
}
|
||||
|
||||
impl<H: Clone> Database<H> for DbAdapter {
|
||||
fn commit(&self, transaction: Transaction<H>) {
|
||||
fn commit(&self, transaction: Transaction<H>) -> Result<(), DatabaseError> {
|
||||
handle_err(self.0.commit(transaction.0.into_iter().map(|change|
|
||||
match change {
|
||||
Change::Set(col, key, value) => (col as u8, key, Some(value)),
|
||||
@@ -52,6 +52,8 @@ impl<H: Clone> Database<H> for DbAdapter {
|
||||
_ => unimplemented!(),
|
||||
}))
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get(&self, col: ColumnId, key: &[u8]) -> Option<Vec<u8>> {
|
||||
|
||||
@@ -297,7 +297,7 @@ pub fn check_database_type(db: &dyn Database<DbHash>, db_type: DatabaseType) ->
|
||||
None => {
|
||||
let mut transaction = Transaction::new();
|
||||
transaction.set(COLUMN_META, meta_keys::TYPE, db_type.as_str().as_bytes());
|
||||
db.commit(transaction)
|
||||
db.commit(transaction)?;
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user