File tree Expand file tree Collapse file tree 14 files changed +103
-183
lines changed Expand file tree Collapse file tree 14 files changed +103
-183
lines changed Original file line number Diff line number Diff line change
1
+ /* *
2
+ * Copyright Soramitsu Co., Ltd. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ #include < memory>
7
+
8
+ #include " blockchain/message_pool/message_storage.hpp"
9
+ #include " storage/ipfs/datastore.hpp"
10
+ #include " primitives/tipset/tipset.hpp"
11
+ #include " primitives/block/block.hpp"
12
+ #include " primitives/cid/cid.hpp"
13
+
14
+ namespace fc ::blockchain::production {
15
+ class BlockGenerator {
16
+ using fc::blockchain::message_pool::MessageStorage;
17
+ using fc::primitives::tipset::Tipset;
18
+ using fc::storage::ipfs::IpfsDataStore;
19
+ using primitives::block::BlockHeader;
20
+
21
+ public:
22
+ BlockGenerator (std::shared_ptr<IpfsDataStore> data_store,
23
+ std::shared_ptr<MessageStorage> messages_store);
24
+
25
+
26
+ };
27
+ } // namespace fc::blockchain::production
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ target_link_libraries(ipfs_datastore_leveldb
24
24
)
25
25
26
26
add_library (ipfs_blockservice
27
- impl/blockservice_impl .cpp
27
+ impl/ipfs_block_service .cpp
28
28
)
29
29
target_link_libraries (ipfs_blockservice
30
30
buffer
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ /* *
2
+ * Copyright Soramitsu Co., Ltd. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ #include " storage/ipfs/impl/ipfs_block_service.hpp"
7
+
8
+ namespace fc ::storage::ipfs {
9
+ IpfsBlockService::IpfsBlockService (std::shared_ptr<IpfsDatastore> data_store)
10
+ : local_storage_{std::move (data_store)} {
11
+ BOOST_ASSERT_MSG (local_storage_ != nullptr ,
12
+ " IPFS block service: invalid local storage" );
13
+ }
14
+
15
+ outcome::result<bool > IpfsBlockService::contains (const CID &key) const {
16
+ return local_storage_->contains (key);
17
+ }
18
+
19
+ outcome::result<void > IpfsBlockService::set (const CID &key, Value value) {
20
+ auto result = local_storage_->set (key, std::move (value));
21
+ if (result.has_error ()) return result.error ();
22
+ return outcome::success ();
23
+ }
24
+
25
+ outcome::result<IpfsBlockService::Value> IpfsBlockService::get (
26
+ const CID &key) const {
27
+ OUTCOME_TRY (data, local_storage_->get (key));
28
+ return std::move (data);
29
+ }
30
+
31
+ outcome::result<void > IpfsBlockService::remove (const CID &key) {
32
+ return local_storage_->remove (key);
33
+ }
34
+ } // namespace fc::storage::ipfs
Original file line number Diff line number Diff line change 8
8
9
9
#include < memory>
10
10
11
- #include " storage/ipfs/blockservice .hpp"
11
+ #include " storage/ipfs/datastore .hpp"
12
12
13
13
namespace fc ::storage::ipfs {
14
- class BlockServiceImpl : public BlockService {
14
+ class IpfsBlockService : public IpfsDatastore {
15
15
public:
16
16
/* *
17
- * @brief Construct block service
17
+ * @brief Construct IPFS storage
18
18
* @param data_store - IPFS storage implementation
19
19
*/
20
- explicit BlockServiceImpl (std::shared_ptr<IpfsDatastore> data_store);
20
+ explicit IpfsBlockService (std::shared_ptr<IpfsDatastore> data_store);
21
21
22
- outcome::result<void > addBlock (const Block &block) override ;
22
+ outcome::result<bool > contains (const CID &key) const override ;
23
23
24
- outcome::result<bool > has (const CID &cid) const override ;
24
+ outcome::result<void > set (const CID &key, Value value) override ;
25
25
26
- outcome::result<Block::Content> getBlockContent (
27
- const CID &cid) const override ;
26
+ outcome::result<Value> get (const CID &key) const override ;
28
27
29
- outcome::result<void > removeBlock (const CID &cid ) override ;
28
+ outcome::result<void > remove (const CID &key ) override ;
30
29
31
30
private:
32
31
std::shared_ptr<IpfsDatastore> local_storage_; /* *< Local data storage */
Original file line number Diff line number Diff line change @@ -16,13 +16,11 @@ namespace fc::storage::ipfs {
16
16
/* *
17
17
* @interface Piece of data, which is used with BlockService
18
18
*/
19
- struct Block {
20
- using Content = common::Buffer; /* *< Alias for content type */
21
-
19
+ struct IpfsBlock {
22
20
/* *
23
21
* @brief Default destructor
24
22
*/
25
- virtual ~Block () = default ;
23
+ virtual ~IpfsBlock () = default ;
26
24
27
25
/* *
28
26
* @brief Get content identifier
@@ -34,7 +32,7 @@ namespace fc::storage::ipfs {
34
32
* @brief Get block content
35
33
* @return Block's raw data for store in the BlockService
36
34
*/
37
- virtual const Content &getRawBytes () const = 0;
35
+ virtual const common::Buffer &getRawBytes () const = 0;
38
36
};
39
37
} // namespace fc::storage::ipfs
40
38
Original file line number Diff line number Diff line change @@ -13,25 +13,25 @@ using libp2p::multi::ContentIdentifierCodec;
13
13
14
14
namespace fc ::storage::ipfs::merkledag {
15
15
MerkleDagServiceImpl::MerkleDagServiceImpl (
16
- std::shared_ptr<BlockService > service)
16
+ std::shared_ptr<IpfsDatastore > service)
17
17
: block_service_{std::move (service)} {
18
18
BOOST_ASSERT_MSG (block_service_ != nullptr ,
19
19
" MerkleDAG service: Block service not connected" );
20
20
}
21
21
22
22
outcome::result<void > MerkleDagServiceImpl::addNode (
23
23
std::shared_ptr<const Node> node) {
24
- return block_service_->addBlock (* node);
24
+ return block_service_->set ( node-> getCID (), node-> getRawBytes () );
25
25
}
26
26
27
27
outcome::result<std::shared_ptr<Node>> MerkleDagServiceImpl::getNode (
28
28
const CID &cid) const {
29
- OUTCOME_TRY (content, block_service_->getBlockContent (cid));
29
+ OUTCOME_TRY (content, block_service_->get (cid));
30
30
return NodeImpl::createFromRawBytes (content);
31
31
}
32
32
33
33
outcome::result<void > MerkleDagServiceImpl::removeNode (const CID &cid) {
34
- return block_service_->removeBlock (cid);
34
+ return block_service_->remove (cid);
35
35
}
36
36
37
37
outcome::result<size_t > MerkleDagServiceImpl::select (
Original file line number Diff line number Diff line change 8
8
9
9
#include < memory>
10
10
11
- #include " storage/ipfs/blockservice .hpp"
11
+ #include " storage/ipfs/datastore .hpp"
12
12
#include " storage/ipfs/merkledag/impl/leaf_impl.hpp"
13
13
#include " storage/ipfs/merkledag/merkledag_service.hpp"
14
14
@@ -19,7 +19,7 @@ namespace fc::storage::ipfs::merkledag {
19
19
* @brief Construct service
20
20
* @param service - underlying block service
21
21
*/
22
- explicit MerkleDagServiceImpl (std::shared_ptr<BlockService > service);
22
+ explicit MerkleDagServiceImpl (std::shared_ptr<IpfsDatastore > service);
23
23
24
24
outcome::result<void > addNode (std::shared_ptr<const Node> node) override ;
25
25
@@ -41,7 +41,7 @@ namespace fc::storage::ipfs::merkledag {
41
41
const CID &cid, uint64_t depth) const override ;
42
42
43
43
private:
44
- std::shared_ptr<BlockService > block_service_;
44
+ std::shared_ptr<IpfsDatastore > block_service_;
45
45
46
46
/* *
47
47
* @brief Fetch graph internal recursive implementation
Original file line number Diff line number Diff line change 9
9
#include < memory>
10
10
11
11
#include " common/outcome.hpp"
12
- #include " storage/ipfs/blockservice.hpp"
13
12
#include " storage/ipfs/merkledag/leaf.hpp"
14
13
#include " storage/ipfs/merkledag/node.hpp"
15
14
You can’t perform that action at this time.
0 commit comments