]> git.bitcoin.ninja Git - ldk-java/blob - c_sharp/src/org/ldk/structs/DefaultMessageRouter.cs
Update CI references to LDK 0.0.124 drop stale memchr pins
[ldk-java] / c_sharp / src / org / ldk / structs / DefaultMessageRouter.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * A [`MessageRouter`] that can only route to a directly connected [`Destination`].
11  * 
12  * # Privacy
13  * 
14  * Creating [`BlindedMessagePath`]s may affect privacy since, if a suitable path cannot be found,
15  * it will create a one-hop path using the recipient as the introduction node if it is a announced
16  * node. Otherwise, there is no way to find a path to the introduction node in order to send a
17  * message, and thus an `Err` is returned.
18  */
19 public class DefaultMessageRouter : CommonBase {
20         internal DefaultMessageRouter(object _dummy, long ptr) : base(ptr) { }
21         ~DefaultMessageRouter() {
22                 if (ptr != 0) { bindings.DefaultMessageRouter_free(ptr); }
23         }
24
25         /**
26          * Creates a [`DefaultMessageRouter`] using the given [`NetworkGraph`].
27          */
28         public static DefaultMessageRouter of(org.ldk.structs.NetworkGraph network_graph, org.ldk.structs.EntropySource entropy_source) {
29                 long ret = bindings.DefaultMessageRouter_new(network_graph.ptr, entropy_source.ptr);
30                 GC.KeepAlive(network_graph);
31                 GC.KeepAlive(entropy_source);
32                 if (ret >= 0 && ret <= 4096) { return null; }
33                 org.ldk.structs.DefaultMessageRouter ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.DefaultMessageRouter(null, ret); }
34                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
35                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(network_graph); };
36                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
37                 return ret_hu_conv;
38         }
39
40         /**
41          * Constructs a new MessageRouter which calls the relevant methods on this_arg.
42          * This copies the `inner` pointer in this_arg and thus the returned MessageRouter must be freed before this_arg is
43          */
44         public MessageRouter as_MessageRouter() {
45                 long ret = bindings.DefaultMessageRouter_as_MessageRouter(this.ptr);
46                 GC.KeepAlive(this);
47                 if (ret >= 0 && ret <= 4096) { return null; }
48                 MessageRouter ret_hu_conv = new MessageRouter(null, ret);
49                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
50                 return ret_hu_conv;
51         }
52
53 }
54 } } }