Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Erik Jansen
crown-core-test-new-gitlab-runner
Commits
0f14d15a
Commit
0f14d15a
authored
10 years ago
by
Jonas Schnelli
Browse files
Options
Download
Email Patches
Plain Diff
[REST] give an appropriate response in warmup phase
parent
e14f40a1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/rest.cpp
+4
-0
src/rest.cpp
src/rpcprotocol.h
+1
-0
src/rpcprotocol.h
src/rpcserver.cpp
+8
-0
src/rpcserver.cpp
src/rpcserver.h
+3
-0
src/rpcserver.h
with
16 additions
and
0 deletions
+16
-0
src/rest.cpp
View file @
0f14d15a
...
...
@@ -188,6 +188,10 @@ bool HTTPReq_REST(AcceptedConnection *conn,
bool
fRun
)
{
try
{
std
::
string
statusmessage
;
if
(
RPCIsInWarmup
(
&
statusmessage
))
throw
RESTERR
(
HTTP_SERVICE_UNAVAILABLE
,
"Service temporarily unavailable: "
+
statusmessage
);
for
(
unsigned
int
i
=
0
;
i
<
ARRAYLEN
(
uri_prefixes
);
i
++
)
{
unsigned
int
plen
=
strlen
(
uri_prefixes
[
i
].
prefix
);
if
(
strURI
.
substr
(
0
,
plen
)
==
uri_prefixes
[
i
].
prefix
)
{
...
...
This diff is collapsed.
Click to expand it.
src/rpcprotocol.h
View file @
0f14d15a
...
...
@@ -28,6 +28,7 @@ enum HTTPStatusCode
HTTP_FORBIDDEN
=
403
,
HTTP_NOT_FOUND
=
404
,
HTTP_INTERNAL_SERVER_ERROR
=
500
,
HTTP_SERVICE_UNAVAILABLE
=
503
,
};
//! Bitcoin RPC error codes
...
...
This diff is collapsed.
Click to expand it.
src/rpcserver.cpp
View file @
0f14d15a
...
...
@@ -756,6 +756,14 @@ void SetRPCWarmupFinished()
fRPCInWarmup
=
false
;
}
bool
RPCIsInWarmup
(
std
::
string
*
outStatus
)
{
LOCK
(
cs_rpcWarmup
);
if
(
outStatus
)
*
outStatus
=
rpcWarmupStatus
;
return
fRPCInWarmup
;
}
void
RPCRunHandler
(
const
boost
::
system
::
error_code
&
err
,
boost
::
function
<
void
(
void
)
>
func
)
{
if
(
!
err
)
...
...
This diff is collapsed.
Click to expand it.
src/rpcserver.h
View file @
0f14d15a
...
...
@@ -53,6 +53,9 @@ void SetRPCWarmupStatus(const std::string& newStatus);
/* Mark warmup as done. RPC calls will be processed from now on. */
void
SetRPCWarmupFinished
();
/* returns the current warmup state. */
bool
RPCIsInWarmup
(
std
::
string
*
statusOut
);
/**
* Type-check arguments; throws JSONRPCError if wrong type given. Does not check that
* the right number of arguments are passed, just that any passed are the correct type.
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment