Skip to content

Conversation

sergkaprovich
Copy link
Contributor

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.

@sergkaprovich sergkaprovich force-pushed the feature/dag-service branch 6 times, most recently from 6e96b2a to 7faae7a Compare February 3, 2020 12:40
@sergkaprovich sergkaprovich marked this pull request as ready for review February 3, 2020 12:55

private:
common::Buffer content_;
std::map<std::string, LeaveImpl, std::less<>> children_;
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#include <libp2p/multi/content_identifier_codec.hpp>
#include <libp2p/multi/multibase_codec/codecs/base58.hpp>
#include <libp2p/multi/multihash.hpp>
#include "merkledag.pb.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

specify full path

Copy link
Contributor Author

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)};
Copy link
Contributor

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

Copy link
Contributor Author

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_{};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:'-(

Copy link
Contributor Author

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_;
Copy link
Contributor

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?

Copy link
Contributor Author

@sergkaprovich sergkaprovich Feb 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old habit, fixed

Copy link
Contributor

@masterjedy masterjedy left a 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.

@sergkaprovich sergkaprovich force-pushed the feature/dag-service branch 3 times, most recently from 691bfcf to e04314a Compare February 5, 2020 15:08
@sergkaprovich sergkaprovich merged commit 63e5c81 into master Feb 5, 2020
@sergkaprovich sergkaprovich deleted the feature/dag-service branch February 5, 2020 16:04
@sergkaprovich sergkaprovich mentioned this pull request Feb 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants