Skip to content

Commit

Permalink
RPC block_create fixes (#2380)
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptocode authored and Russel Waters committed Nov 8, 2019
1 parent 3d83400 commit c00e72a
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions nano/node/json_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,10 @@ void nano::json_handler::block_create ()
{
rpc_l->ec = nano::error_common::generic;
}
rpc_l->response_errors ();
if (rpc_l->ec)
{
rpc_l->response_errors ();
}
};
};
if (prv.data != 0)
Expand Down Expand Up @@ -1442,6 +1445,7 @@ void nano::json_handler::block_create ()
nano::block_builder builder_l;
std::shared_ptr<nano::block> block_l{ nullptr };
nano::root root_l;
std::error_code ec_build;
if (type == "state")
{
if (previous_text.is_initialized () && !representative.is_zero () && (!link.is_zero () || link_text.is_initialized ()))
Expand All @@ -1453,7 +1457,7 @@ void nano::json_handler::block_create ()
.balance (balance)
.link (link)
.sign (prv, pub)
.build ();
.build (ec_build);
if (previous.is_zero ())
{
root_l = pub;
Expand All @@ -1477,7 +1481,7 @@ void nano::json_handler::block_create ()
.source (source)
.representative (representative)
.sign (prv, pub)
.build ();
.build (ec_build);
root_l = pub;
}
else
Expand All @@ -1493,7 +1497,7 @@ void nano::json_handler::block_create ()
.previous (previous)
.source (source)
.sign (prv, pub)
.build ();
.build (ec_build);
root_l = previous;
}
else
Expand All @@ -1509,7 +1513,7 @@ void nano::json_handler::block_create ()
.previous (previous)
.representative (representative)
.sign (prv, pub)
.build ();
.build (ec_build);
root_l = previous;
}
else
Expand All @@ -1528,7 +1532,7 @@ void nano::json_handler::block_create ()
.destination (destination)
.balance (balance.number () - amount.number ())
.sign (prv, pub)
.build ();
.build (ec_build);
root_l = previous;
}
else
Expand All @@ -1545,7 +1549,7 @@ void nano::json_handler::block_create ()
{
ec = nano::error_blocks::invalid_type;
}
if (!ec)
if (!ec && (!ec_build || ec_build == nano::error_common::missing_work))
{
if (work == 0)
{
Expand Down

0 comments on commit c00e72a

Please sign in to comment.