@@ -33,6 +33,7 @@ namespace node {
3333
3434using namespace bc ::blockchain;
3535using namespace bc ::chain;
36+ using namespace bc ::database;
3637using namespace bc ::message;
3738using namespace bc ::network;
3839using namespace std ::placeholders;
@@ -175,12 +176,16 @@ void protocol_transaction_out::send_next_data(inventory_ptr inventory)
175176
176177// TODO: send block_transaction message as applicable.
177178void protocol_transaction_out::send_transaction (const code& ec,
178- transaction_ptr transaction, size_t , size_t , inventory_ptr inventory)
179+ transaction_ptr transaction, size_t , size_t position,
180+ inventory_ptr inventory)
179181{
180182 if (stopped (ec))
181183 return ;
182184
183- if (ec == error::not_found)
185+ // Treat already confirmed transactions as not found.
186+ auto confirmed = !ec && position != transaction_database::unconfirmed;
187+
188+ if (ec == error::not_found || confirmed)
184189 {
185190 LOG_DEBUG (LOG_NODE)
186191 << " Transaction requested by [" << authority () << " ] not found." ;
@@ -189,6 +194,8 @@ void protocol_transaction_out::send_transaction(const code& ec,
189194 BITCOIN_ASSERT (!inventory->inventories ().empty ());
190195 const not_found reply{ inventory->inventories ().back () };
191196 SEND2 (reply, handle_send, _1, reply.command );
197+
198+ // TODO: recursion hazard.
192199 handle_send_next (error::success, inventory);
193200 return ;
194201 }
@@ -243,6 +250,10 @@ bool protocol_transaction_out::handle_notification(const code& ec,
243250 static const auto id = inventory::type_id::transaction;
244251 const inventory announce{ { id, message->hash () } };
245252 SEND2 (announce, handle_send, _1, announce.command );
253+
254+ // //LOG_DEBUG(LOG_NODE)
255+ // // << "Announced tx [" << encode_hash(message->hash()) << "] to ["
256+ // // << authority() << "].";
246257 return true ;
247258}
248259
0 commit comments