Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
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
97f4f4fb
Commit
97f4f4fb
authored
7 years ago
by
Infernoman
Browse files
Options
Download
Email Patches
Plain Diff
Api Stubs
parent
7fe5e9d3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/Makefile.am
+1
-0
src/Makefile.am
src/rpcserver.cpp
+12
-8
src/rpcserver.cpp
src/rpcserver.h
+1
-0
src/rpcserver.h
src/rpcservice.cpp
+123
-0
src/rpcservice.cpp
with
137 additions
and
8 deletions
+137
-8
src/Makefile.am
View file @
97f4f4fb
...
...
@@ -194,6 +194,7 @@ libbitcoin_server_a_SOURCES = \
pow.cpp
\
rest.cpp
\
rpcblockchain.cpp
\
rpcservice.cpp
\
rpcthrone.cpp
\
rpcthrone-budget.cpp
\
rpcmining.cpp
\
...
...
This diff is collapsed.
Click to expand it.
src/rpcserver.cpp
View file @
97f4f4fb
...
...
@@ -310,14 +310,18 @@ static const CRPCCommand vRPCCommands[] =
{
"hidden"
,
"setmocktime"
,
&
setmocktime
,
true
,
false
,
false
},
{
"hidden"
,
"sendalert"
,
&
sendalert
,
false
,
false
,
false
},
/* Crown features */
{
"crown"
,
"throne"
,
&
throne
,
true
,
true
,
false
},
{
"crown"
,
"thronelist"
,
&
thronelist
,
true
,
true
,
false
},
{
"crown"
,
"thronebroadcast"
,
&
thronebroadcast
,
true
,
true
,
false
},
{
"crown"
,
"mnbudget"
,
&
mnbudget
,
true
,
true
,
false
},
{
"crown"
,
"mnbudgetvoteraw"
,
&
mnbudgetvoteraw
,
true
,
true
,
false
},
{
"crown"
,
"mnfinalbudget"
,
&
mnfinalbudget
,
true
,
true
,
false
},
{
"crown"
,
"mnsync"
,
&
mnsync
,
true
,
true
,
false
},
{
"crown"
,
"spork"
,
&
spork
,
true
,
true
,
false
},
{
"crown"
,
"throne"
,
&
throne
,
true
,
true
,
false
},
{
"crown"
,
"thronelist"
,
&
thronelist
,
true
,
true
,
false
},
{
"crown"
,
"thronebroadcast"
,
&
thronebroadcast
,
true
,
true
,
false
},
{
"crown"
,
"mnbudget"
,
&
mnbudget
,
true
,
true
,
false
},
{
"crown"
,
"mnbudgetvoteraw"
,
&
mnbudgetvoteraw
,
true
,
true
,
false
},
{
"crown"
,
"mnfinalbudget"
,
&
mnfinalbudget
,
true
,
true
,
false
},
{
"crown"
,
"mnsync"
,
&
mnsync
,
true
,
true
,
false
},
{
"crown"
,
"spork"
,
&
spork
,
true
,
true
,
false
},
/* API features */
{
"api"
,
"service"
,
&
service
,
true
,
true
,
false
},
#ifdef ENABLE_WALLET
/* Wallet */
...
...
This diff is collapsed.
Click to expand it.
src/rpcserver.h
View file @
97f4f4fb
...
...
@@ -237,6 +237,7 @@ extern json_spirit::Value mnbudget(const json_spirit::Array& params, bool fHelp)
extern
json_spirit
::
Value
mnbudgetvoteraw
(
const
json_spirit
::
Array
&
params
,
bool
fHelp
);
extern
json_spirit
::
Value
mnfinalbudget
(
const
json_spirit
::
Array
&
params
,
bool
fHelp
);
extern
json_spirit
::
Value
mnsync
(
const
json_spirit
::
Array
&
params
,
bool
fHelp
);
extern
json_spirit
::
Value
service
(
const
json_spirit
::
Array
&
params
,
bool
fHelp
);
// in rest.cpp
extern
bool
HTTPReq_REST
(
AcceptedConnection
*
conn
,
...
...
This diff is collapsed.
Click to expand it.
src/rpcservice.cpp
0 → 100644
View file @
97f4f4fb
#include "main.h"
#include "db.h"
#include "init.h"
#include "rpcserver.h"
#include <fstream>
using
namespace
json_spirit
;
using
namespace
std
;
Value
service
(
const
Array
&
params
,
bool
fHelp
)
{
string
strCommand
;
if
(
params
.
size
()
>=
1
)
strCommand
=
params
[
0
].
get_str
();
if
(
fHelp
||
(
strCommand
!=
"enroll"
&&
strCommand
!=
"unenroll"
&&
strCommand
!=
"genservicekey"
&&
strCommand
!=
"addservicekey"
&&
strCommand
!=
"removeservicekey"
&&
strCommand
!=
"status"
&&
strCommand
!=
"getcurrentclients"
&&
strCommand
!=
"setprice"
&&
strCommand
!=
"getprice"
&&
strCommand
!=
"sendclientdata"
&&
strCommand
!=
"discover"
))
throw
runtime_error
(
"service
\"
command
\"
... (
\"
passphrase
\"
)
\n
"
"Vote or show current budgets
\n
"
"
\n
Available commands:
\n
"
" enroll - Enroll to a service on the network
\n
"
" unenroll - Un-enroll from a service on the network
\n
"
" genservicekey - Generate a key to run a service on the network
\n
"
" addservicekey - Add an already existing service key
\n
"
" removeservicekey - Remove a service key
\n
"
" status - Show the status of a service
\n
"
" getcurrentclients - Show current clients subscribed to your service
\n
"
" setprice - Set the price for your service
\n
"
" getprice - Get the price for the service hash
\n
"
" sendclientdata - Manually send client data
\n
"
" discover - List of all services on the network
\n
"
);
if
(
strCommand
==
"enroll"
)
{
// Registers a service on the network, this is called when you launch a service module
if
(
params
.
size
()
!=
5
)
throw
runtime_error
(
"Correct usage is 'service enroll serviceKey sharemodel price timeInterval'"
);
return
Value
::
null
;
}
if
(
strCommand
==
"unenroll"
)
{
// used when stopping the service. Although the network will ping the service at least once per hour
// and if service does not respond, it will be unregistered by the network.
if
(
params
.
size
()
!=
2
)
throw
runtime_error
(
"Correct usage is 'service unenroll serviceKey'"
);
return
Value
::
null
;
}
if
(
strCommand
==
"genservicekey"
)
{
// Generate a key to run a service on the network
if
(
params
.
size
()
!=
1
)
throw
runtime_error
(
"Correct usage is 'service genservicekey'"
);
return
Value
::
null
;
}
if
(
strCommand
==
"addservicekey"
)
{
//
if
(
params
.
size
()
!=
2
)
throw
runtime_error
(
"Correct usage is 'service addservicekey serviceKey'"
);
return
Value
::
null
;
}
if
(
strCommand
==
"removeservicekey"
)
{
//
if
(
params
.
size
()
!=
2
)
throw
runtime_error
(
"Correct usage is 'service removeservicekey serviceKey'"
);
return
Value
::
null
;
}
if
(
strCommand
==
"status"
)
{
// This will return current status of a service – serviceKey is used for this
if
(
params
.
size
()
!=
2
)
throw
runtime_error
(
"Correct usage is 'service status serviceKey'"
);
return
Value
::
null
;
}
if
(
strCommand
==
"getcurrentclients"
)
{
// this will return a list of uniqely identifyable clients that have currently bought services
if
(
params
.
size
()
!=
2
)
throw
runtime_error
(
"Correct usage is 'service getcurrentclients serviceKey'"
);
return
Value
::
null
;
}
if
(
strCommand
==
"setprice"
)
{
// Set the service price - serviceKey is used for this
if
(
params
.
size
()
!=
2
)
throw
runtime_error
(
"Correct usage is 'service setprice serviceKey'"
);
return
Value
::
null
;
}
if
(
strCommand
==
"getprice"
)
{
// Get the service price - serviceKey is used for this
if
(
params
.
size
()
!=
2
)
throw
runtime_error
(
"Correct usage is 'service getprice serviceKey'"
);
return
Value
::
null
;
}
if
(
strCommand
==
"sendclientdata"
)
{
// Manually send client data
return
Value
::
null
;
}
if
(
strCommand
==
"discover"
)
{
// Generates a list of services currently running on the network
if
(
params
.
size
()
!=
1
)
throw
runtime_error
(
"Correct usage is 'service discover'"
);
return
Value
::
null
;
}
return
Value
::
null
;
}
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
Menu
Projects
Groups
Snippets
Help