Skip to content

Commit

Permalink
Merge branch 'feature/missed-stubs' into develop
Browse files Browse the repository at this point in the history
# Conflicts:
#	irohad/CMakeLists.txt
#	irohad/main/application.cpp
#	irohad/main/application.hpp
  • Loading branch information
muratovv committed Jul 23, 2017
2 parents f9bc94f + 55476f1 commit 40a5413
Show file tree
Hide file tree
Showing 26 changed files with 503 additions and 141 deletions.
6 changes: 4 additions & 2 deletions irohad/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ add_subdirectory(ametsuchi)
add_subdirectory(common)
add_subdirectory(consensus)
add_subdirectory(main)
add_subdirectory(ordering)
add_subdirectory(peer_service)
add_subdirectory(validation)
add_subdirectory(torii)
add_subdirectory(network)
add_subdirectory(model)
add_subdirectory(ordering)
add_subdirectory(network)
add_subdirectory(simulator)
add_subdirectory(synchronizer)
49 changes: 49 additions & 0 deletions irohad/ametsuchi/mutable_factory.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved.
* http://soramitsu.co.jp
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef IROHA_MUTABLE_FACTORY_HPP
#define IROHA_MUTABLE_FACTORY_HPP

#include <memory>
#include "ametsuchi/mutable_storage.hpp"

namespace iroha {
namespace ametsuchi {

class MutableFactory {
public:
/**
* Creates a mutable storage from the current state.
* Mutable storage is the only way to commit the block to the ledger.
* @return Created mutable storage
*/
virtual std::unique_ptr<MutableStorage> createMutableStorage() = 0;

/**
* Commit mutable storage to Ametsuchi.
* This transforms Ametsuchi to the new state consistent with
* MutableStorage.
* @param mutableStorage
*/
virtual void commit(std::unique_ptr<MutableStorage> mutableStorage) = 0;

virtual ~MutableFactory() = default;
};

} // namespace ametsuchi
} // namespace iroha
#endif //IROHA_MUTABLE_FACTORY_HPP
32 changes: 4 additions & 28 deletions irohad/ametsuchi/storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#define IROHA_AMETSUCHI_H

#include <ametsuchi/block_query.hpp>
#include <ametsuchi/mutable_storage.hpp>
#include <ametsuchi/wsv_query.hpp>
#include <ametsuchi/temporary_wsv.hpp>
#include "ametsuchi/temporary_factory.hpp"
#include "ametsuchi/mutable_factory.hpp"

namespace iroha {

Expand All @@ -31,33 +31,9 @@ namespace iroha {
* Storage interface, which allows queries on current committed state, and
* creation of state which can be mutated with blocks and transactions
*/
class Storage : public WsvQuery, public BlockQuery {
class Storage : public WsvQuery, public BlockQuery, public TemporaryFactory,
public MutableFactory {
public:

/**
* Creates a temporary world state view from the current state.
* Temporary state will be not committed and will be erased on destructor
* call.
* Temporary state might be used for transaction validation.
* @return Created temporary wsv
*/
virtual std::unique_ptr<TemporaryWsv> createTemporaryWsv() = 0;

/**
* Creates a mutable storage from the current state.
* Mutable storage is the only way to commit the block to the ledger.
* @return Created mutable storage
*/
virtual std::unique_ptr<MutableStorage> createMutableStorage() = 0;

/**
* Commit mutable storage to Ametsuchi.
* This transforms Ametsuchi to the new state consistent with
* MutableStorage.
* @param mutableStorage is moved to the function
*/
virtual void commit(std::unique_ptr<MutableStorage> mutableStorage) = 0;

virtual ~Storage() = default;
};

Expand Down
43 changes: 43 additions & 0 deletions irohad/ametsuchi/temporary_factory.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved.
* http://soramitsu.co.jp
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef IROHA_TEMPORARY_FACTORY_HPP
#define IROHA_TEMPORARY_FACTORY_HPP

#include <memory>
#include "ametsuchi/temporary_wsv.hpp"

namespace iroha {
namespace ametsuchi {

class TemporaryFactory {
public:
/**
* Creates a temporary world state view from the current state.
* Temporary state will be not committed and will be erased on destructor
* call.
* Temporary state might be used for transaction validation.
* @return Created temporary wsv
*/
virtual std::unique_ptr<TemporaryWsv> createTemporaryWsv() = 0;

virtual ~TemporaryFactory() = default;
};

} // namespace ametsuchi
} // namespace iroha
#endif //IROHA_TEMPORARY_FACTORY_HPP
2 changes: 1 addition & 1 deletion irohad/main/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define IROHA_APPLICATION_HPP

#include <main/context.hpp>
#include <network/network_api.h>
#include <network/peer_communication_service.hpp>
#include <consensus/consensus_service_stub.hpp>
#include <torii/processor/query_processor_stub.hpp>
#include <torii/processor/transaction_processor_impl.hpp>
Expand Down
38 changes: 38 additions & 0 deletions irohad/model/tx_responses/stateless_response.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved.
* http://soramitsu.co.jp
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef IROHA_STATELESS_RESPONSE_HPP
#define IROHA_STATELESS_RESPONSE_HPP

#include <model/transaction_response.hpp>

namespace iroha {
namespace model {

/**
* Transaction response that contains
*/
struct StatelessResponse : TransactionResponse {

/**
* Is stateless validation passed
*/
bool passed;
};
} // namespace model
} // namespace iroha
#endif //IROHA_STATELESS_RESPONSE_HPP
2 changes: 1 addition & 1 deletion irohad/network/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
add_library(networking
impl/network_api.cpp
impl/peer_communication_service.cpp
peer_communication_stub.cpp
)

Expand Down
49 changes: 49 additions & 0 deletions irohad/network/consensus_gate.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved.
* http://soramitsu.co.jp
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef IROHA_CONSENSUS_GATE_HPP
#define IROHA_CONSENSUS_GATE_HPP

#include <rxcpp/rx.hpp>
#include <model/block.hpp>

namespace iroha {
namespace network {

/**
* Public api of consensus module
*/
class ConsensusGate {
public:

/**
* Providing data for consensus for voting
*/
virtual void vote(model::Block) = 0;

/**
* Emit committed blocks
* Note: committed block may be not satisfy for top block in ledger
* because synchronization reasons
*/
virtual rxcpp::observable <model::Block> on_commit() = 0;

virtual ~ConsensusGate() = default;
};
} // namespace network
} // namespace iroha
#endif //IROHA_CONSENSUS_GATE_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#include <network/network_api.h>
#include <network/peer_communication_service.hpp>
#include <network/consensus_gate.hpp>

56 changes: 0 additions & 56 deletions irohad/network/network_api.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
#include <rxcpp/rx-observable.hpp>

namespace iroha {
namespace ordering {
namespace network {

/**
* Ordering service interface for peer communication service
* Ordering gate provide interface with network transaction order
*/
class OrderingService {
class OrderingGate {
public:

/**
Expand All @@ -38,11 +39,13 @@ namespace iroha {

/**
* Return observable of all proposals in the consensus
* @return
* @return observable with notifications
*/
virtual rxcpp::observable<model::Proposal> on_proposal() = 0;

virtual ~OrderingGate() = default;
};
}//namespace ordering
}//namespace network
}// namespace iroha

#endif //IROHA_ORDERING_SERVICE_HPP
Loading

0 comments on commit 40a5413

Please sign in to comment.