X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FErrorAction.java;h=f5769f87b5308b96962d64a772be3b3d1ff2cf0c;hb=ff3dacec3be60f870d81f6df11bd9fff92aa6047;hp=ec2ae18f0843b36773230af1fadaebd13106dd08;hpb=6d094e745feaf94c1059555cd1c997965a34bc36;p=ldk-java diff --git a/src/main/java/org/ldk/structs/ErrorAction.java b/src/main/java/org/ldk/structs/ErrorAction.java index ec2ae18f..f5769f87 100644 --- a/src/main/java/org/ldk/structs/ErrorAction.java +++ b/src/main/java/org/ldk/structs/ErrorAction.java @@ -4,6 +4,7 @@ import org.ldk.impl.bindings; import org.ldk.enums.*; import org.ldk.util.*; import java.util.Arrays; +import java.lang.ref.Reference; import javax.annotation.Nullable; @@ -29,9 +30,15 @@ public class ErrorAction extends CommonBase { if (raw_val.getClass() == bindings.LDKErrorAction.IgnoreAndLog.class) { return new IgnoreAndLog(ptr, (bindings.LDKErrorAction.IgnoreAndLog)raw_val); } + if (raw_val.getClass() == bindings.LDKErrorAction.IgnoreDuplicateGossip.class) { + return new IgnoreDuplicateGossip(ptr, (bindings.LDKErrorAction.IgnoreDuplicateGossip)raw_val); + } if (raw_val.getClass() == bindings.LDKErrorAction.SendErrorMessage.class) { return new SendErrorMessage(ptr, (bindings.LDKErrorAction.SendErrorMessage)raw_val); } + if (raw_val.getClass() == bindings.LDKErrorAction.SendWarningMessage.class) { + return new SendWarningMessage(ptr, (bindings.LDKErrorAction.SendWarningMessage)raw_val); + } assert false; return null; // Unreachable without extending the (internal) bindings interface } @@ -44,7 +51,7 @@ public class ErrorAction extends CommonBase { * * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - @Nullable public final ErrorMessage msg; + @Nullable public final org.ldk.structs.ErrorMessage msg; private DisconnectPeer(long ptr, bindings.LDKErrorAction.DisconnectPeer obj) { super(null, ptr); long msg = obj.msg; @@ -66,12 +73,22 @@ public class ErrorAction extends CommonBase { * If the error is logged, log it at the given level. */ public final static class IgnoreAndLog extends ErrorAction { - public final Level ignore_and_log; + public final org.ldk.enums.Level ignore_and_log; private IgnoreAndLog(long ptr, bindings.LDKErrorAction.IgnoreAndLog obj) { super(null, ptr); this.ignore_and_log = obj.ignore_and_log; } } + /** + * The peer provided us with a gossip message which we'd already seen. In most cases this + * should be ignored, but it may result in the message being forwarded if it is a duplicate of + * our own channel announcements. + */ + public final static class IgnoreDuplicateGossip extends ErrorAction { + private IgnoreDuplicateGossip(long ptr, bindings.LDKErrorAction.IgnoreDuplicateGossip obj) { + super(null, ptr); + } + } /** * The peer did something incorrect. Tell them. */ @@ -79,7 +96,7 @@ public class ErrorAction extends CommonBase { /** * The message to send. */ - public final ErrorMessage msg; + public final org.ldk.structs.ErrorMessage msg; private SendErrorMessage(long ptr, bindings.LDKErrorAction.SendErrorMessage obj) { super(null, ptr); long msg = obj.msg; @@ -88,8 +105,32 @@ public class ErrorAction extends CommonBase { this.msg = msg_hu_conv; } } + /** + * The peer did something incorrect. Tell them without closing any channels. + */ + public final static class SendWarningMessage extends ErrorAction { + /** + * The message to send. + */ + public final org.ldk.structs.WarningMessage msg; + /** + * The peer may have done something harmless that we weren't able to meaningfully process, + * though we should still tell them about it. + * If this event is logged, log it at the given level. + */ + public final org.ldk.enums.Level log_level; + private SendWarningMessage(long ptr, bindings.LDKErrorAction.SendWarningMessage obj) { + super(null, ptr); + long msg = obj.msg; + WarningMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new WarningMessage(null, msg); } + msg_hu_conv.ptrs_to.add(this); + this.msg = msg_hu_conv; + this.log_level = obj.log_level; + } + } long clone_ptr() { long ret = bindings.ErrorAction_clone_ptr(this.ptr); + Reference.reachabilityFence(this); return ret; } @@ -98,8 +139,9 @@ public class ErrorAction extends CommonBase { */ public ErrorAction clone() { long ret = bindings.ErrorAction_clone(this.ptr); + Reference.reachabilityFence(this); if (ret >= 0 && ret <= 4096) { return null; } - ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret); + org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(this); return ret_hu_conv; } @@ -109,8 +151,9 @@ public class ErrorAction extends CommonBase { */ public static ErrorAction disconnect_peer(ErrorMessage msg) { long ret = bindings.ErrorAction_disconnect_peer(msg == null ? 0 : msg.ptr & ~1); + Reference.reachabilityFence(msg); if (ret >= 0 && ret <= 4096) { return null; } - ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret); + org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); return ret_hu_conv; } @@ -121,7 +164,7 @@ public class ErrorAction extends CommonBase { public static ErrorAction ignore_error() { long ret = bindings.ErrorAction_ignore_error(); if (ret >= 0 && ret <= 4096) { return null; } - ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret); + org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); return ret_hu_conv; } @@ -131,8 +174,20 @@ public class ErrorAction extends CommonBase { */ public static ErrorAction ignore_and_log(org.ldk.enums.Level a) { long ret = bindings.ErrorAction_ignore_and_log(a); + Reference.reachabilityFence(a); if (ret >= 0 && ret <= 4096) { return null; } - ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret); + org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + /** + * Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction + */ + public static ErrorAction ignore_duplicate_gossip() { + long ret = bindings.ErrorAction_ignore_duplicate_gossip(); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); return ret_hu_conv; } @@ -142,8 +197,22 @@ public class ErrorAction extends CommonBase { */ public static ErrorAction send_error_message(ErrorMessage msg) { long ret = bindings.ErrorAction_send_error_message(msg == null ? 0 : msg.ptr & ~1); + Reference.reachabilityFence(msg); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + /** + * Utility method to constructs a new SendWarningMessage-variant ErrorAction + */ + public static ErrorAction send_warning_message(WarningMessage msg, org.ldk.enums.Level log_level) { + long ret = bindings.ErrorAction_send_warning_message(msg == null ? 0 : msg.ptr & ~1, log_level); + Reference.reachabilityFence(msg); + Reference.reachabilityFence(log_level); if (ret >= 0 && ret <= 4096) { return null; } - ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret); + org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); return ret_hu_conv; }