summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmir Taaki <genjix@riseup.net>2014-03-23 02:06:40 (GMT)
committer Amir Taaki <genjix@riseup.net>2014-03-24 19:25:53 (GMT)
commit91d1c5c0376365bb64b7f392ab832e1d28f7e89c (patch)
treecb247cf8370609af8e90b27b6bdb51ee6415aeb6
parentae5f9b32ea98cf9f8145fd1fa68e7facc6a4d81a (diff)
beautified code, by removing posix_time:: prefixes.
-rw-r--r--src/network/channel.cpp11
-rw-r--r--src/network/network.cpp12
-rw-r--r--src/network/protocol.cpp8
-rw-r--r--src/session.cpp8
-rw-r--r--src/validate.cpp19
5 files changed, 29 insertions, 29 deletions
diff --git a/src/network/channel.cpp b/src/network/channel.cpp
index ad1a14e..d7eb0db 100644
--- a/src/network/channel.cpp
+++ b/src/network/channel.cpp
@@ -23,10 +23,9 @@ namespace libbitcoin {
using std::placeholders::_1;
using std::placeholders::_2;
-
-using boost::posix_time::seconds;
-using boost::posix_time::minutes;
using boost::posix_time::time_duration;
+using boost::posix_time::minutes;
+using boost::posix_time::seconds;
using boost::asio::buffer;
// Connection timeout time
@@ -218,16 +217,14 @@ void channel_proxy::handle_heartbeat(const boost::system::error_code& ec)
send(ping_type(), handle_ping);
}
-void channel_proxy::set_timeout(
- const boost::posix_time::time_duration timeout)
+void channel_proxy::set_timeout(const time_duration timeout)
{
timeout_.cancel();
timeout_.expires_from_now(timeout);
timeout_.async_wait(std::bind(
&channel_proxy::handle_timeout, shared_from_this(), _1));
}
-void channel_proxy::set_heartbeat(
- const boost::posix_time::time_duration timeout)
+void channel_proxy::set_heartbeat(const time_duration timeout)
{
heartbeat_.cancel();
heartbeat_.expires_from_now(timeout);
diff --git a/src/network/network.cpp b/src/network/network.cpp
index aace913..b34d409 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -27,10 +27,12 @@
namespace libbitcoin {
-constexpr size_t connect_timeout = 5;
-
using std::placeholders::_1;
using std::placeholders::_2;
+using boost::posix_time::time_duration;
+using boost::posix_time::seconds;
+
+const time_duration connect_timeout = seconds(5);
acceptor::acceptor(threadpool& pool, tcp_acceptor_ptr tcp_accept)
: pool_(pool), tcp_accept_(tcp_accept)
@@ -69,10 +71,10 @@ public:
proxy_ = std::make_shared<channel_proxy>(pool, socket_);
}
- void start(tcp::resolver::iterator endpoint_iterator, size_t timeout,
- network::connect_handler handle_connect)
+ void start(tcp::resolver::iterator endpoint_iterator,
+ time_duration timeout, network::connect_handler handle_connect)
{
- timer_.expires_from_now(boost::posix_time::seconds(timeout));
+ timer_.expires_from_now(timeout);
timer_.async_wait(std::bind(
&perform_connect_with_timeout::close, shared_from_this(), _1));
diff --git a/src/network/protocol.cpp b/src/network/protocol.cpp
index b246b49..af4cdfb 100644
--- a/src/network/protocol.cpp
+++ b/src/network/protocol.cpp
@@ -25,11 +25,13 @@
namespace libbitcoin {
-constexpr size_t watermark_limit = 2000;
-const boost::posix_time::seconds watermark_reset_interval(5);
-
using std::placeholders::_1;
using std::placeholders::_2;
+using boost::posix_time::time_duration;
+using boost::posix_time::seconds;
+
+constexpr size_t watermark_limit = 2000;
+const time_duration watermark_reset_interval = seconds(5);
static std::string pretty(const ip_address_type& ip)
{
diff --git a/src/session.cpp b/src/session.cpp
index 1d5fb9f..292656f 100644
--- a/src/session.cpp
+++ b/src/session.cpp
@@ -35,9 +35,9 @@ session::session(threadpool& pool, const session_params& params)
{
}
-void handle_set_start_height(const std::error_code&)
+void handle_handshake_height_set(const std::error_code&)
{
- // Set start height in handshake
+ // Start height now set in handshake
// Do nothing
}
void session::start(completion_handler handle_complete)
@@ -54,7 +54,7 @@ void session::start(completion_handler handle_complete)
std::bind(&session::new_channel, this, _1, _2));
chain_.fetch_last_height(
std::bind(&handshake::set_start_height,
- &handshake_, _2, handle_set_start_height));
+ &handshake_, _2, handle_handshake_height_set));
chain_.subscribe_reorganize(
std::bind(&session::set_start_height,
this, _1, _2, _3, _4));
@@ -94,7 +94,7 @@ void session::set_start_height(const std::error_code& ec, size_t fork_point,
return;
}
size_t last_height = fork_point + new_blocks.size();
- handshake_.set_start_height(last_height, handle_set_start_height);
+ handshake_.set_start_height(last_height, handle_handshake_height_set);
chain_.subscribe_reorganize(
std::bind(&session::set_start_height,
this, _1, _2, _3, _4));
diff --git a/src/validate.cpp b/src/validate.cpp
index e0107ca..1149000 100644
--- a/src/validate.cpp
+++ b/src/validate.cpp
@@ -20,9 +20,7 @@
#include <bitcoin/validate.hpp>
#include <set>
-
#include <boost/date_time/posix_time/posix_time.hpp>
-
#include <bitcoin/blockchain/blockchain.hpp>
#include <bitcoin/block.hpp>
#include <bitcoin/constants.hpp>
@@ -34,15 +32,17 @@
namespace libbitcoin {
-constexpr size_t max_block_size = 1000000;
-constexpr size_t max_block_script_sig_operations = max_block_size / 50;
-
using std::placeholders::_1;
using std::placeholders::_2;
using std::placeholders::_3;
using std::placeholders::_4;
+using boost::posix_time::ptime;
+using boost::posix_time::from_time_t;
+using boost::posix_time::second_clock;
+using boost::posix_time::hours;
-namespace posix_time = boost::posix_time;
+constexpr size_t max_block_size = 1000000;
+constexpr size_t max_block_script_sig_operations = max_block_size / 50;
validate_transaction::validate_transaction(
blockchain& chain, const transaction_type& tx,
@@ -375,10 +375,9 @@ std::error_code validate_block::check_block()
if (!check_proof_of_work(current_block_hash, blk_header.bits))
return error::proof_of_work;
- const posix_time::ptime block_time =
- posix_time::from_time_t(blk_header.timestamp);
- const posix_time::ptime two_hour_future =
- posix_time::second_clock::universal_time() + posix_time::hours(2);
+ const ptime block_time = from_time_t(blk_header.timestamp);
+ const ptime two_hour_future =
+ second_clock::universal_time() + hours(2);
if (block_time > two_hour_future)
return error::futuristic_timestamp;