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 #20 from vikramrajkumar/btsx
Browse files Browse the repository at this point in the history
merge latest
  • Loading branch information
bitsha256 committed Aug 18, 2014
2 parents 6b05c76 + c403f9b commit 8f6ff52
Show file tree
Hide file tree
Showing 102 changed files with 865 additions and 6,531 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ tests/client_node
tests/client_rpc_tests/client_rpc_tests
tests/deterministic_signature_test
tests/dev_tests
tests/nathan_tests
tests/server_node
tests/wallet_tests
8 changes: 7 additions & 1 deletion HelperScripts/jenkins_build32.bat
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@ if exist leveldb-win (

cd %WORKSPACE%
call bitshares_toolkit/setenv.bat || exit /b 26

call npm install grunt
call npm install lineman -g --prefix=%NPM_INSTALL_PREFIX%
call npm install lineman-angular
call npm install lineman-less

if exist build (
rmdir /Q /S build || exit /b 27
)
mkdir build
cd build
cmake -G "Visual Studio 12" ../bitshares_toolkit || exit /b 28
cmake -DINCLUDE_QT_WALLET=TRUE -DFORCE_BUILDWEB_GENERATION=TRUE -G "Visual Studio 12" ../bitshares_toolkit || exit /b 28
msbuild.exe /M:%NUMBER_OF_PROCESSORS% /p:Configuration=RelWithDebinfo /p:Platform=Win32 /target:rebuild /clp:ErrorsOnly BitShares.sln || exit /b 30
7 changes: 2 additions & 5 deletions libraries/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ add_subdirectory( utilities )
add_subdirectory( blockchain )
add_subdirectory( wallet )
add_subdirectory( net )
add_subdirectory( network )
#add_subdirectory( network )
add_subdirectory( client )
add_subdirectory( rpc )
add_subdirectory( cli )
add_subdirectory( keyhotee )
add_subdirectory( mail )
#add_subdirectory( kid )
#add_subdirectory( mail )
add_subdirectory( bitcoin )
#add_subdirectory( btsx )
#add_subdirectory( dns )
8 changes: 4 additions & 4 deletions libraries/api/wallet_api.json
Original file line number Diff line number Diff line change
Expand Up @@ -968,18 +968,18 @@
"aliases" : ["pay_delegate"]
},
{
"method_name" : "wallet_set_priority_fee",
"description" : "Set the priority fee to add to new transactions",
"method_name" : "wallet_set_transaction_fee",
"description" : "Set the fee to add to new transactions",
"return_type" : "asset",
"parameters" : [
{
"name" : "fee",
"type" : "real_amount",
"description" : "the wallet priority fee to set"
"description" : "the wallet transaction fee to set"
}
],
"prerequisites" : ["wallet_open"],
"aliases" : ["set_priority_fee", "settrxfee"]
"aliases" : ["wallet_set_priority_fee", "set_priority_fee", "settrxfee", "setfee", "set_fee"]
},
{
"method_name" : "wallet_market_submit_bid",
Expand Down
14 changes: 13 additions & 1 deletion libraries/blockchain/asset_record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,19 @@ bool asset_record::is_null()const
/** the asset is issued by the market and not by any user */
bool asset_record::is_market_issued()const
{
return issuer_account_id == market_issued_asset;
switch( issuer_account_id )
{
case market_issued_asset:
case market_feed_issued_asset:
return true;
default:
return false;
}
}

bool asset_record::uses_market_feed()const
{
return issuer_account_id == market_feed_issued_asset;
}

asset_record asset_record::make_null()const
Expand Down
7 changes: 0 additions & 7 deletions libraries/blockchain/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@ namespace bts { namespace blockchain {
return fc::sha256::hash( enc.result() );
}

int64_t block_header::next_fee( int64_t current_fee, size_t block_size )const
{
uint64_t next_fee_base = block_size * current_fee / BTS_BLOCKCHAIN_TARGET_BLOCK_SIZE;
uint64_t next_fee = ((BTS_BLOCKCHAIN_BLOCKS_PER_DAY-1)*current_fee + next_fee_base) / BTS_BLOCKCHAIN_BLOCKS_PER_DAY;
return std::max<uint64_t>(next_fee,BTS_BLOCKCHAIN_MIN_FEE);
}

full_block::operator digest_block()const
{
digest_block db( (signed_block_header&)*this );
Expand Down
225 changes: 115 additions & 110 deletions libraries/blockchain/chain_database.cpp

Large diffs are not rendered by default.

15 changes: 1 addition & 14 deletions libraries/blockchain/chain_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ namespace bts{ namespace blockchain {
return (get_delegate_pay_rate() * BTS_BLOCKCHAIN_ASSET_REGISTRATION_FEE);
}

share_type chain_interface::calculate_data_fee(size_t bytes) const
{
return (get_fee_rate() * bytes)/1000;
}

bool chain_interface::is_valid_account_name( const std::string& str )const
{
if( str.size() < BTS_BLOCKCHAIN_MIN_NAME_SIZE ) return false;
Expand Down Expand Up @@ -200,15 +195,6 @@ namespace bts{ namespace blockchain {
{
set_property( accumulated_fees, variant(fees) );
}
share_type chain_interface::get_fee_rate()const
{
return get_property( current_fee_rate ).as_int64();
}

void chain_interface::set_fee_rate( share_type fees )
{
set_property( current_fee_rate, variant(fees) );
}

map<asset_id_type, asset_id_type> chain_interface::get_dirty_markets()const
{
Expand All @@ -219,6 +205,7 @@ namespace bts{ namespace blockchain {
return map<asset_id_type,asset_id_type>();
}
}

void chain_interface::set_dirty_markets( const map<asset_id_type,asset_id_type>& d )
{
set_property( dirty_markets, fc::variant(d) );
Expand Down
2 changes: 1 addition & 1 deletion libraries/blockchain/genesis.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"timestamp" : "20140814T010000",
"timestamp" : "20140816T000000",
"market_assets": [
{
"symbol": "PTS",
Expand Down
19 changes: 4 additions & 15 deletions libraries/blockchain/include/bts/blockchain/asset_record.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace bts { namespace blockchain {
{
enum
{
market_issued_asset = -2
market_issued_asset = -2,
market_feed_issued_asset = -3
};

asset_record()
Expand All @@ -23,6 +24,7 @@ namespace bts { namespace blockchain {
bool is_null()const;
/** the asset is issued by the market and not by any user */
bool is_market_issued()const;
bool uses_market_feed()const;
asset_record make_null()const;

uint64_t get_precision()const;
Expand All @@ -40,17 +42,6 @@ namespace bts { namespace blockchain {
share_type maximum_share_supply;
share_type collected_fees;
feed_id_type price_feed_id;

/**
* Setting these values to a reasonable range helps the
* market filter out garbage data that could result in
* very large ratios. For example, assume a min
* market cap for XTS of $1 Million and a maximum
* market cap of $1 Trillion that gives us a trading
* range of $0.0005 and $500 for the price.
*/
price minimum_xts_price; // in this asset
price maximum_xts_price; // in this asset
};
typedef fc::optional<asset_record> oasset_record;

Expand All @@ -70,6 +61,4 @@ FC_REFLECT( bts::blockchain::asset_record,
(maximum_share_supply)
(collected_fees)
(price_feed_id)
(minimum_xts_price)
(maximum_xts_price)
)
)
2 changes: 0 additions & 2 deletions libraries/blockchain/include/bts/blockchain/block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ namespace bts { namespace blockchain {

block_header():block_num(0){}

share_type next_fee( share_type prev_fee_rate, size_t block_size )const;

block_id_type previous;
uint32_t block_num;
fc::time_point_sec timestamp;
Expand Down
11 changes: 8 additions & 3 deletions libraries/blockchain/include/bts/blockchain/chain_database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,19 @@ namespace bts { namespace blockchain {
chain_database();
virtual ~chain_database()override;

void open( const fc::path& data_dir, fc::optional<fc::path> genesis_file );
/**
* @brief open Open the databases, reindexing as necessary
* @param reindex_status_callback Called for each reindexed block, with the count of blocks reindexed so far
*/
void open(const fc::path& data_dir, fc::optional<fc::path> genesis_file ,
std::function<void(uint32_t)> reindex_status_callback = std::function<void(uint32_t)>());
void close();

void add_observer( chain_observer* observer );
void remove_observer( chain_observer* observer );

void set_priority_fee( share_type shares );
share_type get_priority_fee();
void set_relay_fee( share_type shares );
share_type get_relay_fee();

void sanity_check()const;

Expand Down
13 changes: 3 additions & 10 deletions libraries/blockchain/include/bts/blockchain/chain_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ namespace bts { namespace blockchain {
*/
confirmation_requirement = 6,
database_version = 7, // database version, to know when we need to upgrade
current_fee_rate = 8, // database version, to know when we need to upgrade
accumulated_fees = 9, // database version, to know when we need to upgrade
dirty_markets = 10,
last_feed_id = 11 // used for allocating new data feeds
accumulated_fees = 8,
dirty_markets = 9,
last_feed_id = 10 // used for allocating new data feeds
};
typedef uint32_t chain_property_type;

Expand Down Expand Up @@ -79,17 +78,12 @@ namespace bts { namespace blockchain {
share_type get_accumulated_fees()const;
void set_accumulated_fees( share_type fees );

share_type get_fee_rate()const;
void set_fee_rate( share_type fees );

/** return the current fee rate in millishares */
virtual odelegate_slate get_delegate_slate( slate_id_type id )const = 0;
virtual void store_delegate_slate( slate_id_type id,
const delegate_slate& slate ) = 0;

virtual share_type get_delegate_registration_fee()const;
virtual share_type get_asset_registration_fee()const;
virtual share_type calculate_data_fee(size_t bytes) const;

virtual int64_t get_required_confirmations()const;
virtual fc::variant get_property( chain_property_enum property_id )const = 0;
Expand Down Expand Up @@ -185,7 +179,6 @@ FC_REFLECT_ENUM( bts::blockchain::chain_property_enum,
(chain_id)
(confirmation_requirement)
(database_version)
(current_fee_rate)
(accumulated_fees)
(dirty_markets)
(last_feed_id)
Expand Down
66 changes: 28 additions & 38 deletions libraries/blockchain/include/bts/blockchain/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,47 @@
#include <stdint.h>

/* Set to true only for test network */
#define BTS_TEST_NETWORK (false)
#define BTS_TEST_NETWORK_VERSION (15)
#define BTS_TEST_NETWORK false
#define BTS_TEST_NETWORK_VERSION 17

/** @file bts/blockchain/config.hpp
* @brief Defines global constants that determine blockchain behavior
*/
#define BTS_BLOCKCHAIN_VERSION (109)
#define BTS_WALLET_VERSION uint32_t(101)
#define BTS_BLOCKCHAIN_DATABASE_VERSION (122)
#define BTS_BLOCKCHAIN_VERSION 109
#define BTS_BLOCKCHAIN_DATABASE_VERSION 125

/**
* The address prepended to string representation of
* addresses.
*
* Changing these parameters will result in a hard fork.
*/
#define BTS_ADDRESS_PREFIX "BTSX"
#define BTS_BLOCKCHAIN_SYMBOL "BTSX"
#define BTS_BLOCKCHAIN_NAME "BitShares X"
#define BTS_BLOCKCHAIN_DESCRIPTION "Decentralized Autonomous Exchange"
#define BTS_BLOCKCHAIN_PRECISION (100000)
#define BTS_BLOCKCHAIN_MAX_TRANSACTION_EXPIRATION_SEC (60*60*24*2)
#define BTS_BLOCKCHAIN_DEFAULT_TRANSACTION_EXPIRATION_SEC (60*60*2)
#define BTS_ADDRESS_PREFIX "BTSX"
#define BTS_BLOCKCHAIN_SYMBOL "BTSX"
#define BTS_BLOCKCHAIN_NAME "BitShares X"
#define BTS_BLOCKCHAIN_DESCRIPTION "Decentralized Autonomous Exchange"
#define BTS_BLOCKCHAIN_PRECISION 100000
#define BTS_BLOCKCHAIN_MAX_TRANSACTION_EXPIRATION_SEC (60*60*24*2)
#define BTS_BLOCKCHAIN_DEFAULT_TRANSACTION_EXPIRATION_SEC (60*60*2)

#define BTS_BLOCKCHAIN_ENABLE_NEGATIVE_VOTES (false)

#define BTS_BLOCKCHAIN_DEFAULT_PRIORITY_FEE (10000) // XTS
#define BTS_BLOCKCHAIN_DEFAULT_RELAY_FEE 10000 // XTS

/**
* The number of delegates that the blockchain is designed to support
*/
#define BTS_BLOCKCHAIN_NUM_DELEGATES (101)
#define BTS_BLOCKCHAIN_MAX_SLATE_SIZE (BTS_BLOCKCHAIN_NUM_DELEGATES)
#define BTS_BLOCKCHAIN_MIN_FEEDS ((BTS_BLOCKCHAIN_NUM_DELEGATES/2) + 1)
#define BTS_BLOCKCHAIN_NUM_DELEGATES 101
#define BTS_BLOCKCHAIN_MAX_SLATE_SIZE BTS_BLOCKCHAIN_NUM_DELEGATES
#define BTS_BLOCKCHAIN_MIN_FEEDS 3 // ((BTS_BLOCKCHAIN_NUM_DELEGATES/2) + 1)
#define BTS_BLOCKCHAIN_MAX_UNDO_HISTORY (BTS_BLOCKCHAIN_NUM_DELEGATES*4)

#define BTS_BLOCKCHAIN_ENABLE_NEGATIVE_VOTES false

/**
* To prevent a delegate from producing blocks on split network,
* we check the connection count. This means no blocks get produced
* until at least a minimum number of clients are on line.
*/
#define BTS_MIN_DELEGATE_CONNECTION_COUNT (1)
#define BTS_MIN_DELEGATE_CONNECTION_COUNT 1

/**
* Defines the number of seconds that should elapse between blocks
Expand All @@ -63,13 +61,13 @@
* Adjusting this value will change the effective fee charged on transactions
*/
#define BTS_BLOCKCHAIN_MAX_SIZE (1024*1024*1024*int64_t(100)) // 100 GB
#define BTS_BLOCKCHAIN_MIN_NAME_SIZE (1)
#define BTS_BLOCKCHAIN_MAX_NAME_SIZE (63)
#define BTS_BLOCKCHAIN_MIN_NAME_SIZE 1
#define BTS_BLOCKCHAIN_MAX_NAME_SIZE 63
#define BTS_BLOCKCHAIN_MAX_NAME_DATA_SIZE (1024*64)
#define BTS_BLOCKCHAIN_MAX_MEMO_SIZE (19) // bytes
#define BTS_BLOCKCHAIN_MAX_SYMBOL_SIZE (5) // characters
#define BTS_BLOCKCHAIN_MIN_SYMBOL_SIZE (3) // characters
#define BTS_BLOCKCHAIN_PROPOSAL_VOTE_MESSAGE_MAX_SIZE (1024) // bytes
#define BTS_BLOCKCHAIN_MAX_MEMO_SIZE 19 // bytes
#define BTS_BLOCKCHAIN_MAX_SYMBOL_SIZE 5 // characters
#define BTS_BLOCKCHAIN_MIN_SYMBOL_SIZE 3 // characters
#define BTS_BLOCKCHAIN_PROPOSAL_VOTE_MESSAGE_MAX_SIZE 1024 // bytes

/**
* The maximum amount that can be issued for user assets.
Expand All @@ -85,7 +83,7 @@
* Initial shares read from the genesis block are scaled to this number. It is divided
* by 100 so that new shares may be issued without exceeding BTS_BLOCKCHAIN_MAX_SHARES
*/
#define BTS_BLOCKCHAIN_INITIAL_SHARES (BTS_BLOCKCHAIN_MAX_SHARES / 5)
#define BTS_BLOCKCHAIN_INITIAL_SHARES (BTS_BLOCKCHAIN_MAX_SHARES/5)

/**
* How much XTS must be allocated between the short/ask sides of the market before
Expand Down Expand Up @@ -118,22 +116,14 @@
*/
#define BTS_BLOCKCHAIN_BLOCKS_PER_YEAR (BTS_BLOCKCHAIN_BLOCKS_PER_DAY*int64_t(365))

#define BTS_BLOCKCHAIN_AVERAGE_TRX_SIZE (512) // just a random assumption used to calibrate TRX per SEC
#define BTS_BLOCKCHAIN_MAX_TRX_PER_SECOND (1) // (10)
#define BTS_BLOCKCHAIN_MAX_PENDING_QUEUE_SIZE (10) // (BTS_BLOCKCHAIN_MAX_TRX_PER_SECOND * BTS_BLOCKCHAIN_BLOCK_INTERVAL_SEC)
#define BTS_BLOCKCHAIN_AVERAGE_TRX_SIZE 512 // just a random assumption used to calibrate TRX per SEC
#define BTS_BLOCKCHAIN_MAX_TRX_PER_SECOND 1 // (10)
#define BTS_BLOCKCHAIN_MAX_PENDING_QUEUE_SIZE 10 // (BTS_BLOCKCHAIN_MAX_TRX_PER_SECOND * BTS_BLOCKCHAIN_BLOCK_INTERVAL_SEC)

/** defines the maximum block size allowed, 2 MB per hour */
#define BTS_BLOCKCHAIN_MAX_BLOCK_SIZE (10 * BTS_BLOCKCHAIN_AVERAGE_TRX_SIZE * BTS_BLOCKCHAIN_MAX_PENDING_QUEUE_SIZE )

/** defines the target block size, fees will be adjusted to maintain this target */
#define BTS_BLOCKCHAIN_TARGET_BLOCK_SIZE (BTS_BLOCKCHAIN_MAX_BLOCK_SIZE/2)

#define BTS_BLOCKCHAIN_INACTIVE_FEE_APR (10) // 10% per year

/**
* defines the min fee in milli-shares per byte
*/
#define BTS_BLOCKCHAIN_MIN_FEE (1000)
#define BTS_BLOCKCHAIN_INACTIVE_FEE_APR 10 // 10% per year

/**
This constant defines the number of blocks a delegate must produce before
Expand Down
Loading

0 comments on commit 8f6ff52

Please sign in to comment.