-
Notifications
You must be signed in to change notification settings - Fork 36
IPFS MerkleDAG service #77
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
Conversation
6e96b2a
to
7faae7a
Compare
|
||
private: | ||
common::Buffer content_; | ||
std::map<std::string, LeaveImpl, std::less<>> children_; |
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.
why do we need to specify a standard comparator?
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.
For support searching in map by std::string_view
https://stackoverflow.com/questions/35525777/use-of-string-view-for-map-lookup
#include <libp2p/multi/content_identifier_codec.hpp> | ||
#include <libp2p/multi/multibase_codec/codecs/base58.hpp> | ||
#include <libp2p/multi/multihash.hpp> | ||
#include "merkledag.pb.h" |
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.
specify full path
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.
It's impossible, because this file is generated by protobuf in the temporary build directory during cmake-configure operation.
outcome::result<void> NodeImpl::addChild(const std::string &name, | ||
std::shared_ptr<const Node> node) { | ||
LinkImpl link{node->getCID(), name, node->size()}; | ||
std::pair<std::string, LinkImpl> data{name, std::move(link)}; |
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.
try to use std::make_pair() to simplify
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.
Simplified to links_.emplace(name, std::move(link));
instead links_.emplace(std::make_pair...)
gsl::span<const uint8_t> input); | ||
|
||
private: | ||
mutable boost::optional<CID> 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.
:'-(
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.
We should support general interface fc::storage::ipfs::Block, which instances often will be transferred by constant reference or pointer, so Block::getCID()
can't be non-const. On the other hand - we can't recalculate CID every time was added new children link or modified content, because it's a large overhead. So, mutable is very useful here.
size_{size} {} | ||
|
||
const std::string &LinkImpl::getName() const { | ||
return this->name_; |
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.
Why do you need this
?
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.
Old habit, fixed
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.
I approve it for now, adding protobuf libraries should be refactored in the future.
691bfcf
to
e04314a
Compare
ac57d20
to
8c5458f
Compare
Description of the Change
IPFS MerkleDAG service provides functionality to store and retrieve Nodes, which contain various-length data bytes and Links to the children Nodes. Each Link is a simple structure - CID of the children Node, name of the Link and total size of the serialized children Node.
Each Node is stored separately, so each children Node is stored in the same way, as a parent.
MerkleDAG service introduces additional type to represent graph-structure with content of all children Nodes: Leave. This type is used for recursive fetch of all children Node with their content.
Benefits
IPFS component for managing distributed pieces of data.