mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-03 20:24:24 -04:00
Revert "Support for open JDK 20 by updating dependencies"
This reverts commit 5923a34ef9
.
This commit is contained in:
parent
8b7a6945b2
commit
c4898a8ec0
257 changed files with 1875 additions and 1479 deletions
|
@ -18,15 +18,16 @@
|
|||
package haveno.network;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.name.Named;
|
||||
import com.runjva.sourceforge.jsocks.protocol.Socks5Proxy;
|
||||
import haveno.common.config.Config;
|
||||
import haveno.network.p2p.network.NetworkNode;
|
||||
import java.net.UnknownHostException;
|
||||
import javax.annotation.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Named;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
/**
|
||||
* Provides Socks5Proxies for the bitcoin network and http requests
|
||||
* <p/>
|
||||
|
|
|
@ -17,11 +17,9 @@
|
|||
|
||||
package haveno.network.crypto;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import haveno.common.crypto.CryptoException;
|
||||
import haveno.common.crypto.Encryption;
|
||||
import static haveno.common.crypto.Encryption.decryptSecretKey;
|
||||
import haveno.common.crypto.Hash;
|
||||
import haveno.common.crypto.KeyRing;
|
||||
import haveno.common.crypto.PubKeyRing;
|
||||
|
@ -31,11 +29,15 @@ import haveno.common.proto.ProtobufferException;
|
|||
import haveno.common.proto.network.NetworkEnvelope;
|
||||
import haveno.common.proto.network.NetworkProtoResolver;
|
||||
import haveno.network.p2p.DecryptedMessageWithPubKey;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.inject.Inject;
|
||||
import java.security.KeyPair;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.PublicKey;
|
||||
import javax.crypto.SecretKey;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import static haveno.common.crypto.Encryption.decryptSecretKey;
|
||||
|
||||
@Slf4j
|
||||
public class EncryptionService {
|
||||
|
|
|
@ -17,25 +17,10 @@
|
|||
|
||||
package haveno.network.http;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.google.inject.Inject;
|
||||
import com.runjva.sourceforge.jsocks.protocol.Socks5Proxy;
|
||||
import haveno.common.app.Version;
|
||||
import haveno.common.util.Utilities;
|
||||
import haveno.network.Socks5ProxyProvider;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.annotation.Nullable;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -54,6 +39,23 @@ import org.apache.http.impl.client.HttpClients;
|
|||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||
import org.apache.http.ssl.SSLContexts;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
// TODO close connection if failing
|
||||
@Slf4j
|
||||
public class HttpClientImpl implements HttpClient {
|
||||
|
|
|
@ -17,20 +17,24 @@
|
|||
|
||||
package haveno.network.p2p;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.name.Named;
|
||||
import haveno.common.config.Config;
|
||||
import haveno.common.proto.network.NetworkProtoResolver;
|
||||
import haveno.network.p2p.network.BanFilter;
|
||||
import haveno.network.p2p.network.BridgeAddressProvider;
|
||||
import haveno.network.p2p.network.LocalhostNetworkNode;
|
||||
import haveno.network.p2p.network.BanFilter;
|
||||
import haveno.network.p2p.network.NetworkNode;
|
||||
import haveno.network.p2p.network.NewTor;
|
||||
import haveno.network.p2p.network.RunningTor;
|
||||
import haveno.network.p2p.network.TorMode;
|
||||
import haveno.network.p2p.network.TorNetworkNode;
|
||||
|
||||
import haveno.common.config.Config;
|
||||
import haveno.common.proto.network.NetworkProtoResolver;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Provider;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class NetworkNodeProvider implements Provider<NetworkNode> {
|
||||
|
|
|
@ -17,12 +17,13 @@
|
|||
|
||||
package haveno.network.p2p.mailbox;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import haveno.common.persistence.PersistenceManager;
|
||||
import haveno.common.proto.persistable.PersistedDataHost;
|
||||
import haveno.network.p2p.storage.payload.MailboxStoragePayload;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
* We persist failed attempts to decrypt mailbox messages (expected if mailbox message was not addressed to us).
|
||||
* This improves performance at processing mailbox messages.
|
||||
|
|
|
@ -18,15 +18,10 @@
|
|||
package haveno.network.p2p.mailbox;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import com.google.common.util.concurrent.SettableFuture;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import com.google.inject.name.Named;
|
||||
import haveno.common.UserThread;
|
||||
import haveno.common.config.Config;
|
||||
import haveno.common.crypto.CryptoException;
|
||||
|
@ -58,6 +53,13 @@ import haveno.network.p2p.storage.payload.MailboxStoragePayload;
|
|||
import haveno.network.p2p.storage.payload.ProtectedMailboxStorageEntry;
|
||||
import haveno.network.p2p.storage.payload.ProtectedStorageEntry;
|
||||
import haveno.network.utils.CapabilityUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
import java.security.PublicKey;
|
||||
import java.time.Clock;
|
||||
import java.util.ArrayDeque;
|
||||
|
@ -76,9 +78,9 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Nullable;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Responsible for handling of mailbox messages.
|
||||
|
|
|
@ -17,22 +17,6 @@
|
|||
|
||||
package haveno.network.p2p.network;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.google.common.util.concurrent.Uninterruptibles;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import haveno.common.Proto;
|
||||
import haveno.common.UserThread;
|
||||
import haveno.common.app.Capabilities;
|
||||
import haveno.common.app.HasCapabilities;
|
||||
import haveno.common.app.Version;
|
||||
import haveno.common.config.Config;
|
||||
import haveno.common.proto.ProtobufferException;
|
||||
import haveno.common.proto.network.NetworkEnvelope;
|
||||
import haveno.common.proto.network.NetworkProtoResolver;
|
||||
import haveno.common.util.SingleThreadExecutorUtils;
|
||||
import haveno.common.util.Utilities;
|
||||
import haveno.network.p2p.BundleOfEnvelopes;
|
||||
import haveno.network.p2p.CloseConnectionMessage;
|
||||
import haveno.network.p2p.ExtendedDataSizePermission;
|
||||
|
@ -46,16 +30,39 @@ import haveno.network.p2p.storage.messages.AddPersistableNetworkPayloadMessage;
|
|||
import haveno.network.p2p.storage.messages.RemoveDataMessage;
|
||||
import haveno.network.p2p.storage.payload.CapabilityRequiringPayload;
|
||||
import haveno.network.p2p.storage.payload.PersistableNetworkPayload;
|
||||
|
||||
import haveno.common.Proto;
|
||||
import haveno.common.UserThread;
|
||||
import haveno.common.app.Capabilities;
|
||||
import haveno.common.app.HasCapabilities;
|
||||
import haveno.common.app.Version;
|
||||
import haveno.common.config.Config;
|
||||
import haveno.common.proto.ProtobufferException;
|
||||
import haveno.common.proto.network.NetworkEnvelope;
|
||||
import haveno.common.proto.network.NetworkProtoResolver;
|
||||
import haveno.common.util.SingleThreadExecutorUtils;
|
||||
import haveno.common.util.Utilities;
|
||||
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.google.common.util.concurrent.Uninterruptibles;
|
||||
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.net.SocketTimeoutException;
|
||||
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InvalidClassException;
|
||||
import java.io.OptionalDataException;
|
||||
import java.io.StreamCorruptedException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.net.SocketTimeoutException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -70,12 +77,17 @@ import java.util.concurrent.ExecutorService;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.stream.Collectors;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Connection is created by the server thread or by sendMessage from NetworkNode.
|
||||
* All handlers are called on User thread.
|
||||
|
|
|
@ -17,25 +17,31 @@
|
|||
|
||||
package haveno.network.p2p.peers;
|
||||
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.name.Named;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import haveno.network.p2p.network.NetworkNode;
|
||||
import haveno.network.p2p.storage.messages.BroadcastMessage;
|
||||
|
||||
import haveno.common.Timer;
|
||||
import haveno.common.UserThread;
|
||||
import haveno.common.config.Config;
|
||||
import haveno.common.util.Utilities;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import haveno.network.p2p.network.NetworkNode;
|
||||
import haveno.network.p2p.storage.messages.BroadcastMessage;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import lombok.Value;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@Slf4j
|
||||
|
|
|
@ -18,9 +18,6 @@
|
|||
package haveno.network.p2p.peers;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.name.Named;
|
||||
import haveno.common.ClockWatcher;
|
||||
import haveno.common.Timer;
|
||||
import haveno.common.UserThread;
|
||||
|
@ -40,6 +37,12 @@ import haveno.network.p2p.network.RuleViolation;
|
|||
import haveno.network.p2p.peers.peerexchange.Peer;
|
||||
import haveno.network.p2p.peers.peerexchange.PeerList;
|
||||
import haveno.network.p2p.seed.SeedNodeRepository;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
|
@ -53,9 +56,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Nullable;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
@Slf4j
|
||||
public final class PeerManager implements ConnectionListener, PersistedDataHost {
|
||||
|
|
|
@ -17,9 +17,6 @@
|
|||
|
||||
package haveno.network.p2p.peers.getdata;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.google.inject.Inject;
|
||||
import haveno.common.Timer;
|
||||
import haveno.common.UserThread;
|
||||
import haveno.common.app.Version;
|
||||
|
@ -35,6 +32,10 @@ import haveno.network.p2p.peers.getdata.messages.GetDataRequest;
|
|||
import haveno.network.p2p.peers.peerexchange.Peer;
|
||||
import haveno.network.p2p.seed.SeedNodeRepository;
|
||||
import haveno.network.p2p.storage.P2PDataStorage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
@ -44,8 +45,9 @@ import java.util.Map;
|
|||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@Slf4j
|
||||
public class RequestDataManager implements MessageListener, ConnectionListener, PeerManager.Listener {
|
||||
|
|
|
@ -20,7 +20,6 @@ package haveno.network.p2p.peers.keepalive;
|
|||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import com.google.common.util.concurrent.SettableFuture;
|
||||
import com.google.inject.Inject;
|
||||
import haveno.common.Timer;
|
||||
import haveno.common.UserThread;
|
||||
import haveno.common.proto.network.NetworkEnvelope;
|
||||
|
@ -34,11 +33,13 @@ import haveno.network.p2p.network.OutboundConnection;
|
|||
import haveno.network.p2p.peers.PeerManager;
|
||||
import haveno.network.p2p.peers.keepalive.messages.Ping;
|
||||
import haveno.network.p2p.peers.keepalive.messages.Pong;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class KeepAliveManager implements MessageListener, ConnectionListener, PeerManager.Listener {
|
||||
private static final Logger log = LoggerFactory.getLogger(KeepAliveManager.class);
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
package haveno.network.p2p.peers.peerexchange;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.inject.Inject;
|
||||
import haveno.common.Timer;
|
||||
import haveno.common.UserThread;
|
||||
import haveno.common.proto.network.NetworkEnvelope;
|
||||
|
@ -31,6 +30,10 @@ import haveno.network.p2p.network.NetworkNode;
|
|||
import haveno.network.p2p.peers.PeerManager;
|
||||
import haveno.network.p2p.peers.peerexchange.messages.GetPeersRequest;
|
||||
import haveno.network.p2p.seed.SeedNodeRepository;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
@ -43,8 +46,6 @@ import java.util.Random;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Nullable;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class PeerExchangeManager implements MessageListener, ConnectionListener, PeerManager.Listener {
|
||||
|
|
|
@ -17,26 +17,6 @@
|
|||
|
||||
package haveno.network.p2p.storage;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.name.Named;
|
||||
import com.google.protobuf.ByteString;
|
||||
import haveno.common.Timer;
|
||||
import haveno.common.UserThread;
|
||||
import haveno.common.app.Capabilities;
|
||||
import haveno.common.crypto.CryptoException;
|
||||
import haveno.common.crypto.Hash;
|
||||
import haveno.common.crypto.Sig;
|
||||
import haveno.common.persistence.PersistenceManager;
|
||||
import haveno.common.proto.network.GetDataResponsePriority;
|
||||
import haveno.common.proto.network.NetworkEnvelope;
|
||||
import haveno.common.proto.network.NetworkPayload;
|
||||
import haveno.common.proto.persistable.PersistablePayload;
|
||||
import haveno.common.proto.persistable.PersistedDataHost;
|
||||
import haveno.common.util.Hex;
|
||||
import haveno.common.util.Tuple2;
|
||||
import haveno.common.util.Utilities;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import haveno.network.p2p.network.CloseConnectionReason;
|
||||
import haveno.network.p2p.network.Connection;
|
||||
|
@ -74,9 +54,43 @@ import haveno.network.p2p.storage.persistence.ProtectedDataStoreService;
|
|||
import haveno.network.p2p.storage.persistence.RemovedPayloadsService;
|
||||
import haveno.network.p2p.storage.persistence.ResourceDataStoreService;
|
||||
import haveno.network.p2p.storage.persistence.SequenceNumberMap;
|
||||
|
||||
import haveno.common.Timer;
|
||||
import haveno.common.UserThread;
|
||||
import haveno.common.app.Capabilities;
|
||||
import haveno.common.crypto.CryptoException;
|
||||
import haveno.common.crypto.Hash;
|
||||
import haveno.common.crypto.Sig;
|
||||
import haveno.common.persistence.PersistenceManager;
|
||||
import haveno.common.proto.network.GetDataResponsePriority;
|
||||
import haveno.common.proto.network.NetworkEnvelope;
|
||||
import haveno.common.proto.network.NetworkPayload;
|
||||
import haveno.common.proto.persistable.PersistablePayload;
|
||||
import haveno.common.proto.persistable.PersistedDataHost;
|
||||
import haveno.common.util.Hex;
|
||||
import haveno.common.util.Tuple2;
|
||||
import haveno.common.util.Utilities;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
|
||||
import com.google.inject.name.Named;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import org.fxmisc.easybind.EasyBind;
|
||||
import org.fxmisc.easybind.monadic.MonadicBinding;
|
||||
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
|
||||
import java.security.KeyPair;
|
||||
import java.security.PublicKey;
|
||||
|
||||
import java.time.Clock;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
@ -97,16 +111,14 @@ import java.util.concurrent.atomic.AtomicLong;
|
|||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.fxmisc.easybind.EasyBind;
|
||||
import org.fxmisc.easybind.monadic.MonadicBinding;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@Slf4j
|
||||
public class P2PDataStorage implements MessageListener, ConnectionListener, PersistedDataHost {
|
||||
|
@ -235,7 +247,7 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
|
|||
appendOnlyDataStoreService.readFromResourcesSync(postFix);
|
||||
protectedDataStoreService.readFromResourcesSync(postFix);
|
||||
resourceDataStoreService.readFromResourcesSync(postFix);
|
||||
|
||||
|
||||
map.putAll(protectedDataStoreService.getMap());
|
||||
}
|
||||
}
|
||||
|
@ -819,9 +831,9 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
|
|||
synchronized (map) {
|
||||
ProtectedStoragePayload protectedStoragePayload = protectedStorageEntry.getProtectedStoragePayload();
|
||||
ByteArray hashOfPayload = get32ByteHashAsByteArray(protectedStoragePayload);
|
||||
|
||||
|
||||
//log.trace("## call addProtectedStorageEntry hash={}, map={}", hashOfPayload, printMap());
|
||||
|
||||
|
||||
// We do that check early as it is a very common case for returning, so we return early
|
||||
// If we have seen a more recent operation for this payload and we have a payload locally, ignore it
|
||||
ProtectedStorageEntry storedEntry = map.get(hashOfPayload);
|
||||
|
@ -829,13 +841,13 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
|
|||
log.trace("## hasSequenceNrIncreased is false. hash={}", hashOfPayload);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (hasAlreadyRemovedAddOncePayload(protectedStoragePayload, hashOfPayload)) {
|
||||
log.trace("## We have already removed that AddOncePayload by a previous removeDataMessage. " +
|
||||
"We ignore that message. ProtectedStoragePayload: {}", protectedStoragePayload.toString());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// To avoid that expired data get stored and broadcast we check for expire date.
|
||||
if (protectedStorageEntry.isExpired(clock)) {
|
||||
String peer = sender != null ? sender.getFullAddress() : "sender is null";
|
||||
|
@ -843,7 +855,7 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
|
|||
peer, protectedStorageEntry.getProtectedStoragePayload().getClass().getSimpleName());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// We want to allow add operations for equal sequence numbers if we don't have the payload locally. This is
|
||||
// the case for non-persistent Payloads that need to be reconstructed from peer and seed nodes each startup.
|
||||
MapValue sequenceNumberMapValue = sequenceNumberMap.get(hashOfPayload);
|
||||
|
@ -852,36 +864,36 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
|
|||
log.trace("## sequenceNr too low hash={}", hashOfPayload);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Verify the ProtectedStorageEntry is well formed and valid for the add operation
|
||||
if (!protectedStorageEntry.isValidForAddOperation()) {
|
||||
log.trace("## !isValidForAddOperation hash={}", hashOfPayload);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// If we have already seen an Entry with the same hash, verify the metadata is equal
|
||||
if (storedEntry != null && !protectedStorageEntry.matchesRelevantPubKey(storedEntry)) {
|
||||
log.trace("## !matchesRelevantPubKey hash={}", hashOfPayload);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Test against filterPredicate set from FilterManager
|
||||
if (filterPredicate != null &&
|
||||
!filterPredicate.test(protectedStorageEntry.getProtectedStoragePayload())) {
|
||||
log.debug("filterPredicate test failed. hashOfPayload={}", hashOfPayload);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// This is an updated entry. Record it and signal listeners.
|
||||
map.put(hashOfPayload, protectedStorageEntry);
|
||||
hashMapChangedListeners.forEach(e -> e.onAdded(Collections.singletonList(protectedStorageEntry)));
|
||||
|
||||
|
||||
// Record the updated sequence number and persist it. Higher delay so we can batch more items.
|
||||
sequenceNumberMap.put(hashOfPayload, new MapValue(protectedStorageEntry.getSequenceNumber(), this.clock.millis()));
|
||||
requestPersistence();
|
||||
|
||||
|
||||
//log.trace("## ProtectedStorageEntry added to map. hash={}, map={}", hashOfPayload, printMap());
|
||||
|
||||
|
||||
// Optionally, broadcast the add/update depending on the calling environment
|
||||
if (allowBroadcast) {
|
||||
broadcaster.broadcast(new AddDataMessage(protectedStorageEntry), sender, listener);
|
||||
|
@ -890,7 +902,7 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
|
|||
// Persist ProtectedStorageEntries carrying PersistablePayload payloads
|
||||
if (protectedStoragePayload instanceof PersistablePayload)
|
||||
protectedDataStoreService.put(hashOfPayload, protectedStorageEntry);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -939,13 +951,13 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
|
|||
try {
|
||||
ByteArray hashOfPayload = new ByteArray(refreshTTLMessage.getHashOfPayload());
|
||||
ProtectedStorageEntry storedData = map.get(hashOfPayload);
|
||||
|
||||
|
||||
if (storedData == null) {
|
||||
log.debug("We don't have data for that refresh message in our map. That is expected if we missed the data publishing.");
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
ProtectedStorageEntry storedEntry = map.get(hashOfPayload);
|
||||
ProtectedStorageEntry updatedEntry = new ProtectedStorageEntry(
|
||||
storedEntry.getProtectedStoragePayload(),
|
||||
|
@ -953,26 +965,26 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
|
|||
refreshTTLMessage.getSequenceNumber(),
|
||||
refreshTTLMessage.getSignature(),
|
||||
this.clock);
|
||||
|
||||
|
||||
|
||||
|
||||
// If we have seen a more recent operation for this payload, we ignore the current one
|
||||
if (!hasSequenceNrIncreased(updatedEntry.getSequenceNumber(), hashOfPayload))
|
||||
return false;
|
||||
|
||||
|
||||
// Verify the updated ProtectedStorageEntry is well formed and valid for update
|
||||
if (!updatedEntry.isValidForAddOperation())
|
||||
return false;
|
||||
|
||||
|
||||
// Update the hash map with the updated entry
|
||||
map.put(hashOfPayload, updatedEntry);
|
||||
|
||||
|
||||
// Record the latest sequence number and persist it
|
||||
sequenceNumberMap.put(hashOfPayload, new MapValue(updatedEntry.getSequenceNumber(), this.clock.millis()));
|
||||
requestPersistence();
|
||||
|
||||
|
||||
// Always broadcast refreshes
|
||||
broadcaster.broadcast(refreshTTLMessage, sender);
|
||||
|
||||
|
||||
} catch (IllegalArgumentException e) {
|
||||
log.error("refreshTTL failed, missing data: {}", e.toString());
|
||||
e.printStackTrace();
|
||||
|
@ -995,29 +1007,29 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
|
|||
synchronized (map) {
|
||||
ProtectedStoragePayload protectedStoragePayload = protectedStorageEntry.getProtectedStoragePayload();
|
||||
ByteArray hashOfPayload = get32ByteHashAsByteArray(protectedStoragePayload);
|
||||
|
||||
|
||||
// If we have seen a more recent operation for this payload, ignore this one
|
||||
if (!hasSequenceNrIncreased(protectedStorageEntry.getSequenceNumber(), hashOfPayload))
|
||||
return false;
|
||||
|
||||
|
||||
// Verify the ProtectedStorageEntry is well formed and valid for the remove operation
|
||||
if (!protectedStorageEntry.isValidForRemoveOperation())
|
||||
return false;
|
||||
|
||||
|
||||
// If we have already seen an Entry with the same hash, verify the metadata is the same
|
||||
ProtectedStorageEntry storedEntry = map.get(hashOfPayload);
|
||||
if (storedEntry != null && !protectedStorageEntry.matchesRelevantPubKey(storedEntry))
|
||||
return false;
|
||||
|
||||
|
||||
// Record the latest sequence number and persist it
|
||||
sequenceNumberMap.put(hashOfPayload, new MapValue(protectedStorageEntry.getSequenceNumber(), this.clock.millis()));
|
||||
requestPersistence();
|
||||
|
||||
|
||||
// Update that we have seen this AddOncePayload so the next time it is seen it fails verification
|
||||
if (protectedStoragePayload instanceof AddOncePayload) {
|
||||
removedPayloadsService.addHash(hashOfPayload);
|
||||
}
|
||||
|
||||
|
||||
if (storedEntry != null) {
|
||||
// Valid remove entry, do the remove and signal listeners
|
||||
removeFromMapAndDataStore(protectedStorageEntry, hashOfPayload);
|
||||
|
@ -1027,13 +1039,13 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
|
|||
// broadcast the remove to peers so they can update their state appropriately
|
||||
} */
|
||||
printData("after remove");
|
||||
|
||||
|
||||
if (protectedStorageEntry instanceof ProtectedMailboxStorageEntry) {
|
||||
broadcaster.broadcast(new RemoveMailboxDataMessage((ProtectedMailboxStorageEntry) protectedStorageEntry), sender);
|
||||
} else {
|
||||
broadcaster.broadcast(new RemoveDataMessage(protectedStorageEntry), sender);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,18 +18,21 @@
|
|||
package haveno.network.p2p.storage.persistence;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.inject.Inject;
|
||||
import haveno.network.p2p.storage.P2PDataStorage;
|
||||
import haveno.network.p2p.storage.payload.PersistableNetworkPayload;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Used for PersistableNetworkPayload data which gets appended to a map storage.
|
||||
|
|
|
@ -18,17 +18,18 @@
|
|||
package haveno.network.p2p.storage.persistence;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.inject.Inject;
|
||||
import haveno.common.proto.persistable.PersistableEnvelope;
|
||||
import haveno.network.p2p.storage.P2PDataStorage;
|
||||
import haveno.network.p2p.storage.payload.ProtectedStorageEntry;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Used for data which can be added and removed. ProtectedStorageEntry is used for verifying ownership.
|
||||
|
|
|
@ -17,14 +17,15 @@
|
|||
|
||||
package haveno.network.p2p.storage.persistence;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import haveno.common.persistence.PersistenceManager;
|
||||
import haveno.common.proto.persistable.PersistedDataHost;
|
||||
import haveno.network.p2p.storage.P2PDataStorage;
|
||||
import haveno.network.p2p.storage.payload.MailboxStoragePayload;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
* We persist the hashes and timestamp when a AddOncePayload payload got removed. This protects that it could be
|
||||
* added again for instance if the sequence number map would be inconsistent/deleted or when we receive data from
|
||||
|
|
|
@ -18,12 +18,13 @@
|
|||
package haveno.network.p2p.storage.persistence;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.inject.Inject;
|
||||
import haveno.common.proto.persistable.PersistableEnvelope;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Used for handling data from resource files.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue