HARDFORK - fix sub assets

This commit is contained in:
Daniel Larimer 2015-10-26 16:05:01 -04:00
parent 2adbe53714
commit 285d061295
5 changed files with 28 additions and 6 deletions

View file

@ -4,7 +4,7 @@
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* *
* 1. Any modified source or binaries are used only with the BitShares network. * 1. Any modified source or binaries are used only with the MUSE network.
* *
* 2. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 2. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* *

View file

@ -52,7 +52,7 @@ void_result asset_create_evaluator::do_evaluate( const asset_create_operation& o
auto dotpos = op.symbol.find( '.' ); auto dotpos = op.symbol.find( '.' );
if( dotpos != std::string::npos ) { if( dotpos != std::string::npos ) {
auto prefix = op.symbol.substr( 0, dotpos ); auto prefix = op.symbol.substr( 0, dotpos );
auto asset_symbol_itr = asset_indx.find( op.symbol ); auto asset_symbol_itr = asset_indx.find( prefix );
FC_ASSERT( asset_symbol_itr != asset_indx.end(), "Asset ${s} may only be created by issuer of ${p}, but ${p} has not been registered", FC_ASSERT( asset_symbol_itr != asset_indx.end(), "Asset ${s} may only be created by issuer of ${p}, but ${p} has not been registered",
("s",op.symbol)("p",prefix) ); ("s",op.symbol)("p",prefix) );
FC_ASSERT( asset_symbol_itr->issuer == op.issuer, "Asset ${s} may only be created by issuer of ${p}, ${i}", FC_ASSERT( asset_symbol_itr->issuer == op.issuer, "Asset ${s} may only be created by issuer of ${p}, ${i}",

View file

@ -43,7 +43,19 @@ share_type asset_bitasset_data_object::max_force_settlement_volume(share_type cu
void graphene::chain::asset_bitasset_data_object::update_median_feeds(time_point_sec current_time) void graphene::chain::asset_bitasset_data_object::update_median_feeds(time_point_sec current_time)
{ {
current_feed_publication_time = current_time; current_feed_publication_time = current_time;
auto cutoff = current_time - options.feed_lifetime_sec;
for( auto itr = feeds.begin(); itr != feeds.end(); )
{
if( itr->second.first < cutoff )
itr = feeds.erase(itr);
else
++itr;
}
vector<std::reference_wrapper<const price_feed>> current_feeds; vector<std::reference_wrapper<const price_feed>> current_feeds;
current_feeds.reserve(feeds.size());
for( const pair<account_id_type, pair<time_point_sec,price_feed>>& f : feeds ) for( const pair<account_id_type, pair<time_point_sec,price_feed>>& f : feeds )
{ {
if( (current_time - f.second.first).to_seconds() < options.feed_lifetime_sec && if( (current_time - f.second.first).to_seconds() < options.feed_lifetime_sec &&

View file

@ -233,11 +233,13 @@ bool database::check_for_blackswan( const asset_object& mia, bool enable_black_s
auto least_collateral = call_itr->collateralization(); auto least_collateral = call_itr->collateralization();
if( ~least_collateral >= highest ) if( ~least_collateral >= highest )
{ {
elog( "Black Swan detected: \n" elog( "Black Swan detected ${s}/${s1}: \n"
" Least collateralized call: ${lc} ${~lc}\n" " Least collateralized call: ${lc} ${~lc}\n"
// " Highest Bid: ${hb} ${~hb}\n" // " Highest Bid: ${hb} ${~hb}\n"
" Settle Price: ${sp} ${~sp}\n" " Settle Price: ${sp} ${~sp}\n"
" Max: ${h} ${~h}\n", " Max: ${h} ${~h}\n",
("s", settle_price.base.asset_id(*this).symbol )
("s1", settle_price.quote.asset_id(*this).symbol )
("lc",least_collateral.to_real())("~lc",(~least_collateral).to_real()) ("lc",least_collateral.to_real())("~lc",(~least_collateral).to_real())
// ("hb",limit_itr->sell_price.to_real())("~hb",(~limit_itr->sell_price).to_real()) // ("hb",limit_itr->sell_price.to_real())("~hb",(~limit_itr->sell_price).to_real())
("sp",settle_price.to_real())("~sp",(~settle_price).to_real()) ("sp",settle_price.to_real())("~sp",(~settle_price).to_real())
@ -366,11 +368,17 @@ void database::clear_expired_orders()
void database::update_expired_feeds() void database::update_expired_feeds()
{ {
auto& asset_idx = get_index_type<asset_index>().indices(); auto& asset_idx = get_index_type<asset_index>().indices().get<by_type>();
for( const asset_object& a : asset_idx ) auto itr = asset_idx.lower_bound( true /** market issued */ );
//for( const asset_object& a : asset_idx )
while( itr != asset_idx.end() )
{ {
const asset_object& a = *itr;
++itr;
/*
if( !a.is_market_issued() ) if( !a.is_market_issued() )
continue; continue;
*/
const asset_bitasset_data_object& b = a.bitasset_data(*this); const asset_bitasset_data_object& b = a.bitasset_data(*this);
if( b.feed_is_expired(head_block_time()) ) if( b.feed_is_expired(head_block_time()) )

View file

@ -227,11 +227,13 @@ namespace graphene { namespace chain {
typedef flat_index<asset_bitasset_data_object> asset_bitasset_data_index; typedef flat_index<asset_bitasset_data_object> asset_bitasset_data_index;
struct by_symbol; struct by_symbol;
struct by_type;
typedef multi_index_container< typedef multi_index_container<
asset_object, asset_object,
indexed_by< indexed_by<
ordered_unique< tag<by_id>, member< object, object_id_type, &object::id > >, ordered_unique< tag<by_id>, member< object, object_id_type, &object::id > >,
ordered_unique< tag<by_symbol>, member<asset_object, string, &asset_object::symbol> > ordered_unique< tag<by_symbol>, member<asset_object, string, &asset_object::symbol> >,
ordered_non_unique< tag<by_type>, const_mem_fun<asset_object, bool, &asset_object::is_market_issued> >
> >
> asset_object_multi_index_type; > asset_object_multi_index_type;
typedef generic_index<asset_object, asset_object_multi_index_type> asset_index; typedef generic_index<asset_object, asset_object_multi_index_type> asset_index;