Skip to content
This repository has been archived by the owner on Feb 21, 2019. It is now read-only.

Commit

Permalink
Merge pull request #51 from vikramrajkumar/btsx
Browse files Browse the repository at this point in the history
market fixes
  • Loading branch information
bitsha256 committed Sep 4, 2014
2 parents 5a26645 + 40ba2b8 commit 4d8e2ae
Show file tree
Hide file tree
Showing 23 changed files with 969 additions and 883 deletions.
36 changes: 18 additions & 18 deletions libraries/api/wallet_api.json
Expand Up @@ -672,7 +672,7 @@
{
"method_name" : "wallet_account_register",
"description" : "Updates the data published about a given account",
"return_type" : "signed_transaction",
"return_type" : "transaction_record",
"parameters" : [
{
"name" : "account_name",
Expand All @@ -692,7 +692,7 @@
},
{
"name" : "delegate_pay_rate",
"type" : "uint32_t",
"type" : "uint8_t",
"description" : "A value between 0 and 100 for delegates, 255 for non delegates",
"default_value" : 255
}
Expand Down Expand Up @@ -723,7 +723,7 @@
{
"method_name" : "wallet_account_update_registration",
"description" : "Updates the data published about a given account",
"return_type" : "signed_transaction",
"return_type" : "transaction_record",
"parameters" : [
{
"name" : "account_name",
Expand Down Expand Up @@ -754,7 +754,7 @@
{
"method_name" : "wallet_account_update_active_key",
"description" : "Updates the specified account's active key and broadcasts the transaction.",
"return_type" : "signed_transaction",
"return_type" : "transaction_record",
"parameters" : [
{
"name" : "account_to_update",
Expand Down Expand Up @@ -857,7 +857,7 @@
{
"method_name" : "wallet_asset_create",
"description" : "Creates a new user issued asset",
"return_type" : "signed_transaction",
"return_type" : "transaction_record",
"parameters" : [
{
"name" : "symbol",
Expand Down Expand Up @@ -910,7 +910,7 @@
{
"method_name" : "wallet_asset_issue",
"description" : "Issues new shares of a given asset type",
"return_type" : "signed_transaction",
"return_type" : "transaction_record",
"parameters" : [
{
"name" : "amount",
Expand Down Expand Up @@ -970,7 +970,7 @@
{
"method_name" : "wallet_delegate_withdraw_pay",
"description" : "Used to transfer some of the delegate's pay from their balance",
"return_type" : "signed_transaction",
"return_type" : "transaction_record",
"parameters" : [
{
"name" : "delegate_name",
Expand Down Expand Up @@ -1029,7 +1029,7 @@
{
"method_name" : "wallet_market_submit_bid",
"description" : "Used to place a request to buy a quantity of assets at a price specified in another asset",
"return_type" : "signed_transaction",
"return_type" : "transaction_record",
"parameters" : [
{
"name" : "from_account_name",
Expand Down Expand Up @@ -1069,7 +1069,7 @@
{
"method_name" : "wallet_market_submit_ask",
"description" : "Used to place a request to sell a quantity of assets at a price specified in another asset",
"return_type" : "signed_transaction",
"return_type" : "transaction_record",
"parameters" : [
{
"name" : "from_account_name",
Expand Down Expand Up @@ -1109,7 +1109,7 @@
{
"method_name" : "wallet_market_submit_short",
"description" : "Used to place a request to short sell a quantity of assets at a price specified",
"return_type" : "signed_transaction",
"return_type" : "transaction_record",
"parameters" : [
{
"name" : "from_account_name",
Expand Down Expand Up @@ -1144,7 +1144,7 @@
{
"method_name" : "wallet_market_cover",
"description" : "Used to place a request to cover an existing short position",
"return_type" : "signed_transaction",
"return_type" : "transaction_record",
"parameters" : [
{
"name" : "from_account_name",
Expand Down Expand Up @@ -1173,7 +1173,7 @@
{
"method_name" : "wallet_market_cover2",
"description" : "Used to place a request to cover an existing short position",
"return_type" : "signed_transaction",
"return_type" : "transaction_record",
"parameters" : [
{
"name" : "from_account_name",
Expand Down Expand Up @@ -1202,7 +1202,7 @@
{
"method_name" : "wallet_market_add_collateral",
"description" : "Add collateral to a short position",
"return_type" : "signed_transaction",
"return_type" : "transaction_record",
"parameters" : [
{
"name" : "from_account_name",
Expand All @@ -1226,7 +1226,7 @@
{
"method_name" : "wallet_market_add_collateral2",
"description" : "Add collateral to a short position",
"return_type" : "signed_transaction",
"return_type" : "transaction_record",
"parameters" : [
{
"name" : "from_account_name",
Expand Down Expand Up @@ -1312,7 +1312,7 @@
{
"method_name" : "wallet_market_cancel_order",
"description" : "Cancel an order",
"return_type" : "signed_transaction",
"return_type" : "transaction_record",
"parameters" : [
{
"name" : "order_id",
Expand All @@ -1326,7 +1326,7 @@
{
"method_name" : "wallet_market_cancel_order2",
"description" : "Cancel an order",
"return_type" : "signed_transaction",
"return_type" : "transaction_record",
"parameters" : [
{
"name" : "order_id",
Expand Down Expand Up @@ -1486,7 +1486,7 @@
{
"method_name" : "wallet_publish_slate",
"description" : "Publishes the current wallet delegate slate to the public data associated with the account",
"return_type" : "signed_transaction",
"return_type" : "transaction_record",
"parameters" : [
{
"name" : "publishing_account_name",
Expand Down Expand Up @@ -1570,7 +1570,7 @@
{
"method_name" : "wallet_publish_price_feed",
"description" : "publishes a price feed for BitAssets, only active delegates may do this",
"return_type" : "signed_transaction",
"return_type" : "transaction_record",
"parameters" : [
{
"name" : "delegate_account",
Expand Down
26 changes: 15 additions & 11 deletions libraries/blockchain/chain_database.cpp
Expand Up @@ -1036,12 +1036,18 @@ namespace bts { namespace blockchain {
uint32_t last_block_num = -1;
block_id_type last_block_id;
my->_block_num_to_id_db.last( last_block_num, last_block_id );
if( !must_rebuild_index && last_block_num != uint32_t(-1) )
{
my->_head_block_header = get_block_digest( last_block_id );
my->_head_block_id = last_block_id;

try {
if( !must_rebuild_index && last_block_num != uint32_t(-1) )
{
my->_head_block_header = get_block_digest( last_block_id );
my->_head_block_id = last_block_id;
}
} catch (...) {
must_rebuild_index = true;
}
else

if( must_rebuild_index || last_block_num == uint32_t(-1) )
{
close();
fc::remove_all( data_dir / "index" );
Expand All @@ -1055,10 +1061,8 @@ namespace bts { namespace blockchain {

if( !reindex_status_callback )
std::cout << "Please be patient, this will take a few minutes...\r\nRe-indexing database..." << std::flush << std::fixed;
else {
std::cout << "Progress: 0" << std::endl;
else
reindex_status_callback(0);
}

uint32_t blocks_indexed = 0;
const float total_blocks = num_to_id.size();
Expand All @@ -1077,10 +1081,8 @@ namespace bts { namespace blockchain {
if( !reindex_status_callback )
std::cout << "\rRe-indexing database... "
"Approximately " << std::setprecision(2) << progress << "% complete." << std::flush;
else {
std::cout << "progress: " << progress << std::endl;
else
reindex_status_callback(progress);
}
}

push_block(block);
Expand Down Expand Up @@ -2717,6 +2719,8 @@ namespace bts { namespace blockchain {
record_itr.key().timestamp,
fc::variant(string(record_itr.value().highest_bid.ratio * base->precision / quote->precision)).as_double() / (BTS_BLOCKCHAIN_MAX_SHARES*1000),
fc::variant(string(record_itr.value().lowest_ask.ratio * base->precision / quote->precision)).as_double() / (BTS_BLOCKCHAIN_MAX_SHARES*1000),
fc::variant(string(record_itr.value().opening_price.ratio * base->precision / quote->precision)).as_double() / (BTS_BLOCKCHAIN_MAX_SHARES*1000),
fc::variant(string(record_itr.value().closing_price.ratio * base->precision / quote->precision)).as_double() / (BTS_BLOCKCHAIN_MAX_SHARES*1000),
record_itr.value().volume,
record_itr.value().recent_average_price? to_pretty_price_double(*record_itr.value().recent_average_price) : fc::optional<double>()
} );
Expand Down
3 changes: 2 additions & 1 deletion libraries/blockchain/include/bts/blockchain/checkpoints.hpp
Expand Up @@ -13,5 +13,6 @@ const static std::map<uint32_t, bts::blockchain::block_id_type> CHECKPOINT_BLOCK
{332000, bts::blockchain::block_id_type("2ab4e4de53568149de0a0a37f46fce05d861d43f")},
{341000, bts::blockchain::block_id_type("b77a53d3d3c8dfd1c03d04fb989606bc1a738166")},
{358310, bts::blockchain::block_id_type("4fb5498c0f1bce18740dca639389e307a194de2a")},
{384100, bts::blockchain::block_id_type("9f2ffbebd7722b566547507028954fb81cc37271")}
{384100, bts::blockchain::block_id_type("9f2ffbebd7722b566547507028954fb81cc37271")},
{398900, bts::blockchain::block_id_type("0260a868051d0e43316c165bc912cfb8444262ef")}
};
5 changes: 3 additions & 2 deletions libraries/blockchain/include/bts/blockchain/config.hpp
Expand Up @@ -3,7 +3,7 @@
#include <stdint.h>

/* Define client version here */
#define BTS_CLIENT_VERSION "0.4.11"
#define BTS_CLIENT_VERSION "0.4.12"

/* Comment out this line for a non-test network */
//#define BTS_TEST_NETWORK
Expand All @@ -13,7 +13,7 @@
* @brief Defines global constants that determine blockchain behavior
*/
#define BTS_BLOCKCHAIN_VERSION 109
#define BTS_BLOCKCHAIN_DATABASE_VERSION 133
#define BTS_BLOCKCHAIN_DATABASE_VERSION 134

/**
* The address prepended to string representation of
Expand All @@ -29,6 +29,7 @@
#define BTS_BLOCKCHAIN_MAX_TRANSACTION_EXPIRATION_SEC (60*60*24*2)

#define BTS_BLOCKCHAIN_DEFAULT_RELAY_FEE 10000 // XTS
#define BTS_BLOCKCHAIN_MINIMUM_SHORT_ORDER_SIZE (BTS_BLOCKCHAIN_PRECISION*100)

/**
* The number of delegates that the blockchain is designed to support
Expand Down
Expand Up @@ -9,4 +9,4 @@
#define BTSX_MARKET_FORK_2_BLOCK_NUM 316001
#define BTSX_MARKET_FORK_3_BLOCK_NUM 340000
#define BTSX_MARKET_FORK_4_BLOCK_NUM 357000
#define BTSX_MARKET_FORK_5_BLOCK_NUM 407500
#define BTSX_MARKET_FORK_5_BLOCK_NUM 408750
12 changes: 10 additions & 2 deletions libraries/blockchain/include/bts/blockchain/market_records.hpp
Expand Up @@ -71,16 +71,22 @@ namespace bts { namespace blockchain {
{
market_history_record(price highest_bid = price(),
price lowest_ask = price(),
price opening_price = price(),
price closing_price = price(),
share_type volume = 0,
fc::optional<price> recent_average_price = fc::optional<price>())
: highest_bid(highest_bid),
lowest_ask(lowest_ask),
opening_price(opening_price),
closing_price(closing_price),
volume(volume),
recent_average_price(recent_average_price)
{}

price highest_bid;
price lowest_ask;
price opening_price;
price closing_price;
share_type volume;

fc::optional<price> recent_average_price;
Expand All @@ -99,6 +105,8 @@ namespace bts { namespace blockchain {
fc::time_point_sec timestamp;
double highest_bid;
double lowest_ask;
double opening_price;
double closing_price;
share_type volume;

fc::optional<double> recent_average_price;
Expand Down Expand Up @@ -244,9 +252,9 @@ FC_REFLECT_ENUM( bts::blockchain::market_history_key::time_granularity_enum, (ea
FC_REFLECT( bts::blockchain::market_status, (quote_id)(base_id)(bid_depth)(ask_depth)(avg_price_1h)(last_error) )
FC_REFLECT_DERIVED( bts::blockchain::api_market_status, (bts::blockchain::market_status), (avg_price_1h) )
FC_REFLECT( bts::blockchain::market_index_key, (order_price)(owner) )
FC_REFLECT( bts::blockchain::market_history_record, (highest_bid)(lowest_ask)(volume)(recent_average_price) )
FC_REFLECT( bts::blockchain::market_history_record, (highest_bid)(lowest_ask)(opening_price)(closing_price)(volume)(recent_average_price) )
FC_REFLECT( bts::blockchain::market_history_key, (quote_id)(base_id)(granularity)(timestamp) )
FC_REFLECT( bts::blockchain::market_history_point, (timestamp)(highest_bid)(lowest_ask)(volume)(recent_average_price) )
FC_REFLECT( bts::blockchain::market_history_point, (timestamp)(highest_bid)(lowest_ask)(opening_price)(closing_price)(volume)(recent_average_price) )
FC_REFLECT( bts::blockchain::order_record, (balance) )
FC_REFLECT( bts::blockchain::collateral_record, (collateral_balance)(payoff_balance) )
FC_REFLECT( bts::blockchain::market_order, (type)(market_index)(state)(collateral) )
Expand Down

0 comments on commit 4d8e2ae

Please sign in to comment.