]> git.bitcoin.ninja Git - ldk-c-bindings/commitdiff
Update C++ demo and ldk_net to new clone API
authorMatt Corallo <git@bluematt.me>
Sat, 7 Aug 2021 21:08:09 +0000 (21:08 +0000)
committerMatt Corallo <git@bluematt.me>
Sat, 7 Aug 2021 21:08:09 +0000 (21:08 +0000)
ldk-net/ldk_net.c
lightning-c-bindings/demo.cpp

index 18279541e0a88014f8b7621b6855e754be598f1b..dc19e8ee6794a900b1a2a3939940cd333c6d8a85 100644 (file)
@@ -142,12 +142,12 @@ static uint64_t sock_hash(const void* desc) {
        const struct Descriptor *descriptor = (const struct Descriptor*)desc;
        return (uint64_t)descriptor->fd;
 }
-static void* sock_clone(const void* desc) {
-       const struct Descriptor *descriptor = (const struct Descriptor*)desc;
+static void sock_cloned(LDKSocketDescriptor *NONNULL_PTR ldk_desc) {
+       const struct Descriptor *descriptor = (const struct Descriptor*)ldk_desc->this_arg;
        struct Descriptor *new_desc = malloc(sizeof(struct Descriptor));
        new_desc->handler = descriptor->handler;
        new_desc->fd = descriptor->fd;
-       return new_desc;
+       ldk_desc->this_arg = (void*) new_desc;
 }
 static void sock_free(void* desc) {
        free(desc);
@@ -163,7 +163,7 @@ static inline LDKSocketDescriptor get_descriptor(struct SocketHandler *handler,
                .disconnect_socket = sock_disconnect,
                .eq = sock_eq,
                .hash = sock_hash,
-               .clone = sock_clone,
+               .cloned = sock_cloned,
                .free = sock_free,
        };
        return ret;
index b2a8f925706d2473a5f4fed173b8d3d4a8cd60c5..7c6dfda2e0f1c93ffbe83ba0a7dfbc9c0943ff53 100644 (file)
@@ -308,7 +308,7 @@ public:
                        .disconnect_socket = sock_disconnect_socket,
                        .eq = sock_eq,
                        .hash = sock_hash,
-                       .clone = NULL,
+                       .cloned = NULL,
                        .free = NULL,
                };
 
@@ -318,7 +318,7 @@ public:
                        .disconnect_socket = sock_disconnect_socket,
                        .eq = sock_eq,
                        .hash = sock_hash,
-                       .clone = NULL,
+                       .cloned = NULL,
                        .free = NULL,
                };