Introduce son_wallet_object
This commit is contained in:
parent
2e124b07c6
commit
6421d5e852
9 changed files with 76 additions and 12 deletions
|
|
@ -19,6 +19,7 @@ if( GRAPHENE_DISABLE_UNITY_BUILD )
|
|||
db_maint.cpp
|
||||
db_management.cpp
|
||||
db_market.cpp
|
||||
db_sidechain.cpp
|
||||
db_update.cpp
|
||||
db_witness_schedule.cpp
|
||||
)
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include "db_maint.cpp"
|
||||
#include "db_management.cpp"
|
||||
#include "db_market.cpp"
|
||||
#include "db_sidechain.cpp"
|
||||
#include "db_update.cpp"
|
||||
#include "db_witness_schedule.cpp"
|
||||
#include "db_notify.cpp"
|
||||
|
|
@ -461,18 +461,8 @@ void database::update_active_sons()
|
|||
|
||||
bool son_sets_equal = (cur_active_sons.size() == new_active_sons.size());
|
||||
if (son_sets_equal) {
|
||||
for( size_t i = 0; i < cur_active_sons.size(); i++ )
|
||||
{
|
||||
son_sets_equal = son_sets_equal &&
|
||||
cur_active_sons.at(i).son_id == new_active_sons.at(i).son_id &&
|
||||
cur_active_sons.at(i).total_votes == new_active_sons.at(i).total_votes &&
|
||||
cur_active_sons.at(i).signing_key == new_active_sons.at(i).signing_key;
|
||||
|
||||
if (cur_active_sons.at(i).sidechain_public_keys.size() == new_active_sons.at(i).sidechain_public_keys.size()) {
|
||||
|
||||
} else {
|
||||
son_sets_equal = false;
|
||||
}
|
||||
for( size_t i = 0; i < cur_active_sons.size(); i++ ) {
|
||||
son_sets_equal = son_sets_equal && cur_active_sons.at(i) == new_active_sons.at(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ database::database() :
|
|||
{
|
||||
initialize_indexes();
|
||||
initialize_evaluators();
|
||||
initialize_db_sidechain();
|
||||
}
|
||||
|
||||
database::~database()
|
||||
|
|
|
|||
10
libraries/chain/db_sidechain.cpp
Normal file
10
libraries/chain/db_sidechain.cpp
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#include <graphene/chain/database.hpp>
|
||||
|
||||
namespace graphene { namespace chain {
|
||||
|
||||
void database::initialize_db_sidechain()
|
||||
{
|
||||
recreate_primary_wallet = false;
|
||||
}
|
||||
|
||||
} }
|
||||
|
|
@ -40,6 +40,8 @@
|
|||
|
||||
#include <graphene/chain/protocol/protocol.hpp>
|
||||
|
||||
#include <graphene/peerplays_sidechain/defs.hpp>
|
||||
|
||||
#include <fc/log/logger.hpp>
|
||||
|
||||
#include <map>
|
||||
|
|
@ -600,6 +602,13 @@ namespace graphene { namespace chain {
|
|||
* database::close() has not been called, or failed during execution.
|
||||
*/
|
||||
bool _opened = false;
|
||||
|
||||
/////////////////////// db_sidechain.cpp ////////////////////
|
||||
public:
|
||||
bool recreate_primary_wallet;
|
||||
void initialize_db_sidechain();
|
||||
protected:
|
||||
private:
|
||||
};
|
||||
|
||||
namespace detail
|
||||
|
|
|
|||
|
|
@ -147,6 +147,7 @@ namespace graphene { namespace chain {
|
|||
bet_object_type,
|
||||
son_object_type,
|
||||
son_proposal_object_type,
|
||||
son_wallet_object_type,
|
||||
sidechain_address_object_type,
|
||||
OBJECT_TYPE_COUNT ///< Sentry value which contains the number of different object types
|
||||
};
|
||||
|
|
@ -211,6 +212,7 @@ namespace graphene { namespace chain {
|
|||
class bet_object;
|
||||
class son_object;
|
||||
class son_proposal_object;
|
||||
class son_wallet_object;
|
||||
class sidechain_address_object;
|
||||
|
||||
typedef object_id< protocol_ids, account_object_type, account_object> account_id_type;
|
||||
|
|
@ -240,6 +242,7 @@ namespace graphene { namespace chain {
|
|||
typedef object_id< protocol_ids, bet_object_type, bet_object> bet_id_type;
|
||||
typedef object_id< protocol_ids, son_object_type, son_object> son_id_type;
|
||||
typedef object_id< protocol_ids, son_proposal_object_type, son_proposal_object> son_proposal_id_type;
|
||||
typedef object_id< protocol_ids, son_wallet_object_type, son_wallet_object> son_wallet_id_type;
|
||||
typedef object_id< protocol_ids, sidechain_address_object_type, sidechain_address_object> sidechain_address_id_type;
|
||||
|
||||
// implementation types
|
||||
|
|
|
|||
|
|
@ -15,6 +15,19 @@ namespace graphene { namespace chain {
|
|||
uint64_t total_votes = 0;
|
||||
public_key_type signing_key;
|
||||
flat_map<peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
|
||||
|
||||
bool operator==(const son_info& rhs) {
|
||||
bool son_sets_equal =
|
||||
(son_id == rhs.son_id) &&
|
||||
(total_votes == rhs.total_votes) &&
|
||||
(signing_key == rhs.signing_key) &&
|
||||
(sidechain_public_keys.size() == rhs.sidechain_public_keys.size());
|
||||
|
||||
if (son_sets_equal) {
|
||||
// Compare sidechain public keys
|
||||
}
|
||||
return son_sets_equal;
|
||||
}
|
||||
};
|
||||
|
||||
} }
|
||||
|
|
|
|||
36
libraries/chain/include/graphene/chain/son_wallet_object.hpp
Normal file
36
libraries/chain/include/graphene/chain/son_wallet_object.hpp
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
#include <graphene/chain/protocol/types.hpp>
|
||||
#include <graphene/peerplays_sidechain/defs.hpp>
|
||||
|
||||
namespace graphene { namespace chain {
|
||||
using namespace graphene::db;
|
||||
|
||||
/**
|
||||
* @class son_wallet_object
|
||||
* @brief tracks information about a SON wallet.
|
||||
* @ingroup object
|
||||
*/
|
||||
class son_wallet_object : public abstract_object<son_wallet_object>
|
||||
{
|
||||
public:
|
||||
static const uint8_t space_id = protocol_ids;
|
||||
static const uint8_t type_id = son_wallet_object_type;
|
||||
|
||||
flat_map<peerplays_sidechain::sidechain_type, string> addresses;
|
||||
};
|
||||
|
||||
struct by_sidechain_type;
|
||||
struct by_address;
|
||||
using son_wallet_multi_index_type = multi_index_container<
|
||||
son_wallet_object,
|
||||
indexed_by<
|
||||
ordered_unique< tag<by_id>,
|
||||
member<object, object_id_type, &object::id>
|
||||
>
|
||||
>
|
||||
>;
|
||||
using son_wallet_index = generic_index<son_wallet_object, son_wallet_multi_index_type>;
|
||||
} } // graphene::chain
|
||||
|
||||
FC_REFLECT_DERIVED( graphene::chain::son_wallet_object, (graphene::db::object),
|
||||
(addresses) )
|
||||
Loading…
Reference in a new issue