提交 5d4fd13d 编写于 作者: B Bill Hamilton

Merge remote-tracking branch 'upstream_eosio/master' into eosio_build_verify

Merging master
...@@ -208,6 +208,7 @@ namespace eosio { namespace chain { ...@@ -208,6 +208,7 @@ namespace eosio { namespace chain {
bytes packed_context_free_data; bytes packed_context_free_data;
bytes packed_trx; bytes packed_trx;
transaction_id_type id()const;
bytes get_raw_transaction()const; bytes get_raw_transaction()const;
vector<bytes> get_context_free_data()const; vector<bytes> get_context_free_data()const;
transaction get_transaction()const; transaction get_transaction()const;
......
...@@ -255,6 +255,13 @@ vector<bytes> packed_transaction::get_context_free_data()const ...@@ -255,6 +255,13 @@ vector<bytes> packed_transaction::get_context_free_data()const
} FC_CAPTURE_AND_RETHROW((compression)(packed_context_free_data)) } FC_CAPTURE_AND_RETHROW((compression)(packed_context_free_data))
} }
transaction_id_type packed_transaction::id()const
{
try {
return get_transaction().id();
} FC_CAPTURE_AND_RETHROW((compression)(packed_trx))
}
transaction packed_transaction::get_transaction()const transaction packed_transaction::get_transaction()const
{ {
try { try {
......
...@@ -578,7 +578,11 @@ namespace eosio { ...@@ -578,7 +578,11 @@ namespace eosio {
public: public:
uint32_t just_send_it_max; uint32_t just_send_it_max;
connection_ptr pending_txn_source; connection_ptr pending_txn_source;
vector<block_id_type> req_blks; struct block_request {
block_id_type id;
bool local_retry;
};
vector<block_request> req_blks;
vector<transaction_id_type> req_txn; vector<transaction_id_type> req_txn;
void bcast_block (const signed_block_summary& msg, connection_ptr skip = connection_ptr()); void bcast_block (const signed_block_summary& msg, connection_ptr skip = connection_ptr());
...@@ -588,7 +592,7 @@ namespace eosio { ...@@ -588,7 +592,7 @@ namespace eosio {
void rejected_transaction (const packed_transaction& msg); void rejected_transaction (const packed_transaction& msg);
void recv_block (connection_ptr conn, const signed_block_summary& msg); void recv_block (connection_ptr conn, const signed_block_summary& msg);
void recv_transaction(connection_ptr c); void recv_transaction(connection_ptr c);
void recv_notice (connection_ptr conn, const notice_message& msg); void recv_notice (connection_ptr conn, const notice_message& msg, bool generated);
void retry_fetch (connection_ptr conn); void retry_fetch (connection_ptr conn);
}; };
...@@ -1572,9 +1576,16 @@ namespace eosio { ...@@ -1572,9 +1576,16 @@ namespace eosio {
block_id_type blk_id = msg.id(); block_id_type blk_id = msg.id();
uint32_t num = msg.block_num(); uint32_t num = msg.block_num();
for (auto ref = req_blks.begin(); ref != req_blks.end(); ++ref) { for (auto ref = req_blks.begin(); ref != req_blks.end(); ++ref) {
if (*ref == blk_id) { if (ref->id != blk_id)
req_blks.erase(ref); continue;
fc_dlog(logger, "received a requested block"); bool is_retry = ref->local_retry;
req_blks.erase(ref);
fc_dlog(logger, "received a requested block");
if (is_retry) {
bcast_block(msg);
}
else {
notice_message note; notice_message note;
note.known_blocks.mode = normal; note.known_blocks.mode = normal;
note.known_blocks.ids.push_back( blk_id ); note.known_blocks.ids.push_back( blk_id );
...@@ -1641,8 +1652,10 @@ namespace eosio { ...@@ -1641,8 +1652,10 @@ namespace eosio {
c->cancel_wait(); c->cancel_wait();
} }
void big_msg_manager::recv_notice (connection_ptr c, const notice_message& msg) { void big_msg_manager::recv_notice (connection_ptr c, const notice_message& msg, bool generated) {
request_message req; request_message req;
req.req_trx.mode = none;
req.req_blocks.mode = none;
bool send_req = false; bool send_req = false;
chain_controller &cc = my_impl->chain_plug->chain(); chain_controller &cc = my_impl->chain_plug->chain();
if (msg.known_trx.mode == normal) { if (msg.known_trx.mode == normal) {
...@@ -1686,7 +1699,7 @@ namespace eosio { ...@@ -1686,7 +1699,7 @@ namespace eosio {
if (!b) { if (!b) {
send_req = true; send_req = true;
req.req_blocks.ids.push_back( blkid ); req.req_blocks.ids.push_back( blkid );
req_blks.push_back( blkid ); req_blks.push_back( {blkid, generated} );
} }
} }
} }
...@@ -2085,6 +2098,9 @@ namespace eosio { ...@@ -2085,6 +2098,9 @@ namespace eosio {
fc_dlog(logger, "got a notice_message from ${p}", ("p",c->peer_name())); fc_dlog(logger, "got a notice_message from ${p}", ("p",c->peer_name()));
request_message req; request_message req;
bool send_req = false; bool send_req = false;
if (msg.known_trx.mode != none) {
fc_dlog(logger,"this is a ${m} notice with ${n} blocks", ("m",modes_str(msg.known_trx.mode))("n",msg.known_trx.pending));
}
switch (msg.known_trx.mode) { switch (msg.known_trx.mode) {
case none: case none:
break; break;
...@@ -2108,12 +2124,13 @@ namespace eosio { ...@@ -2108,12 +2124,13 @@ namespace eosio {
break; break;
} }
case normal: { case normal: {
big_msg_master->recv_notice (c, msg); big_msg_master->recv_notice (c, msg, false);
} }
} }
fc_dlog(logger,"this is a ${m} notice with ${n} blocks", ("m",modes_str(msg.known_blocks.mode))("n",msg.known_blocks.pending)); if (msg.known_blocks.mode != none) {
fc_dlog(logger,"this is a ${m} notice with ${n} blocks", ("m",modes_str(msg.known_blocks.mode))("n",msg.known_blocks.pending));
}
switch (msg.known_blocks.mode) { switch (msg.known_blocks.mode) {
case none : { case none : {
if (msg.known_trx.mode != normal) { if (msg.known_trx.mode != normal) {
...@@ -2127,7 +2144,7 @@ namespace eosio { ...@@ -2127,7 +2144,7 @@ namespace eosio {
break; break;
} }
case normal : { case normal : {
big_msg_master->recv_notice (c, msg); big_msg_master->recv_notice (c, msg, false);
break; break;
} }
default: { default: {
...@@ -2187,6 +2204,10 @@ namespace eosio { ...@@ -2187,6 +2204,10 @@ namespace eosio {
return; return;
} }
c->cancel_wait(); c->cancel_wait();
if(local_txns.get<by_id>().find(msg.id()) != local_txns.end()) {
fc_dlog(logger, "got a duplicate transaction - dropping");
return;
}
big_msg_master->recv_transaction(c); big_msg_master->recv_transaction(c);
uint64_t code = 0; uint64_t code = 0;
try { try {
...@@ -2239,7 +2260,18 @@ namespace eosio { ...@@ -2239,7 +2260,18 @@ namespace eosio {
for (const auto &recpt : shard.transactions) { for (const auto &recpt : shard.transactions) {
auto ltx = local_txns.get<by_id>().find(recpt.id); auto ltx = local_txns.get<by_id>().find(recpt.id);
switch (recpt.status) { switch (recpt.status) {
case transaction_receipt::delayed: case transaction_receipt::delayed: {
if (ltx == local_txns.end()) {
fc_dlog(logger, "got a delayed transaction, treat it like a notify");
notice_message pending_notify;
pending_notify.known_blocks.mode = normal;
pending_notify.known_blocks.ids.push_back( blk_id );
pending_notify.known_trx.mode = none;
big_msg_master->recv_notice (c, pending_notify, true);
return;
}
// else fall through to executed.
}
case transaction_receipt::executed: { case transaction_receipt::executed: {
if( ltx != local_txns.end()) { if( ltx != local_txns.end()) {
sb.input_transactions.push_back(ltx->packed_txn); sb.input_transactions.push_back(ltx->packed_txn);
...@@ -2265,26 +2297,27 @@ namespace eosio { ...@@ -2265,26 +2297,27 @@ namespace eosio {
} }
} }
go_away_reason reason = fatal_other;
try { try {
chain_plug->accept_block(sb, sync_master->is_active(c)); chain_plug->accept_block(sb, sync_master->is_active(c));
reason = no_reason; big_msg_master->recv_block(c, msg);
sync_master->recv_block(c, blk_id, blk_num, true);
return;
} catch( const unlinkable_block_exception &ex) { } catch( const unlinkable_block_exception &ex) {
elog( "unlinkable_block_exception accept block #${n} syncing from ${p}",("n",blk_num)("p",c->peer_name())); elog( "unlinkable_block_exception accept block #${n} syncing from ${p}",("n",blk_num)("p",c->peer_name()));
reason = unlinkable;
} catch( const block_validate_exception &ex) { } catch( const block_validate_exception &ex) {
elog( "block_validate_exception accept block #${n} syncing from ${p}",("n",blk_num)("p",c->peer_name())); elog( "block_validate_exception accept block #${n} syncing from ${p}",("n",blk_num)("p",c->peer_name()));
reason = validation;
} catch( const assert_exception &ex) { } catch( const assert_exception &ex) {
elog( "unable to accept block on assert exception ${n} from ${p}",("n",ex.to_string())("p",c->peer_name())); elog( "unable to accept block on assert exception ${n} from ${p}",("n",ex.to_string())("p",c->peer_name()));
} catch( const fc::exception &ex) { } catch( const fc::exception &ex) {
elog( "accept_block threw a non-assert exception ${x} from ${p}",( "x",ex.to_string())("p",c->peer_name())); elog( "accept_block threw a non-assert exception ${x} from ${p}",( "x",ex.to_string())("p",c->peer_name()));
reason = no_reason;
} catch( ...) { } catch( ...) {
elog( "handle sync block caught something else from ${p}",("num",blk_num)("p",c->peer_name())); elog( "handle sync block caught something else from ${p}",("num",blk_num)("p",c->peer_name()));
} }
big_msg_master->recv_block(c, msg); notice_message pending_notify;
sync_master->recv_block(c, blk_id, blk_num, reason == no_reason); pending_notify.known_blocks.mode = normal;
pending_notify.known_blocks.ids.push_back( blk_id );
pending_notify.known_trx.mode = none;
big_msg_master->recv_notice (c, pending_notify, true);
} }
void net_plugin_impl::handle_message( connection_ptr c, const signed_block &msg) { void net_plugin_impl::handle_message( connection_ptr c, const signed_block &msg) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册