-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2839 from Taraxa-project/db-opt
Db opt
- Loading branch information
Showing
28 changed files
with
931 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
..._libs/network/include/network/tarcap/packets_handlers/v3/get_pbft_sync_packet_handler.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#pragma once | ||
|
||
#include "../latest/common/packet_handler.hpp" | ||
|
||
namespace taraxa { | ||
class PbftChain; | ||
class DbStorage; | ||
class VoteManager; | ||
} // namespace taraxa | ||
|
||
namespace taraxa::network::tarcap { | ||
class PbftSyncingState; | ||
} | ||
|
||
namespace taraxa::network::tarcap::v3 { | ||
class GetPbftSyncPacketHandler : public PacketHandler { | ||
public: | ||
GetPbftSyncPacketHandler(const FullNodeConfig& conf, std::shared_ptr<taraxa::network::tarcap::PeersState> peers_state, | ||
std::shared_ptr<taraxa::network::tarcap::TimePeriodPacketsStats> packets_stats, | ||
std::shared_ptr<PbftSyncingState> pbft_syncing_state, std::shared_ptr<PbftChain> pbft_chain, | ||
std::shared_ptr<VoteManager> vote_mgr, std::shared_ptr<DbStorage> db, | ||
const addr_t& node_addr, const std::string& logs_prefix = "GET_PBFT_SYNC_PH"); | ||
|
||
// Packet type that is processed by this handler | ||
static constexpr SubprotocolPacketType kPacketType_ = SubprotocolPacketType::GetPbftSyncPacket; | ||
|
||
private: | ||
virtual void validatePacketRlpFormat(const threadpool::PacketData& packet_data) const override; | ||
virtual void process(const threadpool::PacketData& packet_data, const std::shared_ptr<TaraxaPeer>& peer) override; | ||
|
||
virtual void sendPbftBlocks(const std::shared_ptr<TaraxaPeer>& peer, PbftPeriod from_period, | ||
size_t blocks_to_transfer, bool pbft_chain_synced); | ||
|
||
protected: | ||
std::shared_ptr<PbftSyncingState> pbft_syncing_state_; | ||
std::shared_ptr<PbftChain> pbft_chain_; | ||
std::shared_ptr<VoteManager> vote_mgr_; | ||
std::shared_ptr<DbStorage> db_; | ||
}; | ||
|
||
} // namespace taraxa::network::tarcap::v3 |
43 changes: 43 additions & 0 deletions
43
...core_libs/network/include/network/tarcap/packets_handlers/v3/pbft_sync_packet_handler.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#pragma once | ||
|
||
#include "../latest/common/ext_syncing_packet_handler.hpp" | ||
#include "common/thread_pool.hpp" | ||
#include "vote_manager/vote_manager.hpp" | ||
|
||
namespace taraxa::network::tarcap::v3 { | ||
|
||
class PbftSyncPacketHandler : public ExtSyncingPacketHandler { | ||
public: | ||
PbftSyncPacketHandler(const FullNodeConfig& conf, std::shared_ptr<PeersState> peers_state, | ||
std::shared_ptr<TimePeriodPacketsStats> packets_stats, | ||
std::shared_ptr<PbftSyncingState> pbft_syncing_state, std::shared_ptr<PbftChain> pbft_chain, | ||
std::shared_ptr<PbftManager> pbft_mgr, std::shared_ptr<DagManager> dag_mgr, | ||
std::shared_ptr<VoteManager> vote_mgr, std::shared_ptr<DbStorage> db, const addr_t& node_addr, | ||
const std::string& logs_prefix = "PBFT_SYNC_PH"); | ||
|
||
void handleMaliciousSyncPeer(const dev::p2p::NodeID& id); | ||
|
||
// Packet type that is processed by this handler | ||
static constexpr SubprotocolPacketType kPacketType_ = SubprotocolPacketType::PbftSyncPacket; | ||
|
||
private: | ||
virtual void validatePacketRlpFormat(const threadpool::PacketData& packet_data) const override; | ||
virtual void process(const threadpool::PacketData& packet_data, const std::shared_ptr<TaraxaPeer>& peer) override; | ||
|
||
protected: | ||
virtual PeriodData decodePeriodData(const dev::RLP& period_data_rlp) const; | ||
virtual std::vector<std::shared_ptr<PbftVote>> decodeVotesBundle(const dev::RLP& votes_bundle_rlp) const; | ||
|
||
void pbftSyncComplete(); | ||
void delayedPbftSync(int counter); | ||
|
||
static constexpr uint32_t kDelayedPbftSyncDelayMs = 10; | ||
|
||
std::shared_ptr<VoteManager> vote_mgr_; | ||
util::ThreadPool periodic_events_tp_; | ||
|
||
static constexpr size_t kStandardPacketSize = 2; | ||
static constexpr size_t kChainSyncedPacketSize = 3; | ||
}; | ||
|
||
} // namespace taraxa::network::tarcap::v3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.