Skip to content

Commit 186a913

Browse files
committed
nit: quick comment and code cleanuip
Signed-off-by: Carson Farmer <[email protected]>
1 parent fcead6b commit 186a913

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

fendermint/actors/objectstore/src/actor.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ pub struct Actor;
2020

2121
impl Actor {
2222
fn constructor(rt: &impl Runtime) -> Result<(), ActorError> {
23-
// FIXME: (sander) We're setting this up to be a subnet-wide actor for a single repo.
24-
// FIXME: (sander) In the future, this could be deployed dynamically for multi repo subnets.
23+
// FIXME:(sander) We're setting this up to be a subnet-wide actor for a single repo.
24+
// FIXME:(sander) In the future, this could be deployed dynamically for multi repo subnets.
2525
rt.validate_immediate_caller_is(std::iter::once(&SYSTEM_ACTOR_ADDR))?;
2626

2727
let state = State::new(rt.store()).map_err(|e| {
@@ -35,7 +35,7 @@ impl Actor {
3535
}
3636

3737
fn append_object(rt: &impl Runtime, params: PutObjectParams) -> Result<(), ActorError> {
38-
// FIXME: (@carsonfarmer) We'll want to validate the caller is the owner of the repo.
38+
// FIXME:(carsonfarmer) We'll want to validate the caller is the owner of the repo.
3939
rt.validate_immediate_caller_accept_any()?;
4040

4141
rt.transaction(|st: &mut State, rt| {
@@ -49,7 +49,7 @@ impl Actor {
4949
}
5050

5151
fn put_object(rt: &impl Runtime, params: PutObjectParams) -> Result<(), ActorError> {
52-
// FIXME: (@carsonfarmer) We'll want to validate the caller is the owner of the repo.
52+
// FIXME:(carsonfarmer) We'll want to validate the caller is the owner of the repo.
5353
rt.validate_immediate_caller_accept_any()?;
5454

5555
rt.transaction(|st: &mut State, rt| {
@@ -63,7 +63,7 @@ impl Actor {
6363
}
6464

6565
fn delete_object(rt: &impl Runtime, params: DeleteObjectParams) -> Result<(), ActorError> {
66-
// FIXME: (@carsonfarmer) We'll want to validate the caller is the owner of the repo.
66+
// FIXME:(carsonfarmer) We'll want to validate the caller is the owner of the repo.
6767
rt.validate_immediate_caller_accept_any()?;
6868

6969
rt.transaction(|st: &mut State, rt| {

fendermint/actors/objectstore/src/shared.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub struct State {
1818
pub root: Cid,
1919
}
2020

21-
// TODO: (@carsonfarmer) We'll likely want to define the metadata type that will actually be placed in the Hamt
21+
// TODO:(carsonfarmer) We'll likely want to define the metadata type that will actually be placed in the Hamt
2222

2323
impl State {
2424
pub fn new<BS: Blockstore>(store: &BS) -> anyhow::Result<Self> {
@@ -45,7 +45,6 @@ impl State {
4545

4646
let new_content = match hamt.get(&key)? {
4747
Some(existing) => {
48-
// Append the object to the existing object
4948
let mut new_content = existing.clone();
5049
new_content.extend(content);
5150
new_content
@@ -66,15 +65,14 @@ impl State {
6665
) -> anyhow::Result<()> {
6766
let mut hamt = Hamt::<_, Vec<u8>>::load_with_bit_width(&self.root, store, BIT_WIDTH)?;
6867

69-
// TODO: We could use set_if_absent here to avoid overwriting existing objects.
68+
// TODO:(carsonfarmer) We could use set_if_absent here to avoid overwriting existing objects.
7069
hamt.set(key, content)?;
7170
self.root = hamt.flush()?;
7271
Ok(())
7372
}
7473

7574
pub fn delete<BS: Blockstore>(&mut self, store: &BS, key: &BytesKey) -> anyhow::Result<()> {
7675
let mut hamt = Hamt::<_, Vec<u8>>::load_with_bit_width(&self.root, store, BIT_WIDTH)?;
77-
7876
hamt.delete(key)?;
7977
self.root = hamt.flush()?;
8078
Ok(())
@@ -86,20 +84,17 @@ impl State {
8684
key: &BytesKey,
8785
) -> anyhow::Result<Option<Vec<u8>>> {
8886
let hamt = Hamt::<_, Vec<u8>>::load_with_bit_width(&self.root, store, BIT_WIDTH)?;
89-
9087
let value = hamt.get(key).map(|v| v.map(|inner| inner.to_owned()))?;
9188
Ok(value)
9289
}
9390

9491
pub fn list<BS: Blockstore>(&self, store: &BS) -> anyhow::Result<Vec<Vec<u8>>> {
9592
let hamt = Hamt::<_, Vec<u8>>::load_with_bit_width(&self.root, store, BIT_WIDTH)?;
96-
9793
let mut keys = Vec::new();
9894
hamt.for_each(|k, _| {
9995
keys.push(k.0.to_owned());
10096
Ok(())
10197
})?;
102-
10398
Ok(keys)
10499
}
105100
}
@@ -130,9 +125,8 @@ pub enum Method {
130125

131126
#[cfg(test)]
132127
mod tests {
133-
use std::str::FromStr;
134-
135128
use super::*;
129+
use std::str::FromStr;
136130

137131
#[test]
138132
fn test_constructor() {

0 commit comments

Comments
 (0)