]> git.bitcoin.ninja Git - ldk-java/commitdiff
Use new is_ok functions for Result checks in hand-written code
authorMatt Corallo <git@bluematt.me>
Mon, 29 Nov 2021 01:05:05 +0000 (01:05 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 1 Dec 2021 14:14:14 +0000 (14:14 +0000)
src/main/java/org/ldk/batteries/NioPeerHandler.java
src/test/java/org/ldk/PeerTest.java

index afe728b059c482cc35983051ab3f72ed998b0e99..49f60c7f721b22f570dd5e5d9c300ca9c9503fbe 100644 (file)
@@ -217,7 +217,7 @@ public class NioPeerHandler {
                                     buf.get(read_bytes, 0, read);
                                     long read_result_pointer = bindings.PeerManager_read_event(
                                             peer_manager_raw_pointer, peer.descriptor_raw_pointer, read_bytes);
-                                    if (bindings.LDKCResult_boolPeerHandleErrorZ_result_ok(read_result_pointer)) {
+                                    if (bindings.CResult_boolPeerHandleErrorZ_is_ok(read_result_pointer)) {
                                         if (bindings.LDKCResult_boolPeerHandleErrorZ_get_ok(read_result_pointer)) {
                                             key.interestOps(key.interestOps() & (~SelectionKey.OP_READ));
                                         }
index 8dc85de0d5c1eea676d3d9126dce32860639d05e..2aee078486f52c93296be157786b8e6aeba26dc2 100644 (file)
@@ -66,7 +66,7 @@ public class PeerTest {
                         String txid = Arrays.toString(bindings.OutPoint_get_txid(funding_txo));
                         assert monitors.containsKey(txid);
                         long update_res = bindings.ChannelMonitor_update_monitor(monitors.get(txid), update, tx_broadcaster, fee_estimator, logger);
-                        assert bindings.LDKCResult_NoneMonitorUpdateErrorZ_result_ok(update_res);
+                        assert bindings.CResult_NoneMonitorUpdateErrorZ_is_ok(update_res);
                         bindings.CResult_NoneMonitorUpdateErrorZ_free(update_res);
                     }
                     bindings.OutPoint_free(funding_txo);
@@ -165,7 +165,7 @@ public class PeerTest {
     void do_read_event(ConcurrentLinkedQueue<Thread> list, long pm, long descriptor, byte[] arr) {
         Thread thread = new Thread(() -> {
             long res = bindings.PeerManager_read_event(pm, descriptor, arr);
-            assert bindings.LDKCResult_boolPeerHandleErrorZ_result_ok(res);
+            assert bindings.CResult_boolPeerHandleErrorZ_is_ok(res);
             //assert bindings.deref_bool(bindings.LDKCResult_boolPeerHandleErrorZ_get_inner(res));
             bindings.CResult_boolPeerHandleErrorZ_free(res);
         });
@@ -218,10 +218,10 @@ public class PeerTest {
         descriptor1.val = bindings.LDKSocketDescriptor_new(sock2);
 
         long init_vec = bindings.PeerManager_new_outbound_connection(peer1.peer_manager, peer2.node_id, descriptor1.val);
-        assert(bindings.LDKCResult_CVec_u8ZPeerHandleErrorZ_result_ok(init_vec));
+        assert(bindings.CResult_CVec_u8ZPeerHandleErrorZ_is_ok(init_vec));
 
         long con_res = bindings.PeerManager_new_inbound_connection(peer2.peer_manager, descriptor2);
-        assert(bindings.LDKCResult_NonePeerHandleErrorZ_result_ok(con_res));
+        assert(bindings.CResult_NonePeerHandleErrorZ_is_ok(con_res));
         bindings.CResult_NonePeerHandleErrorZ_free(con_res);
         do_read_event(list, peer2.peer_manager, descriptor2, bindings.LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok(init_vec));
         bindings.CResult_CVec_u8ZPeerHandleErrorZ_free(init_vec);
@@ -229,7 +229,7 @@ public class PeerTest {
         deliver_peer_messages(list, peer1.peer_manager, peer2.peer_manager);
 
         long cc_res = bindings.ChannelManager_create_channel(peer1.chan_manager, peer2.node_id, 10000, 1000, 42, 0);
-        assert bindings.LDKCResult_NoneAPIErrorZ_result_ok(cc_res);
+        assert bindings.CResult_NoneAPIErrorZ_is_ok(cc_res);
         bindings.CResult_NoneAPIErrorZ_free(cc_res);
 
         deliver_peer_messages(list, peer1.peer_manager, peer2.peer_manager);
@@ -299,12 +299,12 @@ public class PeerTest {
         bindings.Scorer_free(scorer);
 
         for (long chan : peer1_chans) bindings.ChannelDetails_free(chan);
-        assert bindings.LDKCResult_RouteLightningErrorZ_result_ok(route);
+        assert bindings.CResult_RouteLightningErrorZ_is_ok(route);
         long payment_res = bindings.ChannelManager_send_payment(peer1.chan_manager, bindings.LDKCResult_RouteLightningErrorZ_get_ok(route),
                 bindings.C2Tuple_PaymentHashPaymentSecretZ_get_a(inbound_payment), bindings.C2Tuple_PaymentHashPaymentSecretZ_get_b(inbound_payment));
         bindings.CResult_RouteLightningErrorZ_free(route);
         bindings.C2Tuple_PaymentHashPaymentSecretZ_free(inbound_payment);
-        assert bindings.LDKCResult_NonePaymentSendFailureZ_result_ok(payment_res);
+        assert bindings.CResult_NonePaymentSendFailureZ_is_ok(payment_res);
         bindings.CResult_NonePaymentSendFailureZ_free(payment_res);
 
         deliver_peer_messages(list, peer1.peer_manager, peer2.peer_manager);