| 3006 | } |
| 3007 | |
| 3008 | void node_impl::send_sync_block_to_node_delegate(const graphene::net::block_message& block_message_to_send) |
| 3009 | { |
| 3010 | dlog("in send_sync_block_to_node_delegate()"); |
| 3011 | bool client_accepted_block = false; |
| 3012 | bool discontinue_fetching_blocks_from_peer = false; |
| 3013 | |
| 3014 | fc::oexception handle_message_exception; |
| 3015 | |
| 3016 | try |
| 3017 | { |
| 3018 | std::vector<fc::uint160_t> contained_transaction_message_ids; |
| 3019 | _delegate->handle_block(block_message_to_send, true, contained_transaction_message_ids); |
| 3020 | ilog("Successfully pushed sync block ${num} (id:${id})", |
| 3021 | ("num", block_message_to_send.block.block_num()) |
| 3022 | ("id", block_message_to_send.block_id)); |
| 3023 | _most_recent_blocks_accepted.push_back(block_message_to_send.block_id); |
| 3024 | |
| 3025 | client_accepted_block = true; |
| 3026 | } |
| 3027 | catch (const block_older_than_undo_history& e) |
| 3028 | { |
| 3029 | wlog("Failed to push sync block ${num} (id:${id}): block is on a fork older than our undo history would " |
| 3030 | "allow us to switch to: ${e}", |
| 3031 | ("num", block_message_to_send.block.block_num()) |
| 3032 | ("id", block_message_to_send.block_id) |
| 3033 | ("e", (fc::exception)e)); |
| 3034 | handle_message_exception = e; |
| 3035 | discontinue_fetching_blocks_from_peer = true; |
| 3036 | } |
| 3037 | catch (const fc::canceled_exception&) |
| 3038 | { |
| 3039 | throw; |
| 3040 | } |
| 3041 | catch (const fc::exception& e) |
| 3042 | { |
| 3043 | wlog("Failed to push sync block ${num} (id:${id}): client rejected sync block sent by peer: ${e}", |
| 3044 | ("num", block_message_to_send.block.block_num()) |
| 3045 | ("id", block_message_to_send.block_id) |
| 3046 | ("e", e)); |
| 3047 | handle_message_exception = e; |
| 3048 | } |
| 3049 | |
| 3050 | // build up lists for any potentially-blocking operations we need to do, then do them |
| 3051 | // at the end of this function |
| 3052 | std::set<peer_connection_ptr> peers_with_newly_empty_item_lists; |
| 3053 | std::set<peer_connection_ptr> peers_we_need_to_sync_to; |
| 3054 | std::map<peer_connection_ptr, std::pair<std::string, fc::oexception> > peers_to_disconnect; // map peer -> pair<reason_string, exception> |
| 3055 | |
| 3056 | if( client_accepted_block ) |
| 3057 | { |
| 3058 | --_total_number_of_unfetched_items; |
| 3059 | dlog("sync: client accpted the block, we now have only ${count} items left to fetch before we're in sync", |
| 3060 | ("count", _total_number_of_unfetched_items)); |
| 3061 | bool is_fork_block = is_hard_fork_block(block_message_to_send.block.block_num()); |
| 3062 | for (const peer_connection_ptr& peer : _active_connections) |
| 3063 | { |
| 3064 | ASSERT_TASK_NOT_PREEMPTED(); // don't yield while iterating over _active_connections |
| 3065 | bool disconnecting_this_peer = false; |
nothing calls this directly
no test coverage detected