mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Let MailboxMessage extend ExpirablePayload:
For all MailboxMessage we want to be sure they have an expire date. Add getTTL methods and TTL value. We use 7 days for ChatMessages and 30 days for PrivateNotificationMessages. All others use default 15 days. We prefer to keep them explicit and not use a default method in ExpirablePayload or MailboxMessage. The value in PrefixedSealedAndSignedMessage will not be used as the sender use the TTL of the payload and pass that to the MailboxStoragePayload where we store it in the extraMap. That way we can use different TTL even the payload message is encrypted and we would not be able to look it up.
This commit is contained in:
parent
470230c35c
commit
2b05ed54fc
@ -23,12 +23,16 @@ import bisq.network.p2p.mailbox.MailboxMessage;
|
||||
import bisq.common.app.Version;
|
||||
import bisq.common.proto.network.NetworkEnvelope;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Value;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Value
|
||||
public class PrivateNotificationMessage extends NetworkEnvelope implements MailboxMessage {
|
||||
public static final long TTL = TimeUnit.DAYS.toMillis(30);
|
||||
|
||||
private final PrivateNotificationPayload privateNotificationPayload;
|
||||
private final NodeAddress senderNodeAddress;
|
||||
private final String uid;
|
||||
@ -70,4 +74,9 @@ public class PrivateNotificationMessage extends NetworkEnvelope implements Mailb
|
||||
proto.getUid(),
|
||||
messageVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTTL() {
|
||||
return TTL;
|
||||
}
|
||||
}
|
||||
|
@ -20,9 +20,18 @@ package bisq.core.support.dispute.messages;
|
||||
import bisq.core.support.SupportType;
|
||||
import bisq.core.support.messages.SupportMessage;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public abstract class DisputeMessage extends SupportMessage {
|
||||
public static final long TTL = TimeUnit.DAYS.toMillis(15);
|
||||
|
||||
public DisputeMessage(int messageVersion, String uid, SupportType supportType) {
|
||||
super(messageVersion, uid, supportType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTTL() {
|
||||
return TTL;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
@ -61,6 +62,8 @@ import javax.annotation.Nullable;
|
||||
@Getter
|
||||
@Slf4j
|
||||
public final class ChatMessage extends SupportMessage {
|
||||
public static final long TTL = TimeUnit.DAYS.toMillis(7);
|
||||
|
||||
public interface Listener {
|
||||
void onMessageStateChanged();
|
||||
}
|
||||
@ -339,6 +342,11 @@ public final class ChatMessage extends SupportMessage {
|
||||
return resultChatMessage != null && resultChatMessage.getUid().equals(uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTTL() {
|
||||
return TTL;
|
||||
}
|
||||
|
||||
private void notifyChangeListener() {
|
||||
if (listener != null) {
|
||||
Listener listener = this.listener.get();
|
||||
|
@ -26,6 +26,7 @@ import bisq.common.proto.network.NetworkEnvelope;
|
||||
import com.google.protobuf.ByteString;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Value;
|
||||
@ -35,6 +36,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Value
|
||||
public final class PrefixedSealedAndSignedMessage extends NetworkEnvelope implements MailboxMessage, SendersNodeAddressMessage {
|
||||
public static final long TTL = TimeUnit.DAYS.toMillis(15);
|
||||
|
||||
private final NodeAddress senderNodeAddress;
|
||||
private final SealedAndSigned sealedAndSigned;
|
||||
|
||||
@ -100,4 +103,9 @@ public final class PrefixedSealedAndSignedMessage extends NetworkEnvelope implem
|
||||
proto.getUid(),
|
||||
-1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTTL() {
|
||||
return TTL;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,8 @@ package bisq.network.p2p.mailbox;
|
||||
import bisq.network.p2p.DirectMessage;
|
||||
import bisq.network.p2p.NodeAddress;
|
||||
import bisq.network.p2p.UidMessage;
|
||||
import bisq.network.p2p.storage.payload.ExpirablePayload;
|
||||
|
||||
public interface MailboxMessage extends DirectMessage, UidMessage {
|
||||
public interface MailboxMessage extends DirectMessage, UidMessage, ExpirablePayload {
|
||||
NodeAddress getSenderNodeAddress();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user