Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion COPYING
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
This license applies to all works under this directory.

Libbitcoin - C++ Bitcoin Development Toolkit and Applications
Copyright © 2011-2017 libbitcoin developers (see AUTHORS)
Copyright © 2011-2018 libbitcoin developers (see AUTHORS)

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion console/executor.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion console/executor.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion console/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node/configuration.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node/define.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node/full_node.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node/parser.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node/protocols/protocol_block_in.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node/protocols/protocol_block_out.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
4 changes: 3 additions & 1 deletion include/bitcoin/node/protocols/protocol_block_sync.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down Expand Up @@ -61,6 +61,8 @@ class BCN_API protocol_block_sync

reservation::ptr reservation_;
mutable upgrade_mutex mutex_;
const bool require_witness_;
const bool peer_witness_;
};

} // namespace node
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node/protocols/protocol_header_in.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node/protocols/protocol_transaction_in.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node/sessions/session.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node/sessions/session_inbound.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node/sessions/session_manual.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node/sessions/session_outbound.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node/settings.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node/utility/check_list.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node/utility/hash_queue.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node/utility/performance.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node/utility/reservation.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node/utility/reservations.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node/utility/statistics.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion src/configuration.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion src/full_node.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion src/parser.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion src/protocols/protocol_block_in.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion src/protocols/protocol_block_out.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
24 changes: 22 additions & 2 deletions src/protocols/protocol_block_sync.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down Expand Up @@ -42,12 +42,20 @@ using namespace std::placeholders;
// The moving window in which block average download rate is measured.
static const asio::seconds monitor_interval(5);

inline bool is_witness(uint64_t services)
{
return (services & version::service::node_witness) != 0;
}

// Depends on protocol_header_sync, which requires protocol version 31800.
protocol_block_sync::protocol_block_sync(full_node& node, channel::ptr channel,
safe_chain& chain)
: protocol_timer(node, channel, true, NAME),
chain_(chain),
reservation_(node.get_reservation()),
// Witness must be requested if possibly enforced.
require_witness_(is_witness(node.network_settings().services)),
peer_witness_(is_witness(channel->peer_version()->services())),
CONSTRUCT_TRACK(protocol_block_sync)
{
}
Expand Down Expand Up @@ -80,12 +88,16 @@ void protocol_block_sync::send_get_blocks()
return;

// Repopulate if empty and new work has arrived.
const auto request = reservation_->request();
auto request = reservation_->request();

// Or we may be the same channel and with hashes already requested.
if (request.inventories().empty())
return;

// Convert requested message types to corresponding witness types.
if (require_witness_)
request.to_witness();

LOG_DEBUG(LOG_NODE)
<< "Sending request of " << request.inventories().size()
<< " hashes for slot (" << reservation_->slot() << ").";
Expand Down Expand Up @@ -118,6 +130,14 @@ bool protocol_block_sync::handle_receive_block(const code& ec,
return false;
}

// Do not process incoming blocks if required witness is unavailable.
// The channel will remain active outbound unless node becomes stale.
if (require_witness_ && !peer_witness_)
{
stop(error::channel_stopped);
return false;
}

size_t height;

// The reservation may have become stopped between the stop test and this
Expand Down
2 changes: 1 addition & 1 deletion src/protocols/protocol_header_in.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion src/protocols/protocol_transaction_in.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion src/protocols/protocol_transaction_out.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion src/sessions/session_inbound.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion src/sessions/session_manual.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion src/sessions/session_outbound.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion src/settings.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion src/utility/check_list.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion src/utility/hash_queue.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion src/utility/performance.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion src/utility/reservation.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion src/utility/reservations.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion test/check_list.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion test/configuration.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion test/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
2 changes: 1 addition & 1 deletion test/node.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS)
* Copyright (c) 2011-2018 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
Expand Down
Loading