Fix duplicate send ID insufficient balance again (#1106)
The non-test part ofedcdb15
was reverted in2a6030c
, which broke the test
This commit is contained in:
parent
98e1c9993b
commit
e2fa840fdb
2 changed files with 23 additions and 21 deletions
|
@ -375,7 +375,8 @@ TEST (rpc, send_idempotent)
|
|||
system.poll ();
|
||||
}
|
||||
ASSERT_EQ (200, response2.status);
|
||||
ASSERT_EQ (response2.json.get<std::string> ("block"), block_text);
|
||||
ASSERT_EQ ("", response2.json.get<std::string> ("error", ""));
|
||||
ASSERT_EQ (block_text, response2.json.get<std::string> ("block"));
|
||||
ASSERT_EQ (system.nodes[0]->balance (rai::test_genesis_key.pub), rai::genesis_amount / 4);
|
||||
request.erase ("id");
|
||||
request.put ("id", "456def");
|
||||
|
|
|
@ -2611,29 +2611,30 @@ void rai::rpc_handler::send ()
|
|||
if (!ec)
|
||||
{
|
||||
boost::optional<std::string> send_id (request.get_optional<std::string> ("id"));
|
||||
if (balance >= amount.number ())
|
||||
{
|
||||
auto rpc_l (shared_from_this ());
|
||||
auto response_a (response);
|
||||
wallet->send_async (source, destination, amount.number (), [response_a](std::shared_ptr<rai::block> block_a) {
|
||||
if (block_a != nullptr)
|
||||
{
|
||||
rai::uint256_union hash (block_a->hash ());
|
||||
boost::property_tree::ptree response_l;
|
||||
response_l.put ("block", hash.to_string ());
|
||||
response_a (response_l);
|
||||
}
|
||||
else
|
||||
auto rpc_l (shared_from_this ());
|
||||
auto response_a (response);
|
||||
wallet->send_async (source, destination, amount.number (), [balance, amount, response_a](std::shared_ptr<rai::block> block_a) {
|
||||
if (block_a != nullptr)
|
||||
{
|
||||
rai::uint256_union hash (block_a->hash ());
|
||||
boost::property_tree::ptree response_l;
|
||||
response_l.put ("block", hash.to_string ());
|
||||
response_a (response_l);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (balance >= amount.number ())
|
||||
{
|
||||
error_response (response_a, "Error generating block");
|
||||
}
|
||||
},
|
||||
work == 0, send_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
ec = nano::error_common::insufficient_balance;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::error_code ec (nano::error_common::insufficient_balance);
|
||||
error_response (response_a, ec.message ());
|
||||
}
|
||||
}
|
||||
},
|
||||
work == 0, send_id);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue