Browse Source

json-rpc: Give `waitblockheight` an error code for timeouts

We need to differentiate timeouts from other results, so make it recognizable.
ppa
Christian Decker 4 years ago
parent
commit
0d1b45dfcc
  1. 3
      common/jsonrpc_errors.h
  2. 4
      doc/lightning-waitblockheight.7
  3. 2
      doc/lightning-waitblockheight.7.md
  4. 2
      lightningd/peer_control.c

3
common/jsonrpc_errors.h

@ -84,4 +84,7 @@ static const errcode_t OFFER_EXPIRED = 1002;
static const errcode_t OFFER_ROUTE_NOT_FOUND = 1003; static const errcode_t OFFER_ROUTE_NOT_FOUND = 1003;
static const errcode_t OFFER_BAD_INVREQ_REPLY = 1004; static const errcode_t OFFER_BAD_INVREQ_REPLY = 1004;
/* Errors from wait* commands */
static const errcode_t WAIT_TIMEOUT = 2000;
#endif /* LIGHTNING_COMMON_JSONRPC_ERRORS_H */ #endif /* LIGHTNING_COMMON_JSONRPC_ERRORS_H */

4
doc/lightning-waitblockheight.7

@ -23,7 +23,7 @@ the block height at the time the command returns\.
If \fItimeout\fR seconds is reached without the specified blockheight If \fItimeout\fR seconds is reached without the specified blockheight
being reached, this command will fail\. being reached, this command will fail with a code of \fB2000\fR\.
.SH AUTHOR .SH AUTHOR
@ -33,4 +33,4 @@ ZmnSCPxj \fI<ZmnSCPxj@protonmail.com\fR> is mainly responsible\.
Main web site: \fIhttps://github.com/ElementsProject/lightning\fR Main web site: \fIhttps://github.com/ElementsProject/lightning\fR
\" SHA256STAMP:5714e6333e5ba57cc00de425e6dc411f2c30812bbc8d95d01d50c460ee002e29 \" SHA256STAMP:ac3320b4b9e679d8c407e42c9663540e2fc2aca75143d192f58ce255ca9b3700

2
doc/lightning-waitblockheight.7.md

@ -24,7 +24,7 @@ an object with the single field *blockheight* is returned, which is
the block height at the time the command returns. the block height at the time the command returns.
If *timeout* seconds is reached without the specified blockheight If *timeout* seconds is reached without the specified blockheight
being reached, this command will fail. being reached, this command will fail with a code of `2000`.
AUTHOR AUTHOR
------ ------

2
lightningd/peer_control.c

@ -1850,7 +1850,7 @@ timeout_waitblockheight_waiter(struct waitblockheight_waiter *w)
list_del(&w->list); list_del(&w->list);
w->removed = true; w->removed = true;
tal_steal(tmpctx, w); tal_steal(tmpctx, w);
was_pending(command_fail(w->cmd, LIGHTNINGD, was_pending(command_fail(w->cmd, WAIT_TIMEOUT,
"Timed out.")); "Timed out."));
} }
/* Called by lightningd at each new block. */ /* Called by lightningd at each new block. */

Loading…
Cancel
Save