Package org.ldk.structs
Class OnionMessageHandler
- java.lang.Object
-
- org.ldk.structs.OnionMessageHandler
-
public class OnionMessageHandler extends Object
A trait to describe an object that can receive onion messages.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceOnionMessageHandler.OnionMessageHandlerInterface
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()Destroys the object, freeing associated resources.protected voidfinalize()OnionMessageProviderget_onion_message_provider()Gets the underlying OnionMessageProvider.voidhandle_onion_message(byte[] peer_node_id, OnionMessage msg)Handle an incoming `onion_message` message from the given peer.static OnionMessageHandlernew_impl(OnionMessageHandler.OnionMessageHandlerInterface arg, OnionMessageProvider.OnionMessageProviderInterface OnionMessageProvider_impl)Result_NoneNoneZpeer_connected(byte[] their_node_id, Init init, boolean inbound)Called when a connection is established with a peer.voidpeer_disconnected(byte[] their_node_id)Indicates a connection to the peer failed/an existing connection was lost.InitFeaturesprovided_init_features(byte[] their_node_id)Gets the init feature flags which should be sent to the given peer.NodeFeaturesprovided_node_features()Gets the node feature flags which this handler itself supports.
-
-
-
Method Detail
-
finalize
protected void finalize() throws Throwable
-
destroy
public void destroy()
Destroys the object, freeing associated resources. After this call, any access to this object may result in a SEGFAULT or worse. You should generally NEVER call this method. You should let the garbage collector do this for you when it finalizes objects. However, it may be useful for types which represent locks and should be closed immediately to avoid holding locks until the GC runs.
-
new_impl
public static OnionMessageHandler new_impl(OnionMessageHandler.OnionMessageHandlerInterface arg, OnionMessageProvider.OnionMessageProviderInterface OnionMessageProvider_impl)
-
get_onion_message_provider
public OnionMessageProvider get_onion_message_provider()
Gets the underlying OnionMessageProvider.
-
handle_onion_message
public void handle_onion_message(byte[] peer_node_id, OnionMessage msg)Handle an incoming `onion_message` message from the given peer.
-
peer_connected
public Result_NoneNoneZ peer_connected(byte[] their_node_id, Init init, boolean inbound)
Called when a connection is established with a peer. Can be used to track which peers advertise onion message support and are online. May return an `Err(())` if the features the peer supports are not sufficient to communicate with us. Implementors should be somewhat conservative about doing so, however, as other message handlers may still wish to communicate with this peer.
-
peer_disconnected
public void peer_disconnected(byte[] their_node_id)
Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to drop and refuse to forward onion messages to this peer.
-
provided_node_features
public NodeFeatures provided_node_features()
Gets the node feature flags which this handler itself supports. All available handlers are queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] which are broadcasted in our [`NodeAnnouncement`] message.
-
provided_init_features
public InitFeatures provided_init_features(byte[] their_node_id)
Gets the init feature flags which should be sent to the given peer. All available handlers are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] which are sent in our [`Init`] message. Note that this method is called before [`Self::peer_connected`].
-
-