Skip to content

Commit

Permalink
Add synchronizer interface - provide synchronization of blocks on con…
Browse files Browse the repository at this point in the history
…sensus commit
  • Loading branch information
muratovv committed Jul 16, 2017
1 parent e74dc11 commit e1e5255
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 1 deletion.
3 changes: 2 additions & 1 deletion irohad/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ add_subdirectory(validation)
add_subdirectory(torii)
add_subdirectory(network)
add_subdirectory(model)
add_subdirectory(simulator)
add_subdirectory(simulator)
add_subdirectory(synchronizer)
8 changes: 8 additions & 0 deletions irohad/synchronizer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
add_library(synchronizer
impl/synchronizer.cpp
)

target_link_libraries(synchronizer PUBLIC
model
rxcpp
)
18 changes: 18 additions & 0 deletions irohad/synchronizer/impl/synchronizer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* 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.
*/

#include <synchronizer/synchronizer.hpp>
50 changes: 50 additions & 0 deletions irohad/synchronizer/synchronizer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* 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_SYNCHRONIZER_HPP
#define IROHA_SYNCHRONIZER_HPP

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

namespace iroha {
namespace synchronizer {

using Commit = rxcpp::observable <model::Block>;

/**
* Synchronizer is interface for fetching missed blocks
*/
class Synchronizer {
public:

/**
* Processing block last committed block
*/
virtual void process_commit(model::Block block) = 0;

/**
* Emit committed blocks
* Note: from one block received on consensus
*/
virtual rxcpp::observable<Commit> on_commit_chain() = 0;

virtual ~Synchronizer() = default;
};
} // namespace synchronizer
} // namespace iroha
#endif //IROHA_SYNCHRONIZER_HPP

0 comments on commit e1e5255

Please sign in to comment.