Implement node_property_object
This commit is contained in:
parent
8e9b60dd9c
commit
e6246bf9a0
5 changed files with 58 additions and 11 deletions
|
|
@ -20,6 +20,7 @@
|
|||
#include <graphene/chain/block.hpp>
|
||||
#include <graphene/chain/asset.hpp>
|
||||
#include <graphene/chain/global_property_object.hpp>
|
||||
#include <graphene/chain/node_property_object.hpp>
|
||||
#include <graphene/chain/account_object.hpp>
|
||||
#include <graphene/chain/asset_object.hpp>
|
||||
#include <graphene/chain/fork_database.hpp>
|
||||
|
|
@ -215,6 +216,7 @@ namespace graphene { namespace chain {
|
|||
const asset_object& get_core_asset()const;
|
||||
const global_property_object& get_global_properties()const;
|
||||
const dynamic_global_property_object& get_dynamic_global_properties()const;
|
||||
const node_property_object& get_node_properties()const;
|
||||
const fee_schedule_type& current_fee_schedule()const;
|
||||
|
||||
time_point_sec head_block_time()const;
|
||||
|
|
@ -353,7 +355,7 @@ namespace graphene { namespace chain {
|
|||
///Steps involved in applying a new block
|
||||
///@{
|
||||
|
||||
const witness_object& validate_block_header( uint32_t skip, const signed_block& next_block )const;
|
||||
const witness_object& validate_block_header( const signed_block& next_block )const;
|
||||
void create_block_summary(const signed_block& next_block);
|
||||
|
||||
//////////////////// db_update.cpp ////////////////////
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (c) 2015, Cryptonomex, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is provided for evaluation in private test networks only, until September 8, 2015. After this date, this license expires and
|
||||
* the code may not be used, modified or distributed for any purpose. Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted until September 8, 2015, provided that the following conditions are met:
|
||||
*
|
||||
* 1. The code and/or derivative works are used only for private test networks consisting of no more than 10 P2P nodes.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#pragma once
|
||||
#include <graphene/db/object.hpp>
|
||||
|
||||
namespace graphene { namespace chain {
|
||||
|
||||
/**
|
||||
* @brief Contains per-node database configuration.
|
||||
*
|
||||
* Transactions are evaluated differently based on per-node state.
|
||||
* Settings here may change based on whether the node is syncing or up-to-date.
|
||||
* Or whether the node is a witness node. Or if we're processing a
|
||||
* transaction in a witness-signed block vs. a fresh transaction
|
||||
* from the p2p network. Or configuration-specified tradeoffs of
|
||||
* performance/hardfork resilience vs. paranoia.
|
||||
*/
|
||||
class node_property_object
|
||||
{
|
||||
public:
|
||||
node_property_object() : skip_flags(0) {}
|
||||
~node_property_object(){}
|
||||
|
||||
bool skip_authority_check;
|
||||
};
|
||||
} } // graphene::chain
|
||||
|
|
@ -33,8 +33,8 @@ namespace graphene { namespace chain {
|
|||
class transaction_evaluation_state
|
||||
{
|
||||
public:
|
||||
transaction_evaluation_state( database* db = nullptr, bool skip_authority_check = false )
|
||||
:_db(db),_skip_authority_check(skip_authority_check){}
|
||||
transaction_evaluation_state( database* db = nullptr )
|
||||
:_db(db){}
|
||||
|
||||
bool check_authority( const account_object&, authority::classification auth_class = authority::active, int depth = 0 );
|
||||
|
||||
|
|
@ -55,7 +55,6 @@ namespace graphene { namespace chain {
|
|||
|
||||
const signed_transaction* _trx = nullptr;
|
||||
database* _db = nullptr;
|
||||
bool _skip_authority_check = false;
|
||||
bool _is_proposed_trx = false;
|
||||
};
|
||||
} } // namespace graphene::chain
|
||||
|
|
|
|||
|
|
@ -93,13 +93,16 @@ void_result proposal_update_evaluator::do_evaluate(const proposal_update_operati
|
|||
FC_ASSERT( _proposal->available_owner_approvals.find(id) != _proposal->available_owner_approvals.end(),
|
||||
"", ("id", id)("available", _proposal->available_owner_approvals) );
|
||||
}
|
||||
for( key_id_type id : o.key_approvals_to_add )
|
||||
if( (d.get_node_properties().skip_flags & database::skip_authority_check) == 0 )
|
||||
{
|
||||
FC_ASSERT( trx_state->signed_by(id) || trx_state->_skip_authority_check );
|
||||
}
|
||||
for( key_id_type id : o.key_approvals_to_remove )
|
||||
{
|
||||
FC_ASSERT( trx_state->signed_by(id) || trx_state->_skip_authority_check );
|
||||
for( key_id_type id : o.key_approvals_to_add )
|
||||
{
|
||||
FC_ASSERT( trx_state->signed_by(id) );
|
||||
}
|
||||
for( key_id_type id : o.key_approvals_to_remove )
|
||||
{
|
||||
FC_ASSERT( trx_state->signed_by(id) );
|
||||
}
|
||||
}
|
||||
|
||||
return void_result();
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@
|
|||
namespace graphene { namespace chain {
|
||||
bool transaction_evaluation_state::check_authority( const account_object& account, authority::classification auth_class, int depth )
|
||||
{
|
||||
if( _skip_authority_check || approved_by.find(make_pair(account.id, auth_class)) != approved_by.end() )
|
||||
if( (!_is_proposed_trx) && (_db->get_node_properties().skip_flags & database::skip_authority_check) )
|
||||
return true;
|
||||
if( approved_by.find(make_pair(account.id, auth_class)) != approved_by.end() )
|
||||
return true;
|
||||
|
||||
FC_ASSERT( account.id.instance() != 0 || _is_proposed_trx );
|
||||
|
|
|
|||
Loading…
Reference in a new issue