X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=c_sharp%2Fsrc%2Forg%2Fldk%2Fstructs%2FReplyChannelRange.cs;h=3dafe2eff5044e6f36301067053bc53c7541ecb2;hb=152d721883552dd92925833d15687d7d64d01c35;hp=e4f97698df2d0b1bc75d03070910c06658aef4a2;hpb=8aa8a96fc6d8fcdd3fbb419b4b4c12482af14938;p=ldk-java diff --git a/c_sharp/src/org/ldk/structs/ReplyChannelRange.cs b/c_sharp/src/org/ldk/structs/ReplyChannelRange.cs index e4f97698..3dafe2ef 100644 --- a/c_sharp/src/org/ldk/structs/ReplyChannelRange.cs +++ b/c_sharp/src/org/ldk/structs/ReplyChannelRange.cs @@ -7,13 +7,17 @@ namespace org { namespace ldk { namespace structs { /** - * A reply_channel_range message is a reply to a query_channel_range - * message. Multiple reply_channel_range messages can be sent in reply - * to a single query_channel_range message. The query recipient makes a + * A [`reply_channel_range`] message is a reply to a [`QueryChannelRange`] + * message. + * + * Multiple `reply_channel_range` messages can be sent in reply + * to a single [`QueryChannelRange`] message. The query recipient makes a * best effort to respond based on their local network view which may - * not be a perfect view of the network. The short_channel_ids in the - * reply are encoded. We only support encoding_type=0 uncompressed - * serialization and do not support encoding_type=1 zlib serialization. + * not be a perfect view of the network. The `short_channel_id`s in the + * reply are encoded. We only support `encoding_type=0` uncompressed + * serialization and do not support `encoding_type=1` zlib serialization. + * + * [`reply_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages */ public class ReplyChannelRange : CommonBase { internal ReplyChannelRange(object _dummy, long ptr) : base(ptr) { } @@ -25,16 +29,18 @@ public class ReplyChannelRange : CommonBase { * The genesis hash of the blockchain being queried */ public byte[] get_chain_hash() { - byte[] ret = bindings.ReplyChannelRange_get_chain_hash(this.ptr); + long ret = bindings.ReplyChannelRange_get_chain_hash(this.ptr); GC.KeepAlive(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + byte[] ret_conv = InternalUtils.decodeUint8Array(ret); + return ret_conv; } /** * The genesis hash of the blockchain being queried */ public void set_chain_hash(byte[] val) { - bindings.ReplyChannelRange_set_chain_hash(this.ptr, InternalUtils.check_arr_len(val, 32)); + bindings.ReplyChannelRange_set_chain_hash(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32))); GC.KeepAlive(this); GC.KeepAlive(val); } @@ -94,21 +100,23 @@ public class ReplyChannelRange : CommonBase { } /** - * The short_channel_ids in the channel range + * The `short_channel_id`s in the channel range * * Returns a copy of the field. */ public long[] get_short_channel_ids() { - long[] ret = bindings.ReplyChannelRange_get_short_channel_ids(this.ptr); + long ret = bindings.ReplyChannelRange_get_short_channel_ids(this.ptr); GC.KeepAlive(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + long[] ret_conv = InternalUtils.decodeUint64Array(ret); + return ret_conv; } /** - * The short_channel_ids in the channel range + * The `short_channel_id`s in the channel range */ public void set_short_channel_ids(long[] val) { - bindings.ReplyChannelRange_set_short_channel_ids(this.ptr, val); + bindings.ReplyChannelRange_set_short_channel_ids(this.ptr, InternalUtils.encodeUint64Array(val)); GC.KeepAlive(this); GC.KeepAlive(val); } @@ -117,7 +125,7 @@ public class ReplyChannelRange : CommonBase { * Constructs a new ReplyChannelRange given each field */ public static ReplyChannelRange of(byte[] chain_hash_arg, int first_blocknum_arg, int number_of_blocks_arg, bool sync_complete_arg, long[] short_channel_ids_arg) { - long ret = bindings.ReplyChannelRange_new(InternalUtils.check_arr_len(chain_hash_arg, 32), first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg); + long ret = bindings.ReplyChannelRange_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(chain_hash_arg, 32)), first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, InternalUtils.encodeUint64Array(short_channel_ids_arg)); GC.KeepAlive(chain_hash_arg); GC.KeepAlive(first_blocknum_arg); GC.KeepAlive(number_of_blocks_arg); @@ -147,13 +155,25 @@ public class ReplyChannelRange : CommonBase { return ret_hu_conv; } + /** + * Generates a non-cryptographic 64-bit hash of the ReplyChannelRange. + */ + public long hash() { + long ret = bindings.ReplyChannelRange_hash(this.ptr); + GC.KeepAlive(this); + return ret; + } + + public override int GetHashCode() { + return (int)this.hash(); + } /** * Checks if two ReplyChannelRanges contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ public bool eq(org.ldk.structs.ReplyChannelRange b) { - bool ret = bindings.ReplyChannelRange_eq(this.ptr, b == null ? 0 : b.ptr); + bool ret = bindings.ReplyChannelRange_eq(this.ptr, b.ptr); GC.KeepAlive(this); GC.KeepAlive(b); if (this != null) { this.ptrs_to.AddLast(b); }; @@ -168,7 +188,7 @@ public class ReplyChannelRange : CommonBase { * Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write */ public static Result_ReplyChannelRangeDecodeErrorZ read(byte[] ser) { - long ret = bindings.ReplyChannelRange_read(ser); + long ret = bindings.ReplyChannelRange_read(InternalUtils.encodeUint8Array(ser)); GC.KeepAlive(ser); if (ret >= 0 && ret <= 4096) { return null; } Result_ReplyChannelRangeDecodeErrorZ ret_hu_conv = Result_ReplyChannelRangeDecodeErrorZ.constr_from_ptr(ret); @@ -179,9 +199,11 @@ public class ReplyChannelRange : CommonBase { * Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read */ public byte[] write() { - byte[] ret = bindings.ReplyChannelRange_write(this.ptr); + long ret = bindings.ReplyChannelRange_write(this.ptr); GC.KeepAlive(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + byte[] ret_conv = InternalUtils.decodeUint8Array(ret); + return ret_conv; } }