From 7ff67ebf4aefb190c256166e1aa45b28639eb3f4 Mon Sep 17 00:00:00 2001 From: Jason Paryani Date: Thu, 4 Jun 2015 16:49:46 -0700 Subject: [PATCH] Add bootstrap method to TwoPartyServer --- capnp/helpers/helpers.pxd | 1 + capnp/helpers/rpcHelper.h | 7 +++++++ capnp/lib/capnp.pyx | 3 +++ 3 files changed, 11 insertions(+) diff --git a/capnp/helpers/helpers.pxd b/capnp/helpers/helpers.pxd index 15b7197..0d9884e 100644 --- a/capnp/helpers/helpers.pxd +++ b/capnp/helpers/helpers.pxd @@ -31,6 +31,7 @@ cdef extern from "capnp/helpers/rpcHelper.h": Capability.Client restoreHelper(RpcSystem&, AnyPointer.Reader&) Capability.Client restoreHelper(RpcSystem&, AnyPointer.Builder&) Capability.Client bootstrapHelper(RpcSystem&) + Capability.Client bootstrapHelperServer(RpcSystem&) RpcSystem makeRpcClientWithRestorer(TwoPartyVatNetwork&, PyRestorer&) PyPromise connectServerRestorer(TaskSet &, PyRestorer &, AsyncIoContext *, StringPtr) PyPromise connectServer(TaskSet &, Capability.Client, AsyncIoContext *, StringPtr) diff --git a/capnp/helpers/rpcHelper.h b/capnp/helpers/rpcHelper.h index cd25a92..54f3081 100644 --- a/capnp/helpers/rpcHelper.h +++ b/capnp/helpers/rpcHelper.h @@ -80,6 +80,13 @@ capnp::Capability::Client bootstrapHelper(capnp::RpcSystem& client) { + capnp::MallocMessageBuilder hostIdMessage(8); + auto hostId = hostIdMessage.initRoot(); + hostId.setSide(capnp::rpc::twoparty::Side::CLIENT); + return client.bootstrap(hostId); +} + template capnp::RpcSystem makeRpcClientWithRestorer( diff --git a/capnp/lib/capnp.pyx b/capnp/lib/capnp.pyx index 1f9ab02..ffac811 100644 --- a/capnp/lib/capnp.pyx +++ b/capnp/lib/capnp.pyx @@ -2352,6 +2352,9 @@ cdef class TwoPartyServer: wait_forever() + cpdef bootstrap(self) except +reraise_kj_exception: + return _CapabilityClient()._init(helpers.bootstrapHelperServer(deref(self.thisptr)), self) + property port: def __get__(self): if self._port is None: