|
4 | 4 |
|
5 | 5 | To define a service: |
6 | 6 |
|
7 | | -- Make a struct or class. It may optionally publicly inherit from [psibase::Service] to gain the [psibase::Service::emit] and [psibase::Service::events] convenience methods. |
| 7 | +- Make a struct or class. It may optionally publicly inherit from [psibase::Service] to gain several convenience methods. |
8 | 8 | - Define or declare the set of methods |
9 | 9 | - Reflect the methods using `PSIO_REFLECT`. Only reflected methods become actions; these are available for transactions and for other services to call using [psibase::Actor] or [psibase::call]. |
10 | 10 |
|
11 | | -### Example without convenience base class: |
12 | | - |
13 | | -```c++ |
14 | | -struct MyService |
15 | | -{ |
16 | | - // The account this service is normally installed on. This definition |
17 | | - // is optional. |
18 | | - static constexpr auto service = psibase::AccountNumber("myservice"); |
19 | | - |
20 | | - void doSomething(std::string_view str); |
21 | | - std::string somethingElse(uint32_t x, psibase::AccountNumber y); |
22 | | -}; |
23 | | - |
24 | | -PSIO_REFLECT(MyService, |
25 | | - method(doSomething, str), |
26 | | - method(somethingElse, x, y)) |
27 | | -``` |
28 | | -
|
29 | 11 | ### Example with convenience base class: |
30 | 12 |
|
31 | 13 | ```c++ |
32 | | -struct MyService: psibase::Service<MyService> |
| 14 | +struct MyService: psibase::Service |
33 | 15 | { |
34 | 16 | // The account this service is normally installed on. This definition |
35 | 17 | // is optional. |
@@ -71,7 +53,7 @@ To define events for a service, declare the event functions as below, then refle |
71 | 53 | After you have defined your events, use [psibase::Service::emit] to emit them and [psibase::Service::events] to read them. |
72 | 54 |
|
73 | 55 | ```c++ |
74 | | -struct MyService: psibase::Service<MyService> { |
| 56 | +struct MyService: psibase::Service { |
75 | 57 | struct Events { |
76 | 58 | // Events which live a long time |
77 | 59 | struct History { |
|
0 commit comments