X-Git-Url: https://git.novaco.in/?p=electrum-server.git;a=blobdiff_plain;f=backends%2Flibbitcoin%2Fmemory_buffer.hpp;h=13ad7e6a9d30fbc17ace3f4fd4babb39e0b8189a;hp=9d7621c9880978417a69f5b87ac5ab831129b497;hb=c66a7f1feef268d9f94280894360ea02ffecc0e9;hpb=fc7ce0e8093a5f37de7082702fe959931ac44c04 diff --git a/backends/libbitcoin/memory_buffer.hpp b/backends/libbitcoin/memory_buffer.hpp index 9d7621c..13ad7e6 100644 --- a/backends/libbitcoin/memory_buffer.hpp +++ b/backends/libbitcoin/memory_buffer.hpp @@ -53,16 +53,13 @@ public: size_t index; bool is_input; uint64_t timestamp; - // Convenient storage - message::output_point previous_output; }; typedef std::vector check_result; - typedef std::shared_ptr check_result_ptr; typedef std::function< void (const std::error_code&)> receive_handler; typedef std::function< - void (const std::error_code&, check_result_ptr)> check_handler; + void (const std::error_code&, const check_result&)> check_handler; memory_buffer(async_service_ptr service, blockchain_ptr chain, transaction_pool_ptr txpool) @@ -93,8 +90,38 @@ public: } void check(const message::output_point_list& output_points, - const std::string& address, check_handler handle_check) + const payment_address& address, check_handler handle_check) { + auto this_ptr = shared_from_this(); + strand_.post( + [&, this_ptr, output_points, address, handle_check]() + { + check_result result; + for (auto& outpoint: output_points) + { + auto it = lookup_input_.find(outpoint); + if (it != lookup_input_.end()) + { + check_item item; + item.tx_hash = it->second.hash; + item.index = it->second.index; + item.is_input = true; + item.timestamp = timestamps_[item.tx_hash]; + result.push_back(item); + } + } + auto range = lookup_address_.equal_range(address); + for (auto it = range.first; it != range.second; ++it) + { + check_item item; + item.tx_hash = it->second.hash; + item.index = it->second.index; + item.is_input = false; + item.timestamp = timestamps_[item.tx_hash]; + result.push_back(item); + } + handle_check(std::error_code(), result); + }); } private: