-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add fn new_dag_cbor_default
to Cid
#2909
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain a little more about why we want this?
@lemmih In state migration code, sometimes it needs to calculate CID for a cor-serializable object, without calling |
utils/forest_utils/src/cid/mod.rs
Outdated
|
||
/// Extension methods for constructing `dag-cbor` [Cid] | ||
pub trait CidCborExt { | ||
/// Default CID builder for Filecoin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Such a lovely new trait! It would be a shame not to have 100% coverage on it! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test added
@hanabi1224, what do we do with this PR? |
utils/forest_utils/src/cid/mod.rs
Outdated
/// - The default hash function is 256 bit BLAKE2b | ||
/// | ||
/// This matches [`abi.CidBuilder`](https://github.com/filecoin-project/go-state-types/blob/master/abi/cid.go#L49) in go | ||
fn new_dag_cbor_default<S: serde::ser::Serialize>(obj: &S) -> anyhow::Result<Cid> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming feels non-intuitive to me. I can see that the default
part refers to blake256,
but I don't see any non-default counterpart. How about naming this function from_cbor
or from_cbor_blake256
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
@lemmih @hanabi1224, what do we do with this PR? |
I'm okay with merging it. |
Summary of changes
As part of #2801
Changes introduced in this pull request:
fn new_dag_cbor_default
toCid
to match the default filecoin CID builder in go. See codeReference issue to close (if applicable)
Closes
Other information and links
Change checklist