mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 05:47:58 +00:00
remote-externalities: batch insert key/values (#14004)
* add batch inserting into remote externalities * use into_iter * remove redundant comment * redundant batch insert * avoid extra vec allocations
This commit is contained in:
@@ -132,6 +132,17 @@ where
|
||||
self.offchain_db.clone()
|
||||
}
|
||||
|
||||
/// Batch insert key/values into backend
|
||||
pub fn batch_insert<I>(&mut self, kvs: I)
|
||||
where
|
||||
I: IntoIterator<Item = (StorageKey, StorageValue)>,
|
||||
{
|
||||
self.backend.insert(
|
||||
Some((None, kvs.into_iter().map(|(k, v)| (k, Some(v))).collect())),
|
||||
self.state_version,
|
||||
);
|
||||
}
|
||||
|
||||
/// Insert key/value into backend
|
||||
pub fn insert(&mut self, k: StorageKey, v: StorageValue) {
|
||||
self.backend.insert(vec![(None, vec![(k, Some(v))])], self.state_version);
|
||||
|
||||
Reference in New Issue
Block a user