Skip to content

Commit ab99c9d

Browse files
committed
Remove todo macros
1 parent c2ea7ca commit ab99c9d

File tree

12 files changed

+39
-21
lines changed

12 files changed

+39
-21
lines changed

src/chain/store/chain_store.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ mod tests {
761761
db.clone(),
762762
db.clone(),
763763
db.clone(),
764-
todo!(),
764+
db,
765765
chain_config,
766766
gen_block.clone(),
767767
)
@@ -783,7 +783,7 @@ mod tests {
783783
db.clone(),
784784
db.clone(),
785785
db.clone(),
786-
todo!(),
786+
db,
787787
chain_config,
788788
gen_block,
789789
)

src/daemon/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::daemon::db_util::load_all_forest_cars;
1010
use crate::db::car::ManyCar;
1111
use crate::db::db_engine::{db_root, open_db};
1212
use crate::db::parity_db::ParityDb;
13-
use crate::db::{DummyStore, EthMappingsStore, IndicesStore, CAR_DB_DIR_NAME};
13+
use crate::db::{DummyStore, EthMappingsStore, CAR_DB_DIR_NAME};
1414
use crate::genesis::read_genesis_header;
1515
use crate::libp2p::{Keypair, PeerId};
1616
use crate::networks::ChainConfig;

src/db/gc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ mod test {
286286
db.clone(),
287287
db.clone(),
288288
db.clone(),
289-
todo!(),
289+
db.clone(),
290290
Arc::new(config),
291291
gen_block,
292292
)

src/db/memory.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub struct MemoryDB {
2222
blockchain_persistent_db: RwLock<HashMap<Cid, Vec<u8>>>,
2323
settings_db: RwLock<HashMap<String, Vec<u8>>>,
2424
pub eth_mappings_db: RwLock<HashMap<EthHash, Vec<u8>>>,
25+
pub indices_db: RwLock<HashMap<Cid, Vec<u8>>>,
2526
}
2627

2728
impl MemoryDB {
@@ -135,15 +136,18 @@ impl EthMappingsStore for MemoryDB {
135136

136137
impl IndicesStore for MemoryDB {
137138
fn read_bin(&self, key: &Cid) -> anyhow::Result<Option<Vec<u8>>> {
138-
todo!()
139+
Ok(self.indices_db.read().get(key).cloned())
139140
}
140141

141142
fn write_bin(&self, key: &Cid, value: &[u8]) -> anyhow::Result<()> {
142-
todo!()
143+
self.indices_db
144+
.write()
145+
.insert(key.to_owned(), value.to_vec());
146+
Ok(())
143147
}
144148

145149
fn exists(&self, key: &Cid) -> anyhow::Result<bool> {
146-
todo!()
150+
Ok(self.indices_db.read().contains_key(key))
147151
}
148152
}
149153

src/libp2p/chain_exchange/provider.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,10 @@ mod tests {
176176

177177
let response = make_chain_exchange_response(
178178
&ChainStore::new(
179+
db.clone(),
179180
db.clone(),
180181
db.clone(),
181182
db,
182-
todo!(),
183183
Arc::new(ChainConfig::default()),
184184
gen_block,
185185
)

src/rpc/methods/chain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,7 @@ mod tests {
10451045
db,
10461046
Arc::new(MemoryDB::default()),
10471047
Arc::new(MemoryDB::default()),
1048-
todo!(),
1048+
Arc::new(MemoryDB::default()),
10491049
Arc::new(ChainConfig::calibnet()),
10501050
genesis_block_header,
10511051
)

src/rpc/methods/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,10 @@ mod tests {
193193

194194
let cs_arc = Arc::new(
195195
ChainStore::new(
196+
db.clone(),
196197
db.clone(),
197198
db.clone(),
198199
db,
199-
todo!(),
200200
chain_config.clone(),
201201
genesis_header,
202202
)

src/tool/offline_server/server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,16 @@ pub async fn start_offline_server(
6767
&db,
6868
)
6969
.await?;
70+
let head_ts = Arc::new(db.heaviest_tipset()?);
7071
let chain_store = Arc::new(ChainStore::new(
7172
db.clone(),
7273
db.clone(),
7374
db.clone(),
74-
todo!(),
75+
db.clone(),
7576
chain_config.clone(),
7677
genesis_header.clone(),
7778
)?);
7879
let state_manager = Arc::new(StateManager::new(chain_store.clone(), chain_config)?);
79-
let head_ts = Arc::new(db.heaviest_tipset()?);
8080

8181
populate_eth_mappings(&state_manager, &head_ts)?;
8282

src/tool/subcommands/api_cmd/api_compare_tests.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// SPDX-License-Identifier: Apache-2.0, MIT
33
use crate::blocks::{ElectionProof, Ticket, Tipset};
44
use crate::chain::ChainStore;
5-
use crate::chain_sync::SyncConfig;
65
use crate::db::car::ManyCar;
76
use crate::eth::{EthChainId as EthChainIdType, SAFE_EPOCH_DELAY};
87
use crate::lotus_json::HasLotusJson;
@@ -53,7 +52,7 @@ use serde::de::DeserializeOwned;
5352
use serde::{Deserialize, Serialize};
5453
use serde_json::Value;
5554
use similar::{ChangeTag, TextDiff};
56-
use std::{borrow::Cow, path::Path, path::PathBuf, str::FromStr, sync::Arc, time::Duration};
55+
use std::{borrow::Cow, path::PathBuf, str::FromStr, sync::Arc, time::Duration};
5756
use tabled::{builder::Builder, settings::Style};
5857
use tokio::sync::Semaphore;
5958
use tracing::debug;
@@ -1933,7 +1932,6 @@ pub(super) async fn create_tests(
19331932
tests.extend(f3_tests()?);
19341933
if !snapshot_files.is_empty() {
19351934
let store = Arc::new(ManyCar::try_from(snapshot_files)?);
1936-
dbg!(&n_tipsets);
19371935
revalidate_chain(store.clone(), n_tipsets).await?;
19381936
tests.extend(snapshot_tests(
19391937
store,
@@ -1949,9 +1947,8 @@ pub(super) async fn create_tests(
19491947
async fn revalidate_chain(db: Arc<ManyCar>, n_ts_to_validate: usize) -> anyhow::Result<()> {
19501948
let chain_config = Arc::new(handle_chain_config(&NetworkChain::Calibnet)?);
19511949

1952-
let genesis: Option<&Path> = None;
19531950
let genesis_header = crate::genesis::read_genesis_header(
1954-
genesis.as_deref(),
1951+
None,
19551952
chain_config.genesis_bytes(&db).await?.as_deref(),
19561953
&db,
19571954
)

src/tool/subcommands/api_cmd/generate_test_snapshot.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{
99
daemon::db_util::load_all_forest_cars,
1010
db::{
1111
db_engine::open_db, parity_db::ParityDb, EthMappingsStore, HeaviestTipsetKeyProvider,
12-
MemoryDB, SettingsStore, SettingsStoreExt, CAR_DB_DIR_NAME,
12+
IndicesStore, MemoryDB, SettingsStore, SettingsStoreExt, CAR_DB_DIR_NAME,
1313
},
1414
genesis::read_genesis_header,
1515
libp2p::{NetworkMessage, PeerManager},
@@ -97,10 +97,10 @@ async fn ctx(
9797

9898
let chain_store = Arc::new(
9999
ChainStore::new(
100+
db.clone(),
100101
db.clone(),
101102
db.clone(),
102103
db,
103-
todo!(),
104104
chain_config.clone(),
105105
genesis_header.clone(),
106106
)
@@ -294,3 +294,21 @@ impl<T: EthMappingsStore> EthMappingsStore for ReadOpsTrackingStore<T> {
294294
self.inner.delete(keys)
295295
}
296296
}
297+
298+
impl<T: IndicesStore> IndicesStore for ReadOpsTrackingStore<T> {
299+
fn read_bin(&self, key: &Cid) -> anyhow::Result<Option<Vec<u8>>> {
300+
let result = self.inner.read_bin(key)?;
301+
if let Some(v) = &result {
302+
IndicesStore::write_bin(&self.tracker, key, v.as_slice())?;
303+
}
304+
self.inner.read_bin(key)
305+
}
306+
307+
fn write_bin(&self, key: &Cid, value: &[u8]) -> anyhow::Result<()> {
308+
self.inner.write_bin(key, value)
309+
}
310+
311+
fn exists(&self, key: &Cid) -> anyhow::Result<bool> {
312+
self.inner.exists(key)
313+
}
314+
}

0 commit comments

Comments
 (0)