diff --git a/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelClient.java b/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelClient.java index 7da9fb23..0a3ac16d 100644 --- a/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelClient.java +++ b/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelClient.java @@ -23,9 +23,13 @@ import static com.google.common.base.Preconditions.checkState; *
Does all required verification of server messages and properly stores state objects in the wallet-attached * {@link StoredPaymentChannelClientStates} so that they are automatically closed when necessary and refund * transactions are not lost if the application crashes before it unlocks.
+ * + *Though this interface is largely designed with stateful protocols (eg simple TCP connections) in mind, it is also + * possible to use it with stateless protocols (eg sending protobufs when required over HTTP headers). In this case, the + * "connection" translates roughly into the server-client relationship. See the javadocs for specific functions for more + * details.
*/ public class PaymentChannelClient { - //TODO: Update JavaDocs with notes for communication over stateless protocols private static final org.slf4j.Logger log = LoggerFactory.getLogger(PaymentChannelClient.class); protected final ReentrantLock lock = Threading.lock("channelclient"); @@ -51,7 +55,9 @@ public class PaymentChannelClient { public void sendToServer(Protos.TwoWayChannelMessage msg); /** - *Requests that the connection to the server be closed
+ *Requests that the connection to the server be closed. For stateless protocols, note that after this call, + * no more messages should be received from the server and this object is no longer usable. A + * {@link PaymentChannelClient#connectionClosed()} event should be generated immediately after this call.
* *Called while holding a lock on the {@link PaymentChannelClient} object - be careful about reentrancy
* @@ -294,6 +300,9 @@ public class PaymentChannelClient { *Called when the connection terminates. Notifies the {@link StoredClientChannel} object that we can attempt to * resume this channel in the future and stops generating messages for the server.
* + *For stateless protocols, this translates to a client not using the channel for the immediate future, but + * intending to reopen the channel later. There is likely little reason to use this in a stateless protocol.
+ * *Note that this MUST still be called even after either * {@link ClientConnection#destroyConnection(CloseReason)} or * {@link PaymentChannelClient#close()} is called to actually handle the connection close logic.