From 0656a52eb95f2698cbf0b7d8e6c7962dd5b91de2 Mon Sep 17 00:00:00 2001 From: chimp1984 Date: Sun, 10 Jan 2021 18:11:48 -0500 Subject: [PATCH] Refactor: Move mailbox related classed to mailbox package. Make constructor public. --- .../java/bisq/core/alert/PrivateNotificationMessage.java | 2 +- .../proto/persistable/CorePersistenceProtoResolver.java | 2 +- .../java/bisq/core/support/messages/SupportMessage.java | 2 +- .../messages/CounterCurrencyTransferStartedMessage.java | 2 +- .../trade/messages/DepositTxAndDelayedPayoutTxMessage.java | 2 +- .../trade/messages/MediatedPayoutTxPublishedMessage.java | 2 +- .../trade/messages/MediatedPayoutTxSignatureMessage.java | 2 +- .../bisq/core/trade/messages/PayoutTxPublishedMessage.java | 2 +- .../trade/messages/PeerPublishedDelayedPayoutTxMessage.java | 2 +- .../bisq/core/trade/messages/RefreshTradeStateRequest.java | 2 +- .../core/trade/messages/TraderSignedWitnessMessage.java | 2 +- .../main/java/bisq/core/trade/protocol/TradeProtocol.java | 2 +- p2p/src/main/java/bisq/network/p2p/AckMessage.java | 1 + p2p/src/main/java/bisq/network/p2p/P2PService.java | 3 +++ .../bisq/network/p2p/PrefixedSealedAndSignedMessage.java | 2 ++ .../java/bisq/network/p2p/{ => mailbox}/MailboxItem.java | 3 ++- .../java/bisq/network/p2p/{ => mailbox}/MailboxMessage.java | 6 +++++- .../bisq/network/p2p/{ => mailbox}/MailboxMessageList.java | 4 ++-- .../java/bisq/network/p2p/mocks/MockMailboxPayload.java | 2 +- 19 files changed, 28 insertions(+), 17 deletions(-) rename p2p/src/main/java/bisq/network/p2p/{ => mailbox}/MailboxItem.java (96%) rename p2p/src/main/java/bisq/network/p2p/{ => mailbox}/MailboxMessage.java (84%) rename p2p/src/main/java/bisq/network/p2p/{ => mailbox}/MailboxMessageList.java (97%) diff --git a/core/src/main/java/bisq/core/alert/PrivateNotificationMessage.java b/core/src/main/java/bisq/core/alert/PrivateNotificationMessage.java index 25820ef903..482f84f34b 100644 --- a/core/src/main/java/bisq/core/alert/PrivateNotificationMessage.java +++ b/core/src/main/java/bisq/core/alert/PrivateNotificationMessage.java @@ -17,8 +17,8 @@ package bisq.core.alert; -import bisq.network.p2p.MailboxMessage; import bisq.network.p2p.NodeAddress; +import bisq.network.p2p.mailbox.MailboxMessage; import bisq.common.app.Version; import bisq.common.proto.network.NetworkEnvelope; diff --git a/core/src/main/java/bisq/core/proto/persistable/CorePersistenceProtoResolver.java b/core/src/main/java/bisq/core/proto/persistable/CorePersistenceProtoResolver.java index 539d8ace19..e0937ccaf2 100644 --- a/core/src/main/java/bisq/core/proto/persistable/CorePersistenceProtoResolver.java +++ b/core/src/main/java/bisq/core/proto/persistable/CorePersistenceProtoResolver.java @@ -43,8 +43,8 @@ import bisq.core.trade.statistics.TradeStatistics3Store; import bisq.core.user.PreferencesPayload; import bisq.core.user.UserPayload; -import bisq.network.p2p.MailboxMessageList; import bisq.network.p2p.mailbox.IgnoredMailboxMap; +import bisq.network.p2p.mailbox.MailboxMessageList; import bisq.network.p2p.peers.peerexchange.PeerList; import bisq.network.p2p.storage.persistence.SequenceNumberMap; diff --git a/core/src/main/java/bisq/core/support/messages/SupportMessage.java b/core/src/main/java/bisq/core/support/messages/SupportMessage.java index fae761210f..6d54bf353b 100644 --- a/core/src/main/java/bisq/core/support/messages/SupportMessage.java +++ b/core/src/main/java/bisq/core/support/messages/SupportMessage.java @@ -19,8 +19,8 @@ package bisq.core.support.messages; import bisq.core.support.SupportType; -import bisq.network.p2p.MailboxMessage; import bisq.network.p2p.UidMessage; +import bisq.network.p2p.mailbox.MailboxMessage; import bisq.common.proto.network.NetworkEnvelope; diff --git a/core/src/main/java/bisq/core/trade/messages/CounterCurrencyTransferStartedMessage.java b/core/src/main/java/bisq/core/trade/messages/CounterCurrencyTransferStartedMessage.java index 416c7d74c2..3bd5c368de 100644 --- a/core/src/main/java/bisq/core/trade/messages/CounterCurrencyTransferStartedMessage.java +++ b/core/src/main/java/bisq/core/trade/messages/CounterCurrencyTransferStartedMessage.java @@ -17,8 +17,8 @@ package bisq.core.trade.messages; -import bisq.network.p2p.MailboxMessage; import bisq.network.p2p.NodeAddress; +import bisq.network.p2p.mailbox.MailboxMessage; import bisq.common.app.Version; import bisq.common.proto.ProtoUtil; diff --git a/core/src/main/java/bisq/core/trade/messages/DepositTxAndDelayedPayoutTxMessage.java b/core/src/main/java/bisq/core/trade/messages/DepositTxAndDelayedPayoutTxMessage.java index 6d90bb1f2d..9146bbb159 100644 --- a/core/src/main/java/bisq/core/trade/messages/DepositTxAndDelayedPayoutTxMessage.java +++ b/core/src/main/java/bisq/core/trade/messages/DepositTxAndDelayedPayoutTxMessage.java @@ -17,8 +17,8 @@ package bisq.core.trade.messages; -import bisq.network.p2p.MailboxMessage; import bisq.network.p2p.NodeAddress; +import bisq.network.p2p.mailbox.MailboxMessage; import bisq.common.app.Version; import bisq.common.util.Utilities; diff --git a/core/src/main/java/bisq/core/trade/messages/MediatedPayoutTxPublishedMessage.java b/core/src/main/java/bisq/core/trade/messages/MediatedPayoutTxPublishedMessage.java index e20daba473..c288a3e3ab 100644 --- a/core/src/main/java/bisq/core/trade/messages/MediatedPayoutTxPublishedMessage.java +++ b/core/src/main/java/bisq/core/trade/messages/MediatedPayoutTxPublishedMessage.java @@ -17,8 +17,8 @@ package bisq.core.trade.messages; -import bisq.network.p2p.MailboxMessage; import bisq.network.p2p.NodeAddress; +import bisq.network.p2p.mailbox.MailboxMessage; import bisq.common.app.Version; import bisq.common.proto.network.NetworkEnvelope; diff --git a/core/src/main/java/bisq/core/trade/messages/MediatedPayoutTxSignatureMessage.java b/core/src/main/java/bisq/core/trade/messages/MediatedPayoutTxSignatureMessage.java index b476576b65..d51f1fd513 100644 --- a/core/src/main/java/bisq/core/trade/messages/MediatedPayoutTxSignatureMessage.java +++ b/core/src/main/java/bisq/core/trade/messages/MediatedPayoutTxSignatureMessage.java @@ -17,8 +17,8 @@ package bisq.core.trade.messages; -import bisq.network.p2p.MailboxMessage; import bisq.network.p2p.NodeAddress; +import bisq.network.p2p.mailbox.MailboxMessage; import bisq.common.app.Version; import bisq.common.util.Utilities; diff --git a/core/src/main/java/bisq/core/trade/messages/PayoutTxPublishedMessage.java b/core/src/main/java/bisq/core/trade/messages/PayoutTxPublishedMessage.java index 6b6f38f9c1..cb102f4ac0 100644 --- a/core/src/main/java/bisq/core/trade/messages/PayoutTxPublishedMessage.java +++ b/core/src/main/java/bisq/core/trade/messages/PayoutTxPublishedMessage.java @@ -19,8 +19,8 @@ package bisq.core.trade.messages; import bisq.core.account.sign.SignedWitness; -import bisq.network.p2p.MailboxMessage; import bisq.network.p2p.NodeAddress; +import bisq.network.p2p.mailbox.MailboxMessage; import bisq.common.app.Version; import bisq.common.proto.network.NetworkEnvelope; diff --git a/core/src/main/java/bisq/core/trade/messages/PeerPublishedDelayedPayoutTxMessage.java b/core/src/main/java/bisq/core/trade/messages/PeerPublishedDelayedPayoutTxMessage.java index 9447f9494f..f9d591994f 100644 --- a/core/src/main/java/bisq/core/trade/messages/PeerPublishedDelayedPayoutTxMessage.java +++ b/core/src/main/java/bisq/core/trade/messages/PeerPublishedDelayedPayoutTxMessage.java @@ -17,8 +17,8 @@ package bisq.core.trade.messages; -import bisq.network.p2p.MailboxMessage; import bisq.network.p2p.NodeAddress; +import bisq.network.p2p.mailbox.MailboxMessage; import bisq.common.app.Version; diff --git a/core/src/main/java/bisq/core/trade/messages/RefreshTradeStateRequest.java b/core/src/main/java/bisq/core/trade/messages/RefreshTradeStateRequest.java index f865ea58de..7bad5cebde 100644 --- a/core/src/main/java/bisq/core/trade/messages/RefreshTradeStateRequest.java +++ b/core/src/main/java/bisq/core/trade/messages/RefreshTradeStateRequest.java @@ -17,8 +17,8 @@ package bisq.core.trade.messages; -import bisq.network.p2p.MailboxMessage; import bisq.network.p2p.NodeAddress; +import bisq.network.p2p.mailbox.MailboxMessage; import lombok.EqualsAndHashCode; import lombok.Value; diff --git a/core/src/main/java/bisq/core/trade/messages/TraderSignedWitnessMessage.java b/core/src/main/java/bisq/core/trade/messages/TraderSignedWitnessMessage.java index bae708b577..1f336cf39a 100644 --- a/core/src/main/java/bisq/core/trade/messages/TraderSignedWitnessMessage.java +++ b/core/src/main/java/bisq/core/trade/messages/TraderSignedWitnessMessage.java @@ -19,8 +19,8 @@ package bisq.core.trade.messages; import bisq.core.account.sign.SignedWitness; -import bisq.network.p2p.MailboxMessage; import bisq.network.p2p.NodeAddress; +import bisq.network.p2p.mailbox.MailboxMessage; import bisq.common.app.Version; diff --git a/core/src/main/java/bisq/core/trade/protocol/TradeProtocol.java b/core/src/main/java/bisq/core/trade/protocol/TradeProtocol.java index 934ad56c50..685610d5b7 100644 --- a/core/src/main/java/bisq/core/trade/protocol/TradeProtocol.java +++ b/core/src/main/java/bisq/core/trade/protocol/TradeProtocol.java @@ -28,9 +28,9 @@ import bisq.network.p2p.AckMessage; import bisq.network.p2p.AckMessageSourceType; import bisq.network.p2p.DecryptedDirectMessageListener; import bisq.network.p2p.DecryptedMessageWithPubKey; -import bisq.network.p2p.MailboxMessage; import bisq.network.p2p.NodeAddress; import bisq.network.p2p.SendMailboxMessageListener; +import bisq.network.p2p.mailbox.MailboxMessage; import bisq.network.p2p.messaging.DecryptedMailboxListener; import bisq.common.Timer; diff --git a/p2p/src/main/java/bisq/network/p2p/AckMessage.java b/p2p/src/main/java/bisq/network/p2p/AckMessage.java index fea3fa0a33..19040dd2d7 100644 --- a/p2p/src/main/java/bisq/network/p2p/AckMessage.java +++ b/p2p/src/main/java/bisq/network/p2p/AckMessage.java @@ -17,6 +17,7 @@ package bisq.network.p2p; +import bisq.network.p2p.mailbox.MailboxMessage; import bisq.network.p2p.storage.payload.ExpirablePayload; import bisq.common.app.Version; diff --git a/p2p/src/main/java/bisq/network/p2p/P2PService.java b/p2p/src/main/java/bisq/network/p2p/P2PService.java index 23dc0004e3..9fbe877f30 100644 --- a/p2p/src/main/java/bisq/network/p2p/P2PService.java +++ b/p2p/src/main/java/bisq/network/p2p/P2PService.java @@ -20,6 +20,9 @@ package bisq.network.p2p; import bisq.network.Socks5ProxyProvider; import bisq.network.crypto.EncryptionService; import bisq.network.p2p.mailbox.IgnoredMailboxService; +import bisq.network.p2p.mailbox.MailboxItem; +import bisq.network.p2p.mailbox.MailboxMessage; +import bisq.network.p2p.mailbox.MailboxMessageList; import bisq.network.p2p.messaging.DecryptedMailboxListener; import bisq.network.p2p.network.CloseConnectionReason; import bisq.network.p2p.network.Connection; diff --git a/p2p/src/main/java/bisq/network/p2p/PrefixedSealedAndSignedMessage.java b/p2p/src/main/java/bisq/network/p2p/PrefixedSealedAndSignedMessage.java index bf617dce11..6b2c55d66c 100644 --- a/p2p/src/main/java/bisq/network/p2p/PrefixedSealedAndSignedMessage.java +++ b/p2p/src/main/java/bisq/network/p2p/PrefixedSealedAndSignedMessage.java @@ -17,6 +17,8 @@ package bisq.network.p2p; +import bisq.network.p2p.mailbox.MailboxMessage; + import bisq.common.app.Version; import bisq.common.crypto.SealedAndSigned; import bisq.common.proto.network.NetworkEnvelope; diff --git a/p2p/src/main/java/bisq/network/p2p/MailboxItem.java b/p2p/src/main/java/bisq/network/p2p/mailbox/MailboxItem.java similarity index 96% rename from p2p/src/main/java/bisq/network/p2p/MailboxItem.java rename to p2p/src/main/java/bisq/network/p2p/mailbox/MailboxItem.java index cdf6edf1dc..c8afdaed04 100644 --- a/p2p/src/main/java/bisq/network/p2p/MailboxItem.java +++ b/p2p/src/main/java/bisq/network/p2p/mailbox/MailboxItem.java @@ -15,8 +15,9 @@ * along with Bisq. If not, see . */ -package bisq.network.p2p; +package bisq.network.p2p.mailbox; +import bisq.network.p2p.DecryptedMessageWithPubKey; import bisq.network.p2p.storage.payload.ProtectedMailboxStorageEntry; import bisq.common.proto.ProtobufferException; diff --git a/p2p/src/main/java/bisq/network/p2p/MailboxMessage.java b/p2p/src/main/java/bisq/network/p2p/mailbox/MailboxMessage.java similarity index 84% rename from p2p/src/main/java/bisq/network/p2p/MailboxMessage.java rename to p2p/src/main/java/bisq/network/p2p/mailbox/MailboxMessage.java index 719c33f6cb..9a7d36fa02 100644 --- a/p2p/src/main/java/bisq/network/p2p/MailboxMessage.java +++ b/p2p/src/main/java/bisq/network/p2p/mailbox/MailboxMessage.java @@ -15,9 +15,13 @@ * along with Bisq. If not, see . */ -package bisq.network.p2p; +package bisq.network.p2p.mailbox; +import bisq.network.p2p.DirectMessage; +import bisq.network.p2p.NodeAddress; +import bisq.network.p2p.UidMessage; + public interface MailboxMessage extends DirectMessage, UidMessage { NodeAddress getSenderNodeAddress(); } diff --git a/p2p/src/main/java/bisq/network/p2p/MailboxMessageList.java b/p2p/src/main/java/bisq/network/p2p/mailbox/MailboxMessageList.java similarity index 97% rename from p2p/src/main/java/bisq/network/p2p/MailboxMessageList.java rename to p2p/src/main/java/bisq/network/p2p/mailbox/MailboxMessageList.java index 12e4d7db2f..75adfa2fb5 100644 --- a/p2p/src/main/java/bisq/network/p2p/MailboxMessageList.java +++ b/p2p/src/main/java/bisq/network/p2p/mailbox/MailboxMessageList.java @@ -15,7 +15,7 @@ * along with Bisq. If not, see . */ -package bisq.network.p2p; +package bisq.network.p2p.mailbox; import bisq.common.proto.ProtobufferException; import bisq.common.proto.network.NetworkProtoResolver; @@ -35,7 +35,7 @@ import lombok.extern.slf4j.Slf4j; @EqualsAndHashCode(callSuper = true) public class MailboxMessageList extends PersistableList { - MailboxMessageList() { + public MailboxMessageList() { super(); } diff --git a/p2p/src/test/java/bisq/network/p2p/mocks/MockMailboxPayload.java b/p2p/src/test/java/bisq/network/p2p/mocks/MockMailboxPayload.java index b791a9c4e6..2ccd75de89 100644 --- a/p2p/src/test/java/bisq/network/p2p/mocks/MockMailboxPayload.java +++ b/p2p/src/test/java/bisq/network/p2p/mocks/MockMailboxPayload.java @@ -17,8 +17,8 @@ package bisq.network.p2p.mocks; -import bisq.network.p2p.MailboxMessage; import bisq.network.p2p.NodeAddress; +import bisq.network.p2p.mailbox.MailboxMessage; import bisq.network.p2p.storage.payload.ExpirablePayload; import bisq.common.app.Version;