From: Matt Corallo <649246+TheBlueMatt@users.noreply.github.com> Date: Sun, 26 Sep 2021 22:54:31 +0000 (+0000) Subject: Merge pull request #44 from TheBlueMatt/main X-Git-Tag: v0.0.101.2^0 X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-c-bindings;a=commitdiff_plain;h=551090b10d5f1cc44dbd7fb635fbf33ffb5491da;hp=a830d124bb452a49e1f58809b6aeb229027fed31 Merge pull request #44 from TheBlueMatt/main --- diff --git a/c-bindings-gen/src/main.rs b/c-bindings-gen/src/main.rs index f56f30f..9d6f9cf 100644 --- a/c-bindings-gen/src/main.rs +++ b/c-bindings-gen/src/main.rs @@ -1853,7 +1853,8 @@ fn walk_ast<'a>(ast_storage: &'a FullLibraryAST, crate_types: &mut CrateTypes<'a syn::Item::Impl(i) => { if let &syn::Type::Path(ref p) = &*i.self_ty { if let Some(trait_path) = i.trait_.as_ref() { - if path_matches_nongeneric(&trait_path.1, &["core", "clone", "Clone"]) { + if path_matches_nongeneric(&trait_path.1, &["core", "clone", "Clone"]) || + path_matches_nongeneric(&trait_path.1, &["Clone"]) { if let Some(full_path) = import_resolver.maybe_resolve_path(&p.path, None) { crate_types.set_clonable("crate::".to_owned() + &full_path); } diff --git a/genbindings.sh b/genbindings.sh index e6ffd8b..f74b2ac 100755 --- a/genbindings.sh +++ b/genbindings.sh @@ -230,9 +230,12 @@ while read LINE; do # We'll print this at the end ;; "XXX"*) - STRUCT_NAME="$(echo "$LINE" | awk '{ print $2 }')" + NEW_STRUCT_NAME="$(echo "$LINE" | awk '{ print $2 }')" + if [ "$NEW_STRUCT_NAME" != "$STRUCT_NAME" ]; then + STRUCT_CONTENTS="$(cat include/lightning.h | sed -n -e "/struct LDK$NEW_STRUCT_NAME/{:s" -e "/\} LDK$NEW_STRUCT_NAME;/!{N" -e "b s" -e "}" -e p -e "}")" + fi + STRUCT_NAME="$NEW_STRUCT_NAME" METHOD_NAME="$(echo "$LINE" | awk '{ print $3 }')" - STRUCT_CONTENTS="$(cat include/lightning.h | sed -n -e "/struct LDK$STRUCT_NAME/{:s" -e "/\} LDK$STRUCT_NAME;/!{N" -e "b s" -e "}" -e p -e "}")" METHOD="$(echo "$STRUCT_CONTENTS" | grep "(\*$METHOD_NAME)")" if [ "$METHOD" = "" ]; then echo "Unable to find method declaration for $LINE" diff --git a/lightning-c-bindings/demo.cpp b/lightning-c-bindings/demo.cpp index e7b596b..a11c4bf 100644 --- a/lightning-c-bindings/demo.cpp +++ b/lightning-c-bindings/demo.cpp @@ -242,6 +242,9 @@ public: if (peers_1->datalen == 0 && peers_2->datalen == 0) { break; } std::this_thread::yield(); } + // Note that the above is somewhat race-y, as node 2 may still think its connected. + // Thus, make sure any connections are disconnected on its end as well. + PeerManager_disconnect_by_node_id(&net2, ChannelManager_get_our_node_id(&cm1), false); // Finally make an actual connection and keep it this time assert(!socket_connect(node1_handler, ChannelManager_get_our_node_id(&cm2), (sockaddr*)&listen_addr, sizeof(listen_addr)));