Skip to content

Commit bc4a5d8

Browse files
authored
Merge pull request #1985 from gofractally/cleanup-event-macros
Remove unused event boilerplate
2 parents 87fbea2 + 5d5fd32 commit bc4a5d8

12 files changed

Lines changed: 1 addition & 34 deletions

File tree

doc/src/development/services/cpp-service/reference/services-events.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ auto result =
6666

6767
## Defining events
6868

69-
To define events for a service, declare the event functions as below, then reflect them using the 3 macros below. Each of the `History` and `Merkle` structs must be present and reflected, even when they don't have any events declared within.
69+
To define events for a service, declare the event functions as below, then reflect them using the 2 macros below.
7070

7171
After you have defined your events, use [psibase::Service::emit] to emit them and [psibase::Service::events] to read them.
7272

@@ -91,8 +91,6 @@ struct MyService: psibase::Service<MyService> {
9191
};
9292
};
9393

94-
PSIBASE_REFLECT_EVENTS(MyService)
95-
9694
PSIBASE_REFLECT_HISTORY_EVENTS(
9795
MyService,
9896
method(myEvent, a, s),

libraries/psibase/common/include/psibase/Service.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,6 @@ namespace psibase
179179
}; // Service
180180
}; // namespace psibase
181181

182-
#define PSIBASE_REFLECT_EVENTS(SERVICE) \
183-
using SERVICE##_Events = SERVICE ::Events; \
184-
PSIO_REFLECT(SERVICE##_Events)
185-
186182
#define PSIBASE_REFLECT_HISTORY_EVENTS(SERVICE, ...) \
187183
using SERVICE##_EventsHistory = SERVICE ::Events::History; \
188184
PSIO_REFLECT(SERVICE##_EventsHistory, __VA_ARGS__)

packages/psibase_tests/include/services/test/EmitEvents.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ namespace TestService
5252
method(emitExample, r),
5353
method(serveSys, request))
5454

55-
PSIBASE_REFLECT_EVENTS(EmitEvents)
5655
PSIBASE_REFLECT_HISTORY_EVENTS(EmitEvents, //
5756
method(e, s, i),
5857
method(e2, r))

packages/system/StagedTx/service/cpp/include/services/system/StagedTx.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ namespace SystemService
118118
method(execute, id, txid),
119119
method(get_staged_tx, id),
120120
);
121-
PSIBASE_REFLECT_EVENTS(StagedTxService);
122121
PSIBASE_REFLECT_HISTORY_EVENTS(StagedTxService,
123122
method(updated, txid, actor, datetime, event_type),
124123
);

packages/system/Transact/include/services/system/Transact.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -498,9 +498,6 @@ namespace SystemService
498498
/// Emitted at the start of each block
499499
void blockStart(psibase::BlockNum blockNum, psibase::BlockTime blockTime) {}
500500
};
501-
struct Merkle
502-
{
503-
};
504501
};
505502
};
506503
PSIO_REFLECT(Transact,
@@ -531,10 +528,8 @@ namespace SystemService
531528
)
532529

533530
PSIBASE_REFLECT_TABLES(Transact, Transact::Tables)
534-
PSIBASE_REFLECT_EVENTS(Transact);
535531
PSIBASE_REFLECT_HISTORY_EVENTS(Transact, method(blockStart, blockNum, blockTime));
536532
PSIBASE_PUBLIC_EVENT(Transact::Events::History::blockStart)
537-
PSIBASE_REFLECT_MERKLE_EVENTS(Transact);
538533

539534
// The status will never be nullopt during transaction execution or during RPC.
540535
// It will be nullopt when called by a test wasm before the genesis transaction

packages/system/VirtualServer/service/cpp/include/services/system/VirtualServer.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,6 @@ namespace SystemService
450450
method(setBillableAcc, account),
451451
method(serveSys, request, socket, user))
452452

453-
PSIBASE_REFLECT_EVENTS(VirtualServer);
454453
PSIBASE_REFLECT_HISTORY_EVENTS(
455454
VirtualServer,
456455
allowHashedMethods(),

packages/user/Chainmail/include/services/user/Chainmail.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ namespace UserService
4444
void sent(psibase::AccountNumber sender, psibase::AccountNumber receiver, std::string subject, std::string body, psibase::TimePointSec datetime) {}
4545
void archive(std::string msg_id) {}
4646
};
47-
struct Merkle{};
4847
};
4948
// clang-format on
5049
};
@@ -58,12 +57,10 @@ namespace UserService
5857
method(unsave, msg_id, sender, subject, body, datetime),
5958
method(serveSys, request)
6059
);
61-
PSIBASE_REFLECT_EVENTS(Chainmail);
6260
PSIBASE_REFLECT_HISTORY_EVENTS(Chainmail,
6361
method(sent, sender, receiver, subject, body, datetime),
6462
method(archive, msg_id),
6563
);
66-
PSIBASE_REFLECT_MERKLE_EVENTS(Chainmail);
6764
// clang-format on
6865

6966
} // namespace UserService

packages/user/Events/test/TestService.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ struct TestService : psibase::Service
2323
void account(psibase::AccountNumber a);
2424
void time(psibase::TimePointSec t);
2525
};
26-
struct Merkle
27-
{
28-
};
2926
};
3027
};
3128
PSIO_REFLECT(TestService,
@@ -36,14 +33,12 @@ PSIO_REFLECT(TestService,
3633
method(sendAccount, a),
3734
method(sendTime, t))
3835

39-
PSIBASE_REFLECT_EVENTS(TestService);
4036
PSIBASE_REFLECT_HISTORY_EVENTS(TestService,
4137
method(testEvent, i, d, v, s),
4238
method(opt, opt),
4339
method(optb, opt),
4440
method(str, s),
4541
method(account, a),
4642
method(time, t));
47-
PSIBASE_REFLECT_MERKLE_EVENTS(TestService);
4843

4944
PSIBASE_REFLECT_TABLES(TestService)

packages/user/Invite/include/services/user/Invite.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ namespace UserService
102102
{
103103
void updated(uint32_t inviteId, psibase::AccountNumber actor, std::string_view event);
104104
};
105-
struct Merkle {};
106105
};
107106
// clang-format on
108107
};
@@ -118,11 +117,9 @@ namespace UserService
118117
method(getInvite, inviteId),
119118
method(getExpDate, inviteId),
120119
);
121-
PSIBASE_REFLECT_EVENTS(Invite);
122120
PSIBASE_REFLECT_HISTORY_EVENTS(Invite,
123121
method(updated, inviteId, actor, event),
124122
);
125-
PSIBASE_REFLECT_MERKLE_EVENTS(Invite);
126123
PSIBASE_REFLECT_TABLES(Invite, Invite::Tables)
127124
// clang-format on
128125
} // namespace InviteNs

packages/user/Nft/include/services/user/Nft.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ namespace UserService
7474
method(exists, nftId),
7575
method(getUserConf, account, flag)
7676
);
77-
PSIBASE_REFLECT_EVENTS(Nft);
7877
PSIBASE_REFLECT_HISTORY_EVENTS(Nft,
7978
method(minted, nftId, issuer),
8079
method(burned, nftId, owner),

0 commit comments

Comments
 (0)