Merge commit '9bbbefd3913ccfe01b8e8ef2007ca3eb74ab9d81' into betting
This commit is contained in:
commit
fe82e85d8d
20 changed files with 89 additions and 331 deletions
|
|
@ -1,4 +1,5 @@
|
|||
Copyright (c) 2015 Cryptonomex, Inc., and contributors.
|
||||
Copyright (c) 2015-2016 Cryptonomex Inc.
|
||||
Copyright (c) 2015-2017 contributors
|
||||
|
||||
The MIT License
|
||||
|
||||
|
|
@ -19,4 +20,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
127
README.md
127
README.md
|
|
@ -1,97 +1,77 @@
|
|||
[](http://slack.bitshares.org/)
|
||||
BitShares Core
|
||||
==============
|
||||
* [Getting Started](#getting-started)
|
||||
* [Support](#support)
|
||||
* [Using the API](#using-the-api)
|
||||
* [Accessing restricted API's](#accessing-restricted-apis)
|
||||
* [FAQ](#faq)
|
||||
* [License](#license)
|
||||
|
||||
Intro for new developers
|
||||
------------------------
|
||||
BitShares Core is the BitShares blockchain implementation and command-line interface.
|
||||
The web wallet is [BitShares UI](https://github.com/bitshares/bitshares-ui).
|
||||
|
||||
This is a quick introduction to get new developers up to speed on BitShares.
|
||||
Visit [BitShares.org](https://bitshares.org/) to learn about BitShares and join the community at [BitSharesTalk.org](https://bitsharestalk.org/).
|
||||
|
||||
Starting BitShares
|
||||
-----------------
|
||||
**NOTE:** The official BitShares git repository location, default branch, and submodule remotes were recently changed. Existing
|
||||
repositories can be updated with the following steps:
|
||||
|
||||
For Ubuntu 14.04 LTS users, see this link first:
|
||||
https://github.com/cryptonomex/graphene/wiki/build-ubuntu
|
||||
git remote set-url origin https://github.com/bitshares/bitshares-core.git
|
||||
git checkout master
|
||||
git remote set-head origin --auto
|
||||
git pull
|
||||
git submodule sync --recursive
|
||||
git submodule update --init --recursive
|
||||
|
||||
and then proceed with:
|
||||
Getting Started
|
||||
---------------
|
||||
Build instructions and additional documentation are available in the
|
||||
[wiki](https://github.com/bitshares/bitshares-core/wiki).
|
||||
|
||||
git clone https://github.com/bitshares/bitshares-2
|
||||
cd bitshares-2
|
||||
To build after all dependencies are installed:
|
||||
|
||||
git clone https://github.com/bitshares/bitshares-core.git
|
||||
cd bitshares-core
|
||||
git checkout <LATEST_RELEASE_TAG>
|
||||
git submodule update --init --recursive
|
||||
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .
|
||||
make
|
||||
|
||||
Alternate Boost versions can be specified using the `DBOOST_ROOT` CMake argument. After building, the witness node can
|
||||
be launched with:
|
||||
|
||||
./programs/witness_node/witness_node
|
||||
|
||||
This will launch the witness node. If you would like to launch the command-line wallet, you must first specify a port
|
||||
for communication with the witness node. To do this, add text to `witness_node_data_dir/config.ini` as follows, then
|
||||
restart the node:
|
||||
The node will automatically create a data directory including a config file. It may take several hours to fully synchronize
|
||||
the blockchain. After syncing, you can exit the node using Ctrl+C and setup the command-line wallet by editing
|
||||
`witness_node_data_dir/config.ini` as follows:
|
||||
|
||||
rpc-endpoint = 127.0.0.1:8090
|
||||
|
||||
Then, in a separate terminal window, start the command-line wallet `cli_wallet`:
|
||||
After starting the witness node again, in a separate terminal you can run:
|
||||
|
||||
./programs/cli_wallet/cli_wallet
|
||||
|
||||
To set your iniital password to 'password' use:
|
||||
Set your inital password:
|
||||
|
||||
>>> set_password password
|
||||
>>> unlock password
|
||||
>>> set_password <PASSWORD>
|
||||
>>> unlock <PASSWORD>
|
||||
|
||||
To import your initial balance:
|
||||
|
||||
>>> import_balance nathan [5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3] true
|
||||
>>> import_balance <ACCOUNT NAME> [<WIF_KEY>] true
|
||||
|
||||
If you send private keys over this connection, `rpc-endpoint` should be bound to localhost for security.
|
||||
|
||||
A list of CLI wallet commands is available
|
||||
[here](https://github.com/bitshares/bitshares-2/blob/bitshares/libraries/wallet/include/graphene/wallet/wallet.hpp).
|
||||
Use `help` to see all available wallet commands. Source definition and listing of all commands is available
|
||||
[here](https://github.com/bitshares/bitshares-core/blob/master/libraries/wallet/include/graphene/wallet/wallet.hpp).
|
||||
|
||||
Code coverage testing
|
||||
---------------------
|
||||
Support
|
||||
-------
|
||||
Technical support is available in the [BitSharesTalk technical support subforum](https://bitsharestalk.org/index.php?board=45.0).
|
||||
|
||||
Check how much code is covered by unit tests, using gcov/lcov (see http://ltp.sourceforge.net/coverage/lcov.php ).
|
||||
BitShares Core bugs can be reported directly to the [issue tracker](https://github.com/bitshares/bitshares-core/issues).
|
||||
|
||||
cmake -D ENABLE_COVERAGE_TESTING=true -D CMAKE_BUILD_TYPE=Debug .
|
||||
make
|
||||
lcov --capture --initial --directory . --output-file base.info --no-external
|
||||
libraries/fc/bloom_test
|
||||
libraries/fc/task_cancel_test
|
||||
libraries/fc/api
|
||||
libraries/fc/blind
|
||||
libraries/fc/ecc_test test
|
||||
libraries/fc/real128_test
|
||||
libraries/fc/lzma_test README.md
|
||||
libraries/fc/ntp_test
|
||||
tests/intense_test
|
||||
tests/app_test
|
||||
tests/chain_bench
|
||||
tests/chain_test
|
||||
tests/performance_test
|
||||
lcov --capture --directory . --output-file test.info --no-external
|
||||
lcov --add-tracefile base.info --add-tracefile test.info --output-file total.info
|
||||
lcov -o interesting.info -r total.info libraries/fc/vendor/\* libraries/fc/tests/\* tests/\*
|
||||
mkdir -p lcov
|
||||
genhtml interesting.info --output-directory lcov --prefix `pwd`
|
||||
|
||||
Now open `lcov/index.html` in a browser.
|
||||
|
||||
Unit testing
|
||||
------------
|
||||
|
||||
We use the Boost unit test framework for unit testing. Most unit
|
||||
tests reside in the `chain_test` build target.
|
||||
|
||||
Witness node
|
||||
------------
|
||||
|
||||
The role of the witness node is to broadcast transactions, download blocks, and optionally sign them.
|
||||
|
||||
```
|
||||
./witness_node --rpc-endpoint 127.0.0.1:8090 --enable-stale-production -w '"1.6.0"' '"1.6.1"' '"1.6.2"' '"1.6.3"' '"1.6.4"' '"1.6.5"' '"1.6.6"' '"1.6.7"' '"1.6.8"' '"1.6.9"' '"1.6.10"' '"1.6.11"' '"1.6.12"' '"1.6.13"' '"1.6.14"' '"1.6.15"' '"1.6.16"' '"1.6.17"' '"1.6.18"' '"1.6.19"' '"1.6.20"' '"1.6.21"' '"1.6.22"' '"1.6.23"' '"1.6.24"' '"1.6.25"' '"1.6.26"' '"1.6.27"' '"1.6.28"' '"1.6.29"' '"1.6.30"' '"1.6.31"' '"1.6.32"' '"1.6.33"' '"1.6.34"' '"1.6.35"' '"1.6.36"' '"1.6.37"' '"1.6.38"' '"1.6.39"' '"1.6.40"' '"1.6.41"' '"1.6.42"' '"1.6.43"' '"1.6.44"' '"1.6.45"' '"1.6.46"' '"1.6.47"' '"1.6.48"' '"1.6.49"' '"1.6.50"' '"1.6.51"' '"1.6.52"' '"1.6.53"' '"1.6.54"' '"1.6.55"' '"1.6.56"' '"1.6.57"' '"1.6.58"' '"1.6.59"' '"1.6.60"' '"1.6.61"' '"1.6.62"' '"1.6.63"' '"1.6.64"' '"1.6.65"' '"1.6.66"' '"1.6.67"' '"1.6.68"' '"1.6.69"' '"1.6.70"' '"1.6.71"' '"1.6.72"' '"1.6.73"' '"1.6.74"' '"1.6.75"' '"1.6.76"' '"1.6.77"' '"1.6.78"' '"1.6.79"' '"1.6.80"' '"1.6.81"' '"1.6.82"' '"1.6.83"' '"1.6.84"' '"1.6.85"' '"1.6.86"' '"1.6.87"' '"1.6.88"' '"1.6.89"' '"1.6.90"' '"1.6.91"' '"1.6.92"' '"1.6.93"' '"1.6.94"' '"1.6.95"' '"1.6.96"' '"1.6.97"' '"1.6.98"' '"1.6.99"' '"1.6.100"'
|
||||
```
|
||||
|
||||
Running specific tests
|
||||
----------------------
|
||||
|
||||
- `tests/chain_tests -t block_tests/name_of_test`
|
||||
BitShares UI bugs should be reported to the [UI issue tracker](https://github.com/bitshares/bitshares-ui/issues)
|
||||
|
||||
Using the API
|
||||
-------------
|
||||
|
|
@ -164,13 +144,8 @@ If you want information which is not available from an API, it might be availabl
|
|||
from the [database](https://bitshares.github.io/doxygen/classgraphene_1_1chain_1_1database.html);
|
||||
it is fairly simple to write API methods to expose database methods.
|
||||
|
||||
Running private testnet
|
||||
-----------------------
|
||||
|
||||
See the [documentation](https://github.com/cryptonomex/graphene/wiki/private-testnet) if you want to run a private testnet.
|
||||
|
||||
Questions
|
||||
---------
|
||||
FAQ
|
||||
---
|
||||
|
||||
- Is there a way to generate help with parameter names and method descriptions?
|
||||
|
||||
|
|
@ -240,3 +215,7 @@ Questions
|
|||
connecting to. Therefore the API to add p2p connections needs to be set up with proper access
|
||||
controls.
|
||||
|
||||
License
|
||||
-------
|
||||
BitShares Core is under the MIT license. See [LICENSE](https://github.com/bitshares/bitshares-core/blob/master/LICENSE)
|
||||
for more information.
|
||||
|
|
|
|||
2
docs
2
docs
|
|
@ -1 +1 @@
|
|||
Subproject commit cc4a57cf18161d591bb2ad23a2cfa630fa2f9915
|
||||
Subproject commit 474c28bc7181739f25229b45b76646a693cad998
|
||||
|
|
@ -4,7 +4,6 @@ add_subdirectory( deterministic_openssl_rand )
|
|||
add_subdirectory( chain )
|
||||
add_subdirectory( egenesis )
|
||||
add_subdirectory( net )
|
||||
add_subdirectory( time )
|
||||
add_subdirectory( utilities )
|
||||
add_subdirectory( app )
|
||||
add_subdirectory( plugins )
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ add_library( graphene_app
|
|||
)
|
||||
|
||||
# need to link graphene_debug_witness because plugins aren't sufficiently isolated #246
|
||||
target_link_libraries( graphene_app graphene_market_history graphene_account_history graphene_chain fc graphene_db graphene_net graphene_time graphene_utilities graphene_debug_witness )
|
||||
target_link_libraries( graphene_app graphene_market_history graphene_account_history graphene_chain fc graphene_db graphene_net graphene_utilities graphene_debug_witness )
|
||||
target_include_directories( graphene_app
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../egenesis/include" )
|
||||
|
|
|
|||
|
|
@ -28,15 +28,12 @@
|
|||
|
||||
#include <graphene/chain/protocol/fee_schedule.hpp>
|
||||
#include <graphene/chain/protocol/types.hpp>
|
||||
#include <graphene/time/time.hpp>
|
||||
|
||||
#include <graphene/egenesis/egenesis.hpp>
|
||||
|
||||
#include <graphene/net/core_messages.hpp>
|
||||
#include <graphene/net/exceptions.hpp>
|
||||
|
||||
#include <graphene/time/time.hpp>
|
||||
|
||||
#include <graphene/utilities/key_conversion.hpp>
|
||||
#include <graphene/chain/worker_evaluator.hpp>
|
||||
|
||||
|
|
@ -163,21 +160,22 @@ namespace detail {
|
|||
}
|
||||
else
|
||||
{
|
||||
// https://bitsharestalk.org/index.php/topic,23715.0.html
|
||||
vector<string> seeds = {
|
||||
"104.236.144.84:1777", // puppies
|
||||
"128.199.143.47:2015", // Harvey
|
||||
"185.25.22.21:1776", // liondani (Greece)
|
||||
"bitshares.openledger.info:1776", // OpenLedger
|
||||
"bts-seed1.abit-more.com:62015", // abit
|
||||
"seed.bitsharesnodes.com:1776", // wackou
|
||||
"seed.blocktrades.us:1776", // BlockTrades
|
||||
"seed.roelandp.nl:1776", // roelandp (Canada)
|
||||
"seed02.bitsharesnodes.com:1776",
|
||||
"seed04.bitsharesnodes.com:1776", // Thom
|
||||
"seed05.bitsharesnodes.com:1776", // Thom
|
||||
"seed06.bitsharesnodes.com:1776", // Thom
|
||||
"seed07.bitsharesnodes.com:1776", // Thom
|
||||
"51.15.61.160:1776" // lafona
|
||||
"104.236.144.84:1777", // puppies (USA)
|
||||
"128.199.143.47:2015", // Harvey (Singapore)
|
||||
"212.47.249.84:50696", // iHashFury (France)
|
||||
"51.15.61.160:1776", // lafona (France)
|
||||
"bts-seed1.abit-more.com:62015", // abit (China)
|
||||
"seed.bitsharesnodes.com:1776", // wackou (Netherlands)
|
||||
"seed.blocktrades.us:1776", // BlockTrades (USA)
|
||||
"seed.cubeconnex.com:1777", // cube (USA)
|
||||
"seed.roelandp.nl:1776", // roelandp (Canada)
|
||||
"seed04.bts-nodes.net:1776", // Thom (Australia)
|
||||
"seed05.bts-nodes.net:1776", // Thom (USA)
|
||||
"seed06.bts-nodes.net:1776", // Thom (USA)
|
||||
"seed07.bts-nodes.net:1776", // Thom (Singapore)
|
||||
"seeds.bitshares.eu:1776" // pc (http://seeds.quisquis.de/bitshares.html)
|
||||
};
|
||||
for( const string& endpoint_string : seeds )
|
||||
{
|
||||
|
|
@ -335,7 +333,7 @@ namespace detail {
|
|||
bool modified_genesis = false;
|
||||
if( _options->count("genesis-timestamp") )
|
||||
{
|
||||
genesis.initial_timestamp = fc::time_point_sec( graphene::time::now() ) + genesis.initial_parameters.block_interval + _options->at("genesis-timestamp").as<uint32_t>();
|
||||
genesis.initial_timestamp = fc::time_point_sec( fc::time_point::now() ) + genesis.initial_parameters.block_interval + _options->at("genesis-timestamp").as<uint32_t>();
|
||||
genesis.initial_timestamp -= genesis.initial_timestamp.sec_since_epoch() % genesis.initial_parameters.block_interval;
|
||||
modified_genesis = true;
|
||||
std::cerr << "Used genesis timestamp: " << genesis.initial_timestamp.to_iso_string() << " (PLEASE RECORD THIS)\n";
|
||||
|
|
@ -467,8 +465,6 @@ namespace detail {
|
|||
_force_validate = true;
|
||||
}
|
||||
|
||||
graphene::time::now();
|
||||
|
||||
if( _options->count("api-access") )
|
||||
_apiaccess = fc::json::from_file( _options->at("api-access").as<boost::filesystem::path>() )
|
||||
.as<api_access>();
|
||||
|
|
@ -537,7 +533,7 @@ namespace detail {
|
|||
std::vector<fc::uint160_t>& contained_transaction_message_ids) override
|
||||
{ try {
|
||||
|
||||
auto latency = graphene::time::now() - blk_msg.block.timestamp;
|
||||
auto latency = fc::time_point::now() - blk_msg.block.timestamp;
|
||||
FC_ASSERT( (latency.count()/1000) > -5000, "Rejecting block with timestamp in the future" );
|
||||
if (!sync_mode || blk_msg.block.block_num() % 10000 == 0)
|
||||
{
|
||||
|
|
@ -909,12 +905,6 @@ namespace detail {
|
|||
return fc::time_point_sec::min();
|
||||
} FC_CAPTURE_AND_RETHROW( (block_id) ) }
|
||||
|
||||
/** returns graphene::time::now() */
|
||||
virtual fc::time_point_sec get_blockchain_now() override
|
||||
{
|
||||
return graphene::time::now();
|
||||
}
|
||||
|
||||
virtual item_hash_t get_head_block_id() const override
|
||||
{
|
||||
return _chain_db->head_block_id();
|
||||
|
|
|
|||
|
|
@ -165,8 +165,9 @@ void database::close(bool rewind)
|
|||
}
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
catch ( const fc::exception& e )
|
||||
{
|
||||
wlog( "Database close unexpected exception: ${e}", ("e", e) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 772c2b28226736b455e31b1fdf51e4f18bf33cee
|
||||
Subproject commit 8eb2ccc1803e82a8312b08566b2cdda8b68dc249
|
||||
|
|
@ -158,9 +158,6 @@ namespace graphene { namespace net {
|
|||
*/
|
||||
virtual fc::time_point_sec get_block_time(const item_hash_t& block_id) = 0;
|
||||
|
||||
/** returns graphene::blockchain::now() */
|
||||
virtual fc::time_point_sec get_blockchain_now() = 0;
|
||||
|
||||
virtual item_hash_t get_head_block_id() const = 0;
|
||||
|
||||
virtual uint32_t estimate_last_known_fork_from_git_revision_timestamp(uint32_t unix_timestamp) const = 0;
|
||||
|
|
|
|||
|
|
@ -396,7 +396,6 @@ namespace graphene { namespace net { namespace detail {
|
|||
void connection_count_changed( uint32_t c ) override;
|
||||
uint32_t get_block_number(const item_hash_t& block_id) override;
|
||||
fc::time_point_sec get_block_time(const item_hash_t& block_id) override;
|
||||
fc::time_point_sec get_blockchain_now() override;
|
||||
item_hash_t get_head_block_id() const override;
|
||||
uint32_t estimate_last_known_fork_from_git_revision_timestamp(uint32_t unix_timestamp) const override;
|
||||
void error_encountered(const std::string& message, const fc::oexception& error) override;
|
||||
|
|
@ -2642,7 +2641,8 @@ namespace graphene { namespace net { namespace detail {
|
|||
fc::time_point_sec minimum_time_of_last_offered_block =
|
||||
originating_peer->last_block_time_delegate_has_seen + // timestamp of the block immediately before the first unfetched block
|
||||
originating_peer->number_of_unfetched_item_ids * GRAPHENE_MIN_BLOCK_INTERVAL;
|
||||
if (minimum_time_of_last_offered_block > _delegate->get_blockchain_now() + GRAPHENE_NET_FUTURE_SYNC_BLOCKS_GRACE_PERIOD_SEC)
|
||||
fc::time_point_sec now = fc::time_point::now();
|
||||
if (minimum_time_of_last_offered_block > now + GRAPHENE_NET_FUTURE_SYNC_BLOCKS_GRACE_PERIOD_SEC)
|
||||
{
|
||||
wlog("Disconnecting from peer ${peer} who offered us an implausible number of blocks, their last block would be in the future (${timestamp})",
|
||||
("peer", originating_peer->get_remote_endpoint())
|
||||
|
|
@ -2650,7 +2650,7 @@ namespace graphene { namespace net { namespace detail {
|
|||
fc::exception error_for_peer(FC_LOG_MESSAGE(error, "You offered me a list of more sync blocks than could possibly exist. Total blocks offered: ${blocks}, Minimum time of the last block you offered: ${minimum_time_of_last_offered_block}, Now: ${now}",
|
||||
("blocks", originating_peer->number_of_unfetched_item_ids)
|
||||
("minimum_time_of_last_offered_block", minimum_time_of_last_offered_block)
|
||||
("now", _delegate->get_blockchain_now())));
|
||||
("now", now)));
|
||||
disconnect_from_peer(originating_peer,
|
||||
"You offered me a list of more sync blocks than could possibly exist",
|
||||
true, error_for_peer);
|
||||
|
|
@ -5448,14 +5448,6 @@ namespace graphene { namespace net { namespace detail {
|
|||
INVOKE_AND_COLLECT_STATISTICS(get_block_time, block_id);
|
||||
}
|
||||
|
||||
/** returns graphene::blockchain::now() */
|
||||
fc::time_point_sec statistics_gathering_node_delegate_wrapper::get_blockchain_now()
|
||||
{
|
||||
// this function doesn't need to block,
|
||||
ASSERT_TASK_NOT_PREEMPTED();
|
||||
return _node_delegate->get_blockchain_now();
|
||||
}
|
||||
|
||||
item_hash_t statistics_gathering_node_delegate_wrapper::get_head_block_id() const
|
||||
{
|
||||
INVOKE_AND_COLLECT_STATISTICS(get_head_block_id);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
#include <graphene/chain/database.hpp>
|
||||
#include <graphene/chain/witness_object.hpp>
|
||||
#include <graphene/time/time.hpp>
|
||||
|
||||
#include <graphene/utilities/key_conversion.hpp>
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ add_library( graphene_witness
|
|||
witness.cpp
|
||||
)
|
||||
|
||||
target_link_libraries( graphene_witness graphene_chain graphene_app graphene_time )
|
||||
target_link_libraries( graphene_witness graphene_chain graphene_app )
|
||||
target_include_directories( graphene_witness
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
#include <graphene/chain/database.hpp>
|
||||
#include <graphene/chain/witness_object.hpp>
|
||||
#include <graphene/time/time.hpp>
|
||||
|
||||
#include <graphene/utilities/key_conversion.hpp>
|
||||
|
||||
|
|
@ -51,7 +50,7 @@ void new_chain_banner( const graphene::chain::database& db )
|
|||
"* *\n"
|
||||
"********************************\n"
|
||||
"\n";
|
||||
if( db.get_slot_at_time( graphene::time::now() ) > 200 )
|
||||
if( db.get_slot_at_time( fc::time_point::now() ) > 200 )
|
||||
{
|
||||
std::cerr << "Your genesis seems to have an old timestamp\n"
|
||||
"Please consider using the --genesis-timestamp option to give your genesis a recent timestamp\n"
|
||||
|
|
@ -122,8 +121,6 @@ void witness_plugin::plugin_startup()
|
|||
{ try {
|
||||
ilog("witness plugin: plugin_startup() begin");
|
||||
chain::database& d = database();
|
||||
//Start NTP time client
|
||||
graphene::time::now();
|
||||
|
||||
if( !_witnesses.empty() )
|
||||
{
|
||||
|
|
@ -143,7 +140,6 @@ void witness_plugin::plugin_startup()
|
|||
|
||||
void witness_plugin::plugin_shutdown()
|
||||
{
|
||||
graphene::time::shutdown_ntp_time();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -151,13 +147,12 @@ void witness_plugin::schedule_production_loop()
|
|||
{
|
||||
//Schedule for the next second's tick regardless of chain state
|
||||
// If we would wait less than 50ms, wait for the whole second.
|
||||
fc::time_point ntp_now = graphene::time::now();
|
||||
fc::time_point fc_now = fc::time_point::now();
|
||||
int64_t time_to_next_second = 1000000 - (ntp_now.time_since_epoch().count() % 1000000);
|
||||
fc::time_point now = fc::time_point::now();
|
||||
int64_t time_to_next_second = 1000000 - (now.time_since_epoch().count() % 1000000);
|
||||
if( time_to_next_second < 50000 ) // we must sleep for at least 50ms
|
||||
time_to_next_second += 1000000;
|
||||
|
||||
fc::time_point next_wakeup( fc_now + fc::microseconds( time_to_next_second ) );
|
||||
fc::time_point next_wakeup( now + fc::microseconds( time_to_next_second ) );
|
||||
|
||||
//wdump( (now.time_since_epoch().count())(next_wakeup.time_since_epoch().count()) );
|
||||
_block_production_task = fc::schedule([this]{block_production_loop();},
|
||||
|
|
@ -221,7 +216,7 @@ block_production_condition::block_production_condition_enum witness_plugin::bloc
|
|||
block_production_condition::block_production_condition_enum witness_plugin::maybe_produce_block( fc::mutable_variant_object& capture )
|
||||
{
|
||||
chain::database& db = database();
|
||||
fc::time_point now_fine = graphene::time::now();
|
||||
fc::time_point now_fine = fc::time_point::now();
|
||||
fc::time_point_sec now = now_fine + fc::microseconds( 500000 );
|
||||
|
||||
// If the next block production opportunity is in the present or future, we're synced.
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
file(GLOB HEADERS "include/graphene/time/*.hpp")
|
||||
|
||||
add_library( graphene_time
|
||||
time.cpp
|
||||
)
|
||||
|
||||
target_link_libraries( graphene_time fc )
|
||||
target_include_directories( graphene_time
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
|
||||
|
||||
install( TARGETS
|
||||
graphene_time
|
||||
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
)
|
||||
install( FILES ${HEADERS} DESTINATION "include/graphene/time" )
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Cryptonomex, Inc., and contributors.
|
||||
*
|
||||
* The MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <fc/optional.hpp>
|
||||
#include <fc/signals.hpp>
|
||||
#include <fc/time.hpp>
|
||||
|
||||
namespace graphene { namespace time {
|
||||
|
||||
typedef fc::signal<void()> time_discontinuity_signal_type;
|
||||
extern time_discontinuity_signal_type time_discontinuity_signal;
|
||||
|
||||
fc::optional<fc::time_point> ntp_time();
|
||||
fc::time_point now();
|
||||
fc::time_point nonblocking_now(); // identical to now() but guaranteed not to block
|
||||
void update_ntp_time();
|
||||
fc::microseconds ntp_error();
|
||||
void shutdown_ntp_time();
|
||||
|
||||
void start_simulated_time( const fc::time_point sim_time );
|
||||
void advance_simulated_time_to( const fc::time_point sim_time );
|
||||
void advance_time( int32_t delta_seconds );
|
||||
|
||||
} } // graphene::time
|
||||
|
|
@ -1,126 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Cryptonomex, Inc., and contributors.
|
||||
*
|
||||
* The MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <graphene/time/time.hpp>
|
||||
|
||||
#include <fc/exception/exception.hpp>
|
||||
#include <fc/network/ntp.hpp>
|
||||
#include <fc/thread/mutex.hpp>
|
||||
#include <fc/thread/scoped_lock.hpp>
|
||||
|
||||
#include <atomic>
|
||||
|
||||
namespace graphene { namespace time {
|
||||
|
||||
static int32_t simulated_time = 0;
|
||||
static int32_t adjusted_time_sec = 0;
|
||||
|
||||
time_discontinuity_signal_type time_discontinuity_signal;
|
||||
|
||||
namespace detail
|
||||
{
|
||||
std::atomic<fc::ntp*> ntp_service(nullptr);
|
||||
fc::mutex ntp_service_initialization_mutex;
|
||||
}
|
||||
|
||||
fc::optional<fc::time_point> ntp_time()
|
||||
{
|
||||
fc::ntp* actual_ntp_service = detail::ntp_service.load();
|
||||
if (!actual_ntp_service)
|
||||
{
|
||||
fc::scoped_lock<fc::mutex> lock(detail::ntp_service_initialization_mutex);
|
||||
actual_ntp_service = detail::ntp_service.load();
|
||||
if (!actual_ntp_service)
|
||||
{
|
||||
actual_ntp_service = new fc::ntp;
|
||||
detail::ntp_service.store(actual_ntp_service);
|
||||
}
|
||||
}
|
||||
return actual_ntp_service->get_time();
|
||||
}
|
||||
|
||||
void shutdown_ntp_time()
|
||||
{
|
||||
fc::ntp* actual_ntp_service = detail::ntp_service.exchange(nullptr);
|
||||
delete actual_ntp_service;
|
||||
}
|
||||
|
||||
fc::time_point now()
|
||||
{
|
||||
if( simulated_time )
|
||||
return fc::time_point() + fc::seconds( simulated_time + adjusted_time_sec );
|
||||
|
||||
fc::optional<fc::time_point> current_ntp_time = ntp_time();
|
||||
if( current_ntp_time.valid() )
|
||||
return *current_ntp_time + fc::seconds( adjusted_time_sec );
|
||||
else
|
||||
return fc::time_point::now() + fc::seconds( adjusted_time_sec );
|
||||
}
|
||||
|
||||
fc::time_point nonblocking_now()
|
||||
{
|
||||
if (simulated_time)
|
||||
return fc::time_point() + fc::seconds(simulated_time + adjusted_time_sec);
|
||||
|
||||
fc::ntp* actual_ntp_service = detail::ntp_service.load();
|
||||
fc::optional<fc::time_point> current_ntp_time;
|
||||
if (actual_ntp_service)
|
||||
current_ntp_time = actual_ntp_service->get_time();
|
||||
|
||||
if (current_ntp_time)
|
||||
return *current_ntp_time + fc::seconds(adjusted_time_sec);
|
||||
else
|
||||
return fc::time_point::now() + fc::seconds(adjusted_time_sec);
|
||||
}
|
||||
|
||||
void update_ntp_time()
|
||||
{
|
||||
detail::ntp_service.load()->request_now();
|
||||
}
|
||||
|
||||
fc::microseconds ntp_error()
|
||||
{
|
||||
fc::optional<fc::time_point> current_ntp_time = ntp_time();
|
||||
FC_ASSERT( current_ntp_time, "We don't have NTP time!" );
|
||||
return *current_ntp_time - fc::time_point::now();
|
||||
}
|
||||
|
||||
void start_simulated_time( const fc::time_point sim_time )
|
||||
{
|
||||
simulated_time = sim_time.sec_since_epoch();
|
||||
adjusted_time_sec = 0;
|
||||
}
|
||||
void advance_simulated_time_to( const fc::time_point sim_time )
|
||||
{
|
||||
simulated_time = sim_time.sec_since_epoch();
|
||||
adjusted_time_sec = 0;
|
||||
}
|
||||
|
||||
void advance_time( int32_t delta_seconds )
|
||||
{
|
||||
adjusted_time_sec += delta_seconds;
|
||||
time_discontinuity_signal();
|
||||
}
|
||||
|
||||
} } // graphene::time
|
||||
|
|
@ -351,7 +351,7 @@ class wallet_api
|
|||
* This returns a list of operation history objects, which describe activity on the account.
|
||||
*
|
||||
* @param name the name or id of the account
|
||||
* @param limit the number of entries to return (starting from the most recent) (max 100)
|
||||
* @param limit the number of entries to return (starting from the most recent)
|
||||
* @returns a list of \c operation_history_objects
|
||||
*/
|
||||
vector<operation_detail> get_account_history(string name, int limit)const;
|
||||
|
|
|
|||
|
|
@ -19,11 +19,11 @@ target_link_libraries( performance_test graphene_chain graphene_app graphene_acc
|
|||
|
||||
file(GLOB BENCH_MARKS "benchmarks/*.cpp")
|
||||
add_executable( chain_bench ${BENCH_MARKS} ${COMMON_SOURCES} )
|
||||
target_link_libraries( chain_bench graphene_chain graphene_app graphene_account_history graphene_bookie graphene_time graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} )
|
||||
target_link_libraries( chain_bench graphene_chain graphene_app graphene_account_history graphene_bookie graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} )
|
||||
|
||||
file(GLOB APP_SOURCES "app/*.cpp")
|
||||
add_executable( app_test ${APP_SOURCES} )
|
||||
target_link_libraries( app_test graphene_app graphene_account_history graphene_bookie graphene_net graphene_chain graphene_time graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} )
|
||||
target_link_libraries( app_test graphene_app graphene_account_history graphene_bookie graphene_net graphene_chain graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} )
|
||||
|
||||
file(GLOB INTENSE_SOURCES "intense/*.cpp")
|
||||
add_executable( intense_test ${INTENSE_SOURCES} ${COMMON_SOURCES} )
|
||||
|
|
|
|||
|
|
@ -26,8 +26,6 @@
|
|||
|
||||
#include <graphene/chain/balance_object.hpp>
|
||||
|
||||
#include <graphene/time/time.hpp>
|
||||
|
||||
#include <graphene/utilities/tempdir.hpp>
|
||||
|
||||
#include <graphene/account_history/account_history_plugin.hpp>
|
||||
|
|
|
|||
|
|
@ -25,8 +25,6 @@
|
|||
#include <graphene/chain/account_object.hpp>
|
||||
#include <graphene/utilities/tempdir.hpp>
|
||||
|
||||
#include <graphene/time/time.hpp>
|
||||
|
||||
#include <fc/crypto/digest.hpp>
|
||||
#include <fc/smart_ref_impl.hpp>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue