Skip to content

Commit 7d0e16f

Browse files
committed
Add daemon protocol version to {worker,serve}_protocol::*Conn
This will allow us to factor out more serializers
1 parent d2ca68e commit 7d0e16f

File tree

6 files changed

+25
-9
lines changed

6 files changed

+25
-9
lines changed

src/libstore/daemon.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,14 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
276276
TrustedFlag trusted, RecursiveFlag recursive, unsigned int clientVersion,
277277
Source & from, BufferedSink & to, unsigned int op)
278278
{
279-
worker_proto::ReadConn rconn { { .from = from } };
280-
worker_proto::WriteConn wconn { { .to = to } };
279+
worker_proto::ReadConn rconn {
280+
{ .from = from },
281+
/* .version = */ clientVersion,
282+
};
283+
worker_proto::WriteConn wconn {
284+
{ .to = to },
285+
/* .version = */ clientVersion,
286+
};
281287

282288
switch (op) {
283289

src/libstore/path-info.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ ValidPathInfo ValidPathInfo::read(Source & source, const Store & store, unsigned
9191
ValidPathInfo info(path, narHash);
9292
if (deriver != "") info.deriver = store.parseStorePath(deriver);
9393
info.references = worker_proto::read(store,
94-
worker_proto::ReadConn { { .from = source } },
94+
worker_proto::ReadConn {
95+
{ .from = source },
96+
/* .version = */ format,
97+
},
9598
Phantom<StorePathSet> {});
9699
source >> info.registrationTime >> info.narSize;
97100
if (format >= 16) {
@@ -114,7 +117,10 @@ void ValidPathInfo::write(
114117
sink << (deriver ? store.printStorePath(*deriver) : "")
115118
<< narHash.to_string(Base16, false);
116119
worker_proto::write(store,
117-
worker_proto::WriteConn { { .to = sink } },
120+
worker_proto::WriteConn {
121+
{ .to = sink },
122+
/* .version = */ format,
123+
},
118124
references);
119125
sink << registrationTime << narSize;
120126
if (format >= 16) {

src/libstore/remote-store-connection.hh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ struct RemoteStore::Connection
1616
return worker_proto::ReadConn {
1717
{
1818
.from = from,
19-
}
19+
},
20+
/* .version = */ daemonVersion,
2021
};
2122
}
2223

@@ -25,7 +26,8 @@ struct RemoteStore::Connection
2526
return worker_proto::WriteConn {
2627
{
2728
.to = to,
28-
}
29+
},
30+
/* .version = */ daemonVersion,
2931
};
3032
}
3133

src/libstore/remote-store.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,9 +510,7 @@ void RemoteStore::addToStore(const ValidPathInfo & info, Source & source,
510510
sink
511511
<< exportMagic
512512
<< printStorePath(info.path);
513-
worker_proto::write(*this,
514-
worker_proto::WriteConn { { .to = sink } },
515-
info.references);
513+
worker_proto::write(*this, *conn, info.references);
516514
sink
517515
<< (info.deriver ? printStorePath(*info.deriver) : "")
518516
<< 0 // == no legacy signature

src/libstore/serve-protocol.hh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ using common_proto::write;
3737
/* FIXME maybe move more stuff inside here */
3838

3939
struct ReadConn : common_proto::ReadConn {
40+
unsigned int version;
4041
};
4142

4243
struct WriteConn : common_proto::WriteConn {
44+
unsigned int version;
4345
};
4446

4547
MAKE_PROTO(template<typename T>, std::vector<T>);

src/libstore/worker-protocol.hh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@ using common_proto::write;
8585
/* FIXME maybe move more stuff inside here */
8686

8787
struct ReadConn : common_proto::ReadConn {
88+
unsigned int version;
8889
};
8990

9091
struct WriteConn : common_proto::WriteConn {
92+
unsigned int version;
9193
};
9294

9395
MAKE_PROTO(, BuildResult);

0 commit comments

Comments
 (0)