Allow supplying keypair when creating mutable dirs

This commit is contained in:
Christopher R. Wood 2024-05-03 16:55:38 -04:00
parent dd568ab6f4
commit 9c2362853d
2 changed files with 21 additions and 4 deletions

View File

@ -1125,8 +1125,18 @@ class _Client(node.Node, pollmixin.PollMixin):
# may get an opaque node if there were any problems.
return self.nodemaker.create_from_cap(write_uri, read_uri, deep_immutable=deep_immutable, name=name)
def create_dirnode(self, initial_children=None, version=None):
d = self.nodemaker.create_new_mutable_directory(initial_children, version=version)
def create_dirnode(
self,
initial_children=None,
version=None,
*,
unique_keypair: tuple[rsa.PublicKey, rsa.PrivateKey] | None = None
):
d = self.nodemaker.create_new_mutable_directory(
initial_children,
version=version,
keypair=unique_keypair,
)
return d
def create_immutable_dirnode(self, children, convergence=None):

View File

@ -135,7 +135,13 @@ class NodeMaker(object):
d.addCallback(lambda res: n)
return d
def create_new_mutable_directory(self, initial_children=None, version=None):
def create_new_mutable_directory(
self,
initial_children=None,
version=None,
*,
keypair: tuple[PublicKey, PrivateKey] | None = None,
):
if initial_children is None:
initial_children = {}
for (name, (node, metadata)) in initial_children.items():
@ -145,7 +151,8 @@ class NodeMaker(object):
d = self.create_mutable_file(lambda n:
MutableData(pack_children(initial_children,
n.get_writekey())),
version=version)
version=version,
keypair=keypair)
d.addCallback(self._create_dirnode)
return d