Compare commits
2 commits
master
...
bug/issue-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e391f5a5b | ||
|
|
cff6cbec26 |
4 changed files with 59 additions and 14 deletions
12
Dockerfile
12
Dockerfile
|
|
@ -1,4 +1,4 @@
|
||||||
FROM ubuntu:18.04
|
FROM ubuntu:20.04
|
||||||
MAINTAINER PeerPlays Blockchain Standards Association
|
MAINTAINER PeerPlays Blockchain Standards Association
|
||||||
|
|
||||||
ENV LANG en_US.UTF-8
|
ENV LANG en_US.UTF-8
|
||||||
|
|
@ -59,7 +59,7 @@ RUN \
|
||||||
cd build/release && \
|
cd build/release && \
|
||||||
cmake \
|
cmake \
|
||||||
-DBOOST_ROOT="$BOOST_ROOT" \
|
-DBOOST_ROOT="$BOOST_ROOT" \
|
||||||
-DCMAKE_BUILD_TYPE=Debug \
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
../.. && \
|
../.. && \
|
||||||
make witness_node cli_wallet && \
|
make witness_node cli_wallet && \
|
||||||
install -s programs/witness_node/witness_node programs/cli_wallet/cli_wallet /usr/local/bin && \
|
install -s programs/witness_node/witness_node programs/cli_wallet/cli_wallet /usr/local/bin && \
|
||||||
|
|
@ -82,10 +82,16 @@ VOLUME ["/var/lib/peerplays", "/etc/peerplays"]
|
||||||
# rpc service:
|
# rpc service:
|
||||||
EXPOSE 8090
|
EXPOSE 8090
|
||||||
# p2p service:
|
# p2p service:
|
||||||
EXPOSE 1776
|
EXPOSE 9777
|
||||||
|
EXPOSE 19777
|
||||||
|
EXPOSE 29777
|
||||||
|
EXPOSE 39777
|
||||||
|
EXPOSE 49777
|
||||||
|
EXPOSE 59777
|
||||||
|
|
||||||
# default exec/config files
|
# default exec/config files
|
||||||
ADD docker/default_config.ini /etc/peerplays/config.ini
|
ADD docker/default_config.ini /etc/peerplays/config.ini
|
||||||
|
ADD docker/logging.ini /etc/peerplays/logging.ini
|
||||||
ADD docker/peerplaysentry.sh /usr/local/bin/peerplaysentry.sh
|
ADD docker/peerplaysentry.sh /usr/local/bin/peerplaysentry.sh
|
||||||
RUN chmod a+x /usr/local/bin/peerplaysentry.sh
|
RUN chmod a+x /usr/local/bin/peerplaysentry.sh
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,7 @@ fi
|
||||||
## Link the peerplays config file into home
|
## Link the peerplays config file into home
|
||||||
## This link has been created in Dockerfile, already
|
## This link has been created in Dockerfile, already
|
||||||
ln -f -s /etc/peerplays/config.ini /var/lib/peerplays
|
ln -f -s /etc/peerplays/config.ini /var/lib/peerplays
|
||||||
|
ln -f -s /etc/peerplays/logging.ini /var/lib/peerplays
|
||||||
|
|
||||||
# Plugins need to be provided in a space-separated list, which
|
# Plugins need to be provided in a space-separated list, which
|
||||||
# makes it necessary to write it like this
|
# makes it necessary to write it like this
|
||||||
|
|
|
||||||
|
|
@ -103,8 +103,15 @@ void block_database::remove( const block_id_type& id )
|
||||||
index_entry e;
|
index_entry e;
|
||||||
auto index_pos = sizeof(e)*block_header::num_from_id(id);
|
auto index_pos = sizeof(e)*block_header::num_from_id(id);
|
||||||
_block_num_to_pos.seekg( 0, _block_num_to_pos.end );
|
_block_num_to_pos.seekg( 0, _block_num_to_pos.end );
|
||||||
if ( _block_num_to_pos.tellg() <= index_pos )
|
|
||||||
|
std::streampos s_pos = _block_num_to_pos.tellg();
|
||||||
|
if (-1 == s_pos){
|
||||||
|
FC_THROW_EXCEPTION(fc::key_not_found_exception, "Block ${id} not contained in block database, _block_num_to_pos.tellg failed", ("id", id));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( static_cast<uint32_t>(s_pos) <= index_pos ){
|
||||||
FC_THROW_EXCEPTION(fc::key_not_found_exception, "Block ${id} not contained in block database", ("id", id));
|
FC_THROW_EXCEPTION(fc::key_not_found_exception, "Block ${id} not contained in block database", ("id", id));
|
||||||
|
}
|
||||||
|
|
||||||
_block_num_to_pos.seekg( index_pos );
|
_block_num_to_pos.seekg( index_pos );
|
||||||
_block_num_to_pos.read( (char*)&e, sizeof(e) );
|
_block_num_to_pos.read( (char*)&e, sizeof(e) );
|
||||||
|
|
@ -118,20 +125,27 @@ void block_database::remove( const block_id_type& id )
|
||||||
} FC_CAPTURE_AND_RETHROW( (id) ) }
|
} FC_CAPTURE_AND_RETHROW( (id) ) }
|
||||||
|
|
||||||
bool block_database::contains( const block_id_type& id )const
|
bool block_database::contains( const block_id_type& id )const
|
||||||
{
|
{ try {
|
||||||
if( id == block_id_type() )
|
if( id == block_id_type() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
index_entry e;
|
index_entry e;
|
||||||
auto index_pos = sizeof(e)*block_header::num_from_id(id);
|
auto index_pos = sizeof(e)*block_header::num_from_id(id);
|
||||||
_block_num_to_pos.seekg( 0, _block_num_to_pos.end );
|
_block_num_to_pos.seekg( 0, _block_num_to_pos.end );
|
||||||
if ( _block_num_to_pos.tellg() < index_pos + sizeof(e) )
|
|
||||||
|
std::streampos s_pos = _block_num_to_pos.tellg();
|
||||||
|
if (-1 == s_pos){
|
||||||
|
FC_THROW_EXCEPTION(fc::key_not_found_exception, "Block ${id} not contained in block database, _block_num_to_pos.tellg failed", ("id", id));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( static_cast<uint32_t>(s_pos) < index_pos + sizeof(e) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_block_num_to_pos.seekg( index_pos );
|
_block_num_to_pos.seekg( index_pos );
|
||||||
_block_num_to_pos.read( (char*)&e, sizeof(e) );
|
_block_num_to_pos.read( (char*)&e, sizeof(e) );
|
||||||
|
|
||||||
return e.block_id == id && e.block_size > 0;
|
return e.block_id == id && e.block_size > 0;
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (id) ) }
|
||||||
|
|
||||||
block_id_type block_database::fetch_block_id( uint32_t block_num )const
|
block_id_type block_database::fetch_block_id( uint32_t block_num )const
|
||||||
{
|
{
|
||||||
|
|
@ -156,7 +170,13 @@ optional<signed_block> block_database::fetch_optional( const block_id_type& id )
|
||||||
index_entry e;
|
index_entry e;
|
||||||
auto index_pos = sizeof(e)*block_header::num_from_id(id);
|
auto index_pos = sizeof(e)*block_header::num_from_id(id);
|
||||||
_block_num_to_pos.seekg( 0, _block_num_to_pos.end );
|
_block_num_to_pos.seekg( 0, _block_num_to_pos.end );
|
||||||
if ( _block_num_to_pos.tellg() <= index_pos )
|
std::streampos s_pos = _block_num_to_pos.tellg();
|
||||||
|
|
||||||
|
if (-1 == s_pos){
|
||||||
|
FC_THROW_EXCEPTION(fc::key_not_found_exception, "Block ${id} not contained in block database, _block_num_to_pos.tellg failed", ("id", id));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( static_cast<uint32_t>(s_pos) <= index_pos )
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
_block_num_to_pos.seekg( index_pos );
|
_block_num_to_pos.seekg( index_pos );
|
||||||
|
|
@ -188,7 +208,12 @@ optional<signed_block> block_database::fetch_by_number( uint32_t block_num )cons
|
||||||
index_entry e;
|
index_entry e;
|
||||||
auto index_pos = sizeof(e)*block_num;
|
auto index_pos = sizeof(e)*block_num;
|
||||||
_block_num_to_pos.seekg( 0, _block_num_to_pos.end );
|
_block_num_to_pos.seekg( 0, _block_num_to_pos.end );
|
||||||
if ( _block_num_to_pos.tellg() <= index_pos )
|
std::streampos s_pos = _block_num_to_pos.tellg();
|
||||||
|
if (-1 == s_pos){
|
||||||
|
FC_THROW_EXCEPTION(fc::key_not_found_exception, "Block ${block_num} not contained in block database, _block_num_to_pos.tellg failed", ("block_num", block_num));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( static_cast<uint32_t>(s_pos) <= index_pos )
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
_block_num_to_pos.seekg( index_pos, _block_num_to_pos.beg );
|
_block_num_to_pos.seekg( index_pos, _block_num_to_pos.beg );
|
||||||
|
|
@ -217,7 +242,11 @@ optional<index_entry> block_database::last_index_entry()const {
|
||||||
|
|
||||||
_block_num_to_pos.seekg( 0, _block_num_to_pos.end );
|
_block_num_to_pos.seekg( 0, _block_num_to_pos.end );
|
||||||
std::streampos pos = _block_num_to_pos.tellg();
|
std::streampos pos = _block_num_to_pos.tellg();
|
||||||
if( pos < sizeof(index_entry) )
|
if (-1 == pos){
|
||||||
|
FC_THROW_EXCEPTION(fc::key_not_found_exception, "last_index_entry tellg failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
if( static_cast<size_t>(pos) < sizeof(index_entry) )
|
||||||
return optional<index_entry>();
|
return optional<index_entry>();
|
||||||
|
|
||||||
pos -= pos % sizeof(index_entry);
|
pos -= pos % sizeof(index_entry);
|
||||||
|
|
@ -230,7 +259,7 @@ optional<index_entry> block_database::last_index_entry()const {
|
||||||
_block_num_to_pos.seekg( pos );
|
_block_num_to_pos.seekg( pos );
|
||||||
_block_num_to_pos.read( (char*)&e, sizeof(e) );
|
_block_num_to_pos.read( (char*)&e, sizeof(e) );
|
||||||
if( _block_num_to_pos.gcount() == sizeof(e) && e.block_size > 0
|
if( _block_num_to_pos.gcount() == sizeof(e) && e.block_size > 0
|
||||||
&& e.block_pos + e.block_size <= blocks_size )
|
&& e.block_pos + static_cast<uint64_t>(e.block_size) <= static_cast<uint64_t>(blocks_size) )
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
vector<char> data( e.block_size );
|
vector<char> data( e.block_size );
|
||||||
|
|
|
||||||
|
|
@ -477,6 +477,7 @@ namespace graphene { namespace net { namespace detail {
|
||||||
// @{
|
// @{
|
||||||
fc::promise<void>::ptr _retrigger_advertise_inventory_loop_promise;
|
fc::promise<void>::ptr _retrigger_advertise_inventory_loop_promise;
|
||||||
fc::future<void> _advertise_inventory_loop_done;
|
fc::future<void> _advertise_inventory_loop_done;
|
||||||
|
fc::mutex _new_inventory_mutex; /// mutex to protect _new_inventory
|
||||||
std::unordered_set<item_id> _new_inventory; /// list of items we have received but not yet advertised to our peers
|
std::unordered_set<item_id> _new_inventory; /// list of items we have received but not yet advertised to our peers
|
||||||
// @}
|
// @}
|
||||||
|
|
||||||
|
|
@ -1239,7 +1240,11 @@ namespace graphene { namespace net { namespace detail {
|
||||||
dlog("beginning an iteration of advertise inventory");
|
dlog("beginning an iteration of advertise inventory");
|
||||||
// swap inventory into local variable, clearing the node's copy
|
// swap inventory into local variable, clearing the node's copy
|
||||||
std::unordered_set<item_id> inventory_to_advertise;
|
std::unordered_set<item_id> inventory_to_advertise;
|
||||||
|
|
||||||
|
{
|
||||||
|
fc::scoped_lock<fc::mutex> lock(_new_inventory_mutex);
|
||||||
inventory_to_advertise.swap(_new_inventory);
|
inventory_to_advertise.swap(_new_inventory);
|
||||||
|
}
|
||||||
|
|
||||||
// process all inventory to advertise and construct the inventory messages we'll send
|
// process all inventory to advertise and construct the inventory messages we'll send
|
||||||
// first, then send them all in a batch (to avoid any fiber interruption points while
|
// first, then send them all in a batch (to avoid any fiber interruption points while
|
||||||
|
|
@ -1295,6 +1300,7 @@ namespace graphene { namespace net { namespace detail {
|
||||||
iter->first->send_message(iter->second);
|
iter->first->send_message(iter->second);
|
||||||
inventory_messages_to_send.clear();
|
inventory_messages_to_send.clear();
|
||||||
|
|
||||||
|
fc::scoped_lock<fc::mutex> lock(_new_inventory_mutex);
|
||||||
if (_new_inventory.empty())
|
if (_new_inventory.empty())
|
||||||
{
|
{
|
||||||
_retrigger_advertise_inventory_loop_promise = fc::promise<void>::ptr(new fc::promise<void>("graphene::net::retrigger_advertise_inventory_loop"));
|
_retrigger_advertise_inventory_loop_promise = fc::promise<void>::ptr(new fc::promise<void>("graphene::net::retrigger_advertise_inventory_loop"));
|
||||||
|
|
@ -4964,7 +4970,10 @@ namespace graphene { namespace net { namespace detail {
|
||||||
message_hash_type hash_of_item_to_broadcast = item_to_broadcast.id();
|
message_hash_type hash_of_item_to_broadcast = item_to_broadcast.id();
|
||||||
|
|
||||||
_message_cache.cache_message( item_to_broadcast, hash_of_item_to_broadcast, propagation_data, hash_of_message_contents );
|
_message_cache.cache_message( item_to_broadcast, hash_of_item_to_broadcast, propagation_data, hash_of_message_contents );
|
||||||
|
{
|
||||||
|
fc::scoped_lock<fc::mutex> lock(_new_inventory_mutex);
|
||||||
_new_inventory.insert( item_id(item_to_broadcast.msg_type, hash_of_item_to_broadcast ) );
|
_new_inventory.insert( item_id(item_to_broadcast.msg_type, hash_of_item_to_broadcast ) );
|
||||||
|
}
|
||||||
trigger_advertise_inventory_loop();
|
trigger_advertise_inventory_loop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue