private Snapshot write(SnapshotId id, String hostname, Function<Node, Snapshot> snapshotFunction, @SuppressWarnings("unused") Mutex snapshotLock) {
        List<Snapshot> snapshots = read(hostname);
        try (var nodeMutex = nodeRepository.nodes().lockAndGetRequired(hostname)) {
            Node node = requireNode(nodeMutex);
            Snapshot snapshot = snapshotFunction.apply(node);
            try (var transaction = new NestedTransaction()) {
                Node updatedNode = node.with(node.status().withSnapshot(Optional.of(snapshot)));
                db.writeTo(updatedNode.state(),
                           List.of(updatedNode),
                           Agent.system,
                           Optional.empty(),
                           transaction);
                List<Snapshot> updated = new ArrayList<>(snapshots);
                updated.removeIf(s -> s.id().equals(id));
                updated.add(snapshot);
                db.writeSnapshots(hostname, updated, transaction);
                transaction.commit();
            }
            return snapshot;
        }
    }
Returns the key pair to use when sealing the snapshot encryption key
node-repository/src/main/java/com/yahoo/vespa/hosted/provision/backup/Snapshots.java