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 #56 from vikramrajkumar/btsx
Browse files Browse the repository at this point in the history
upstream fixes
  • Loading branch information
bitsha256 committed Sep 10, 2014
2 parents 5a17046 + c0304b1 commit 3c11ba2
Show file tree
Hide file tree
Showing 52 changed files with 1,020 additions and 411 deletions.
2 changes: 1 addition & 1 deletion libraries/api/blockchain_api.json
Expand Up @@ -526,7 +526,7 @@
{
"method_name" : "blockchain_export_fork_graph",
"description" : "dumps the fork data to graphviz format",
"return_type" : "std::string",
"return_type" : "string",
"parameters" : [
{
"name" : "start_block",
Expand Down
6 changes: 3 additions & 3 deletions libraries/api/general_api.json
Expand Up @@ -30,7 +30,7 @@
{
"method_name": "help",
"description": "display a list of commands, or detailed help on an individual command",
"return_type": "std::string",
"return_type": "string",
"parameters" :
[
{
Expand All @@ -52,7 +52,7 @@
[
{
"name" : "address",
"type" : "std::string",
"type" : "string",
"description" : "the address or public key to validate"
}
],
Expand All @@ -63,7 +63,7 @@
{
"method_name": "execute_command_line",
"description": "Execute the given command as if it were typed on the CLI",
"return_type": "std::string",
"return_type": "string",
"parameters" :
[
{
Expand Down
46 changes: 42 additions & 4 deletions libraries/api/mail_api.json
Expand Up @@ -68,6 +68,23 @@
"is_const" : true,
"prerequisites" : ["json_authenticated"]
},
{
"method_name": "mail_get_archive_messages",
"description": "Get all messages in the mail client which are not in processing (sent and received).",
"return_type": "message_status_list",
"parameters" : [],
"is_const" : true,
"prerequisites" : ["json_authenticated"]
},
{
"method_name": "mail_inbox",
"description": "Get headers of all messages in the inbox.",
"return_type": "message_header_list",
"parameters" : [],
"is_const" : true,
"prerequisites" : ["json_authenticated"],
"aliases" : ["inbox"]
},
{
"method_name": "mail_retry_send",
"description": "Retries sending the specified message.",
Expand All @@ -83,7 +100,7 @@
},
{
"method_name": "mail_remove_message",
"description": "Removes the message from the local database",
"description": "Removes the message from the local database.",
"return_type": "void",
"parameters" : [
{
Expand All @@ -95,9 +112,30 @@
"prerequisites" : ["json_authenticated"]
},
{
"method_name": "mail_get_sent_message",
"method_name": "mail_archive_message",
"description": "Removes the message from the inbox.",
"return_type": "void",
"parameters" : [
{
"name" : "message_id",
"type" : "message_id",
"description" : "ID of the message to archive."
}
],
"prerequisites" : ["json_authenticated"],
"aliases" : ["archive"]
},
{
"method_name": "mail_check_new_messages",
"description": "Check mail server for new mail.",
"return_type": "void",
"parameters" : [],
"prerequisites" : ["json_authenticated","wallet_unlocked"]
},
{
"method_name": "mail_get_message",
"description": "Get a specific message from the client.",
"return_type": "message",
"return_type": "email_record",
"parameters" : [
{
"name" : "message_id",
Expand All @@ -106,7 +144,7 @@
}
],
"is_const" : true,
"prerequisites" : ["json_authenticated"]
"prerequisites" : ["json_authenticated","wallet_unlocked"]
},
{
"method_name": "mail_send",
Expand Down
2 changes: 1 addition & 1 deletion libraries/api/network_api.json
Expand Up @@ -16,7 +16,7 @@
},
{
"name" : "command",
"type" : "std::string",
"type" : "string",
"description" : "'add' to add a node to the list, 'remove' to remove a node from the list, 'onetry' to try a connection to the node once",
"example" : "add",
"default_value" : "add"
Expand Down
10 changes: 10 additions & 0 deletions libraries/api/types.json
Expand Up @@ -642,6 +642,16 @@
"type_name" : "message_status_list",
"cpp_return_type" : "std::multimap<bts::mail::client::mail_status,bts::mail::message_id_type>",
"cpp_include_file" : "bts/mail/client.hpp"
},
{
"type_name" : "email_record",
"cpp_return_type" : "bts::mail::email_record",
"cpp_include_file" : "bts/mail/client.hpp"
},
{
"type_name" : "message_header_list",
"cpp_return_type" : "std::vector<bts::mail::email_header>",
"cpp_include_file" : "bts/mail/client.hpp"
}
]
}
4 changes: 2 additions & 2 deletions libraries/api/wallet_api.json
Expand Up @@ -1195,7 +1195,7 @@
"description" : "the type of asset you are covering (ie: USD)"
},
{
"name" : "short_id",
"name" : "cover_id",
"type" : "order_id",
"description" : "the order ID you would like to cover"
}
Expand Down Expand Up @@ -1616,7 +1616,7 @@
},
{
"method_name" : "wallet_mail_create",
"description" : "Creates a new mail message.",
"description" : "Creates a new mail message and returns the encrypted message.",
"return_type" : "message",
"parameters" : [
{
Expand Down
60 changes: 38 additions & 22 deletions libraries/blockchain/CMakeLists.txt
@@ -1,30 +1,41 @@
##################################################################################################
# Magic to get the genesis.json converted to a .cpp file and compiled into the bts_client library
set(genesis_json "${CMAKE_CURRENT_SOURCE_DIR}/genesis_btsx.json")
set(genesis_prologue "${CMAKE_CURRENT_SOURCE_DIR}/genesis.prologue")
set(genesis_epilogue "${CMAKE_CURRENT_SOURCE_DIR}/genesis.epilogue")
source_group("Genesis JSON Files" FILES ${genesis_json} ${genesis_prologue} ${genesis_epilogue})

set(generated_genesis_file "${CMAKE_CURRENT_BINARY_DIR}/genesis_json.cpp")
set(rpc_stubs_output_dir "${CMAKE_BINARY_DIR}/libraries/rpc_stubs")
set(generated_rpc_stubs_files "${rpc_stubs_output_dir}/common_api_rpc_server.cpp"
"${rpc_stubs_output_dir}/common_api_rpc_client.cpp"
"${rpc_stubs_output_dir}/common_api_client.cpp"
"${rpc_stubs_output_dir}/include/bts/rpc_stubs/common_api_rpc_server.hpp"
"${rpc_stubs_output_dir}/include/bts/rpc_stubs/common_api_rpc_client.hpp"
"${rpc_stubs_output_dir}/include/bts/rpc_stubs/common_api_client.hpp"
"${rpc_stubs_output_dir}/include/bts/rpc_stubs/common_api_overrides.ipp")
set(EMBED_GENESIS_STATE_AS_TEXT TRUE CACHE BOOL "If true, genesis.json is included in text form, causing slower startup times")

if (EMBED_GENESIS_STATE_AS_TEXT)
set(genesis_prologue "${CMAKE_CURRENT_SOURCE_DIR}/genesis.prologue")
set(genesis_epilogue "${CMAKE_CURRENT_SOURCE_DIR}/genesis.epilogue")

set(generated_genesis_file "${CMAKE_CURRENT_BINARY_DIR}/genesis_json.cpp")

add_custom_command(OUTPUT ${generated_genesis_file}
COMMAND bts_json_to_cpp "--json=${genesis_json}"
"--prologue=${genesis_prologue}"
"--epilogue=${genesis_epilogue}"
"--out=${generated_genesis_file}.new"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${generated_genesis_file}.new" "${generated_genesis_file}"
COMMAND ${CMAKE_COMMAND} -E remove "${generated_genesis_file}.new"
DEPENDS bts_json_to_cpp ${genesis_json} ${genesis_prologue} ${genesis_epilogue} )
else(EMBED_GENESIS_STATE_AS_TEXT)
set(genesis_prologue "${CMAKE_CURRENT_SOURCE_DIR}/binary_genesis.prologue")
set(genesis_epilogue "${CMAKE_CURRENT_SOURCE_DIR}/binary_genesis.epilogue")

set(generated_genesis_file "${CMAKE_CURRENT_BINARY_DIR}/genesis_json.cpp")

add_custom_command(OUTPUT ${generated_genesis_file}
COMMAND bts_json_to_cpp "--json=${genesis_json}"
"--prologue=${genesis_prologue}"
"--epilogue=${genesis_epilogue}"
"--out=${generated_genesis_file}.new"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${generated_genesis_file}.new" "${generated_genesis_file}"
COMMAND ${CMAKE_COMMAND} -E remove "${generated_genesis_file}.new"
DEPENDS bts_json_to_cpp ${genesis_json} ${genesis_prologue} ${genesis_epilogue} )
add_custom_command(OUTPUT ${generated_genesis_file}
COMMAND bts_genesis_to_bin "--json=${genesis_json}"
"--prologue=${genesis_prologue}"
"--epilogue=${genesis_epilogue}"
"--source-out=${generated_genesis_file}.new"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${generated_genesis_file}.new" "${generated_genesis_file}"
COMMAND ${CMAKE_COMMAND} -E remove "${generated_genesis_file}.new"
DEPENDS bts_genesis_to_bin ${genesis_json} ${genesis_prologue} ${genesis_epilogue} )
endif(EMBED_GENESIS_STATE_AS_TEXT)

source_group("Genesis JSON Files" FILES ${genesis_json} ${genesis_prologue} ${genesis_epilogue})


##################################################################################################
# Regular stuff for the bts_client library

Expand Down Expand Up @@ -69,8 +80,13 @@ else()
endif()

target_link_libraries( bts_blockchain fc bts_db leveldb )
target_include_directories( bts_blockchain
target_include_directories( bts_blockchain
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )

if (EMBED_GENESIS_STATE_AS_TEXT)
target_compile_definitions( bts_blockchain PRIVATE EMBED_GENESIS_STATE_AS_TEXT )
endif (EMBED_GENESIS_STATE_AS_TEXT)

if (USE_PCH)
set_target_properties(bts_blockchain PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
cotire(bts_blockchain)
Expand Down
8 changes: 4 additions & 4 deletions libraries/blockchain/address.cpp
Expand Up @@ -9,7 +9,7 @@ namespace bts {
address::address(){}

address::address( const std::string& base58str )
{
{
FC_ASSERT( is_valid( base58str ) );
std::vector<char> v = fc::from_base58( base58str.substr( strlen(BTS_ADDRESS_PREFIX) ) );
memcpy( (char*)addr._hash, v.data(), std::min<size_t>( v.size()-4, sizeof(addr) ) );
Expand Down Expand Up @@ -56,7 +56,7 @@ namespace bts {
{
addr = fc::ripemd160::hash( fc::sha512::hash( pub.data, sizeof(pub) ) );
}

address::address( const bts::blockchain::public_key_type& pub )
{
addr = fc::ripemd160::hash( fc::sha512::hash( pub.key_data.data, sizeof(pub.key_data) ) );
Expand All @@ -73,8 +73,8 @@ namespace bts {

} } // namespace bts::blockchain

namespace fc
{
namespace fc
{
void to_variant( const bts::blockchain::address& var, variant& vo )
{
vo = std::string(var);
Expand Down
5 changes: 2 additions & 3 deletions libraries/blockchain/balance_operations.cpp
Expand Up @@ -284,10 +284,9 @@ namespace bts { namespace blockchain {
} FC_CAPTURE_AND_RETHROW( (option) )
break;
}
case withdraw_null_type:

default:
FC_CAPTURE_AND_THROW( invalid_withdraw_condition, (current_balance_record->condition) );
break;
// default:
}
// update delegate vote on withdrawn account..

Expand Down
13 changes: 13 additions & 0 deletions libraries/blockchain/binary_genesis.epilogue
@@ -0,0 +1,13 @@
};

genesis_block_config get_builtin_genesis_block_config()
{
return fc::raw::unpack<genesis_block_config>((const char*)raw_genesis_config, sizeof(raw_genesis_config));
}

fc::sha256 get_builtin_genesis_block_state_hash()
{
return fc::sha256::hash((const char*)raw_genesis_config, sizeof(raw_genesis_config));
}

} } // end namespace bts::blockchain
12 changes: 12 additions & 0 deletions libraries/blockchain/binary_genesis.prologue
@@ -0,0 +1,12 @@
// This file is generated by bts_json_to_cpp from ${json_file_name}
#include <bts/blockchain/genesis_json.hpp>
#include <bts/blockchain/genesis_config.hpp>

#include <string>
#include <fc/crypto/sha256.hpp>
#include <fc/io/raw.hpp>

namespace bts { namespace blockchain {

static const unsigned char raw_genesis_config[] =
{
23 changes: 17 additions & 6 deletions libraries/blockchain/chain_database.cpp
Expand Up @@ -1777,7 +1777,7 @@ namespace bts { namespace blockchain {

digest_type detail::chain_database_impl::initialize_genesis( const optional<path>& genesis_file, bool chain_id_only )
{ try {
auto chain_id = self->chain_id();
digest_type chain_id = self->chain_id();
if( chain_id != digest_type() && !chain_id_only )
{
self->sanity_check();
Expand Down Expand Up @@ -1805,19 +1805,28 @@ namespace bts { namespace blockchain {
{
FC_ASSERT( !"Invalid genesis format", " '${format}'", ("format",genesis_file->extension() ) );
}
fc::sha256::encoder enc;
fc::raw::pack( enc, config );
chain_id = enc.result();
}
else
{
// this is the usual case
std::cout << "Initializing genesis state from built-in genesis file\n";
#ifdef EMBED_GENESIS_STATE_AS_TEXT
std::string genesis_file_contents = get_builtin_genesis_json_as_string();
config = fc::json::from_string(genesis_file_contents).as<genesis_block_config>();
fc::sha256::encoder enc;
fc::raw::pack( enc, config );
chain_id = enc.result();
#else
config = get_builtin_genesis_block_config();
chain_id = get_builtin_genesis_block_state_hash();
#endif
}

fc::sha256::encoder enc;
fc::raw::pack( enc, config );
chain_id = enc.result();
if( chain_id_only ) return chain_id;
if( chain_id_only )
return chain_id;
_chain_id = chain_id;
self->set_property( bts::blockchain::chain_id, fc::variant(_chain_id) );

Expand Down Expand Up @@ -2469,6 +2478,7 @@ namespace bts { namespace blockchain {
auto order = market_order { bid_order, bid_itr.key(), bid_itr.value() };
if( filter(order) )
ret.push_back(order);
++bid_itr;
}

auto ask_itr = my->_ask_db.begin();
Expand All @@ -2477,6 +2487,7 @@ namespace bts { namespace blockchain {
auto order = market_order { ask_order, ask_itr.key(), ask_itr.value() };
if( filter(order) )
ret.push_back(order);
++ask_itr;
}

auto short_itr = my->_short_db.begin();
Expand All @@ -2485,8 +2496,8 @@ namespace bts { namespace blockchain {
auto order = market_order { short_order, short_itr.key(), short_itr.value() };
if( filter(order) )
ret.push_back(order);
++short_itr;
}

return ret;
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/blockchain/genesis.json
@@ -1,5 +1,5 @@
{
"timestamp" : "20140901T000000",
"timestamp" : "20140908T000001",
"market_assets": [
{
"symbol": "PTS",
Expand Down
3 changes: 2 additions & 1 deletion libraries/blockchain/include/bts/blockchain/checkpoints.hpp
Expand Up @@ -6,5 +6,6 @@ const static std::map<uint32_t, bts::blockchain::block_id_type> CHECKPOINT_BLOCK
{
{ 1, bts::blockchain::block_id_type( "8abcfb93c52f999e3ef5288c4f837f4f15af5521" ) },
{ 225000, bts::blockchain::block_id_type( "2e09195c3e4ef6d58736151ea22f78f08556e6a9" ) },
{ 442700, bts::blockchain::block_id_type( "c22e2dc1954f7d3a9620048d64587018e98c03f8" ) }
{ 442700, bts::blockchain::block_id_type( "c22e2dc1954f7d3a9620048d64587018e98c03f8" ) },
{ 452700, bts::blockchain::block_id_type( "b678b7b86a8b05593df49acc5e8ba62f7177276e" ) }
};
4 changes: 2 additions & 2 deletions libraries/blockchain/include/bts/blockchain/config.hpp
Expand Up @@ -3,11 +3,11 @@
#include <stdint.h>

/* Define client version here */
#define BTS_CLIENT_VERSION "0.4.13"
#define BTS_CLIENT_VERSION "0.4.14"

/* Comment out this line for a non-test network */
//#define BTS_TEST_NETWORK
#define BTS_TEST_NETWORK_VERSION 23
#define BTS_TEST_NETWORK_VERSION 25

/** @file bts/blockchain/config.hpp
* @brief Defines global constants that determine blockchain behavior
Expand Down

0 comments on commit 3c11ba2

Please sign in to comment.