Skip to content

Commit

Permalink
nixd/librpc: remove BCID
Browse files Browse the repository at this point in the history
  • Loading branch information
inclyc committed Mar 13, 2024
1 parent 65621fe commit df67d20
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions nixd/librpc/include/nixd/rpc/Protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ template <class T> void readBytecode(std::string_view &Data, Message<T> &Msg) {

struct RegisterBCParams {
std::string Shm;
std::string BasePath;
std::string CachePath;
std::size_t Size;
std::uintptr_t BCID;
};

void writeBytecode(std::ostream &OS, const RegisterBCParams &Params);
void readBytecode(std::string_view &Data, RegisterBCParams &Params);

struct ExprValueParams {
std::uintptr_t BCID;
std::uintptr_t ExprID;
};

Expand Down
8 changes: 4 additions & 4 deletions nixd/librpc/src/Protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@ using bc::writeBytecode;

void writeBytecode(std::ostream &OS, const RegisterBCParams &Params) {
writeBytecode(OS, Params.Shm);
writeBytecode(OS, Params.BasePath);
writeBytecode(OS, Params.CachePath);
writeBytecode(OS, Params.Size);
writeBytecode(OS, Params.BCID);
}

void readBytecode(std::string_view &Data, RegisterBCParams &Params) {
readBytecode(Data, Params.Shm);
readBytecode(Data, Params.BasePath);
readBytecode(Data, Params.CachePath);
readBytecode(Data, Params.Size);
readBytecode(Data, Params.BCID);
}

void writeBytecode(std::ostream &OS, const ExprValueParams &Params) {
writeBytecode(OS, Params.ExprID);
writeBytecode(OS, Params.BCID);
}

void readBytecode(std::string_view &Data, ExprValueParams &Params) {
readBytecode(Data, Params.ExprID);
readBytecode(Data, Params.BCID);
}

void writeBytecode(std::ostream &OS, const ExprValueResponse &Params) {
Expand Down
5 changes: 1 addition & 4 deletions nixd/librpc/test/Transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ TEST(RPC, MessageEval) {

using DataT = Message<ExprValueParams>;

sendPacket(Pipes[PIPE_WRITE],
DataT{RPCKind::ExprValue, ExprValueParams{1, 2}});
sendPacket(Pipes[PIPE_WRITE], DataT{RPCKind::ExprValue, ExprValueParams{2}});

auto Msg = recvPacket<DataT>(Pipes[PIPE_READ]);

ASSERT_EQ(Msg.Params.BCID, 1);
ASSERT_EQ(Msg.Params.ExprID, 2);
}

Expand Down

0 comments on commit df67d20

Please sign in to comment.