Merge many bugfix branches into develop

Merged:

492-bugfix-open-fail #492
523-bugfix-multiple-blind-xfer #523
537-cleanup-remove-operation_get_required_authorities #537
540-cleanup-settle-volume-spam #540
542-bugfix-cancel-fee #542
557-bugfix-pts-address #557
559-test-fix-zero-block-wait #559
561-bugfix-serializer-build-broken #561
562-bugfix-unreflected-fields #562
This commit is contained in:
theoreticalbts 2016-02-09 10:57:21 -05:00
12 changed files with 58 additions and 52 deletions

View file

@ -331,9 +331,27 @@ namespace detail {
fc::read_file_contents( _data_dir / "db_version", version_str );
return (version_str != GRAPHENE_CURRENT_DB_VERSION);
};
if( !is_new() && is_outdated() )
bool need_reindex = (!is_new() && is_outdated());
std::string reindex_reason = "version upgrade";
if( !need_reindex )
{
ilog("Replaying blockchain due to version upgrade");
try
{
_chain_db->open(_data_dir / "blockchain", initial_state);
}
catch( const fc::exception& e )
{
ilog( "caught exception ${e} in open()", ("e", e.to_detail_string()) );
need_reindex = true;
reindex_reason = "exception in open()";
}
}
if( need_reindex )
{
ilog("Replaying blockchain due to ${reason}", ("reason", reindex_reason) );
fc::remove_all( _data_dir / "db_version" );
_chain_db->reindex(_data_dir / "blockchain", initial_state());
@ -349,8 +367,6 @@ namespace detail {
db_version.write( version_string.c_str(), version_string.size() );
db_version.close();
}
} else {
_chain_db->open(_data_dir / "blockchain", initial_state);
}
} else {
wlog("Detected unclean shutdown. Replaying blockchain...");

View file

@ -646,7 +646,6 @@ void database::init_genesis(const genesis_state_type& genesis_state)
for( uint32_t i = 1; i <= genesis_state.initial_active_witnesses; ++i )
{
p.active_witnesses.insert(i);
p.witness_accounts.insert(get(witness_id_type(i)).witness_account);
}
});

View file

@ -232,13 +232,6 @@ void database::update_active_witnesses()
[](const witness_object& w) {
return w.id;
});
gp.witness_accounts.clear();
gp.witness_accounts.reserve(wits.size());
std::transform(wits.begin(), wits.end(),
std::inserter(gp.witness_accounts, gp.witness_accounts.end()),
[](const witness_object& w) {
return w.witness_account;
});
});
} FC_CAPTURE_AND_RETHROW() }

View file

@ -401,9 +401,12 @@ void database::clear_expired_orders()
break;
}
}
modify(mia, [settled](asset_bitasset_data_object& b) {
b.force_settled_volume = settled.amount;
});
if( mia.force_settled_volume != settled.amount )
{
modify(mia, [settled](asset_bitasset_data_object& b) {
b.force_settled_volume = settled.amount;
});
}
}
}
}

View file

@ -52,7 +52,6 @@ namespace graphene { namespace chain {
vector<committee_member_id_type> active_committee_members; // updated once per maintenance interval
flat_set<witness_id_type> active_witnesses; // updated once per maintenance interval
// n.b. witness scheduling is done by witness_schedule object
flat_set<account_id_type> witness_accounts; // updated once per maintenance interval
};
/**

View file

@ -96,4 +96,5 @@ FC_REFLECT_DERIVED( graphene::chain::withdraw_permission_object, (graphene::db::
(withdrawal_period_sec)
(period_start_time)
(expiration)
(claimed_this_period)
)

View file

@ -38,29 +38,6 @@ void balance_claim_operation::validate()const
FC_ASSERT( balance_owner_key != public_key_type() );
}
struct required_auth_visitor
{
typedef void result_type;
vector<authority>& result;
required_auth_visitor( vector<authority>& r ):result(r){}
/** for most operations this is a no-op */
template<typename T>
void operator()(const T& )const {}
void operator()( const balance_claim_operation& o )const
{
result.push_back( authority( 1, o.balance_owner_key, 1 ) );
}
};
void operation_get_required_authorities( const operation& op, vector<authority>& result )
{
op.visit( required_auth_visitor( result ) );
}
/**
* @brief Used to validate operations in a polymorphic manner
*/

View file

@ -779,7 +779,7 @@ class wallet_api
blind_confirmation transfer_to_blind( string from_account_id_or_name,
string asset_symbol,
/** map from key or label to amount */
map<string, string> to_amounts,
vector<pair<string, string>> to_amounts,
bool broadcast = false );
/**

View file

@ -1985,8 +1985,8 @@ public:
limit_order_cancel_operation op;
op.fee_paying_account = get_object<limit_order_object>(order_id).seller;
op.order = order_id;
set_operation_fees( trx, _remote_db->get_global_properties().parameters.current_fees);
trx.operations = {op};
set_operation_fees( trx, _remote_db->get_global_properties().parameters.current_fees);
trx.validate();
return sign_transaction(trx, broadcast);
@ -3446,7 +3446,17 @@ vector< signed_transaction > wallet_api_impl::import_balance( string name_or_id,
{
optional< private_key_type > key = wif_to_key( wif_key );
FC_ASSERT( key.valid(), "Invalid private key" );
addrs.push_back( key->get_public_key() );
fc::ecc::public_key pk = key->get_public_key();
addrs.push_back( pk );
keys[addrs.back()] = *key;
// see chain/balance_evaluator.cpp
addrs.push_back( pts_address( pk, false, 56 ) );
keys[addrs.back()] = *key;
addrs.push_back( pts_address( pk, true, 56 ) );
keys[addrs.back()] = *key;
addrs.push_back( pts_address( pk, false, 0 ) );
keys[addrs.back()] = *key;
addrs.push_back( pts_address( pk, true, 0 ) );
keys[addrs.back()] = *key;
}
}
@ -3883,7 +3893,7 @@ blind_confirmation wallet_api::blind_transfer_help( string from_key_or_label,
blind_confirmation wallet_api::transfer_to_blind( string from_account_id_or_name,
string asset_symbol,
/** map from key or label to amount */
map<string, string> to_amounts,
vector<pair<string, string>> to_amounts,
bool broadcast )
{ try {
FC_ASSERT( !is_locked() );

View file

@ -23,14 +23,19 @@
*/
#include <graphene/chain/protocol/protocol.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/chain/vesting_balance_object.hpp>
#include <graphene/chain/withdraw_permission_object.hpp>
#include <graphene/chain/proposal_object.hpp>
#include <graphene/chain/witness_object.hpp>
#include <graphene/chain/market_evaluator.hpp>
#include <graphene/chain/account_object.hpp>
#include <graphene/chain/asset_object.hpp>
#include <graphene/chain/balance_object.hpp>
#include <graphene/chain/committee_member_object.hpp>
#include <graphene/chain/confidential_object.hpp>
#include <graphene/chain/market_object.hpp>
#include <graphene/chain/proposal_object.hpp>
#include <graphene/chain/vesting_balance_object.hpp>
#include <graphene/chain/withdraw_permission_object.hpp>
#include <graphene/chain/witness_object.hpp>
#include <graphene/chain/worker_object.hpp>
#include <fc/smart_ref_impl.hpp>
#include <iostream>

View file

@ -322,8 +322,10 @@ void database_fixture::generate_blocks(fc::time_point_sec timestamp, bool miss_i
if( miss_intermediate_blocks )
{
generate_block();
auto slots_to_miss = db.get_slot_at_time(timestamp) - 1;
if( slots_to_miss <= 0 ) return;
auto slots_to_miss = db.get_slot_at_time(timestamp);
if( slots_to_miss <= 1 )
return;
--slots_to_miss;
generate_block(~0, init_account_priv_key, slots_to_miss);
return;
}

View file

@ -1152,8 +1152,9 @@ BOOST_AUTO_TEST_CASE( witness_feeds )
generate_block();
const asset_object& bit_usd = get_asset("USDBIT");
auto& global_props = db.get_global_properties();
const vector<account_id_type> active_witnesses(global_props.witness_accounts.begin(),
global_props.witness_accounts.end());
vector<account_id_type> active_witnesses;
for( const witness_id_type& wit_id : global_props.active_witnesses )
active_witnesses.push_back( wit_id(db).witness_account );
BOOST_REQUIRE_EQUAL(active_witnesses.size(), 10);
asset_publish_feed_operation op;