mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 23:06:39 +01:00
more singletoning
This commit is contained in:
parent
a4e8ec5ebf
commit
3f097ebf63
5 changed files with 13 additions and 5 deletions
|
@ -18,6 +18,7 @@
|
|||
package bisq.common.crypto;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.bouncycastle.openpgp.PGPKeyPair;
|
||||
import org.bouncycastle.openpgp.PGPPublicKey;
|
||||
|
@ -34,6 +35,7 @@ import javax.annotation.Nullable;
|
|||
@Getter
|
||||
@EqualsAndHashCode
|
||||
@Slf4j
|
||||
@Singleton
|
||||
public class KeyRing {
|
||||
private final KeyPair signatureKeyPair;
|
||||
private final KeyPair encryptionKeyPair;
|
||||
|
|
|
@ -22,6 +22,7 @@ import bisq.common.storage.FileUtil;
|
|||
import com.google.inject.Inject;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.bouncycastle.openpgp.PGPKeyPair;
|
||||
|
||||
|
@ -56,6 +57,7 @@ import org.jetbrains.annotations.NotNull;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
// TODO: use a password protection for key storage
|
||||
@Singleton
|
||||
public class KeyStorage {
|
||||
private static final Logger log = LoggerFactory.getLogger(KeyStorage.class);
|
||||
|
||||
|
|
|
@ -41,7 +41,6 @@ import bisq.core.proto.network.CoreNetworkProtoResolver;
|
|||
import bisq.core.proto.persistable.CorePersistenceProtoResolver;
|
||||
import bisq.core.trade.TradeModule;
|
||||
import bisq.core.user.Preferences;
|
||||
import bisq.core.user.User;
|
||||
|
||||
import bisq.network.crypto.EncryptionServiceModule;
|
||||
import bisq.network.p2p.P2PModule;
|
||||
|
@ -51,7 +50,6 @@ import bisq.network.p2p.seed.SeedNodeRepository;
|
|||
import bisq.common.ClockWatcher;
|
||||
import bisq.common.CommonOptionKeys;
|
||||
import bisq.common.app.AppModule;
|
||||
import bisq.common.crypto.KeyRing;
|
||||
import bisq.common.crypto.KeyStorage;
|
||||
import bisq.common.proto.network.NetworkProtoResolver;
|
||||
import bisq.common.proto.persistable.PersistenceProtoResolver;
|
||||
|
@ -77,9 +75,6 @@ public class CoreModule extends AppModule {
|
|||
protected void configure() {
|
||||
bind(BisqEnvironment.class).toInstance((BisqEnvironment) environment);
|
||||
|
||||
bind(KeyStorage.class).in(Singleton.class);
|
||||
bind(KeyRing.class).in(Singleton.class);
|
||||
bind(User.class).in(Singleton.class);
|
||||
bind(ClockWatcher.class).in(Singleton.class);
|
||||
bind(Preferences.class).in(Singleton.class);
|
||||
bind(BridgeAddressProvider.class).to(Preferences.class).in(Singleton.class);
|
||||
|
|
|
@ -34,6 +34,7 @@ import bisq.common.proto.persistable.PersistedDataHost;
|
|||
import bisq.common.storage.Storage;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.ReadOnlyObjectProperty;
|
||||
|
@ -64,6 +65,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
*/
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
@Singleton
|
||||
public class User implements PersistedDataHost {
|
||||
final private Storage<UserPayload> storage;
|
||||
final private KeyRing keyRing;
|
||||
|
|
|
@ -24,9 +24,13 @@ import bisq.core.app.WalletAppSetup;
|
|||
import bisq.core.locale.CurrencyUtil;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.payment.TradeLimits;
|
||||
import bisq.core.user.User;
|
||||
import bisq.core.util.BSFormatter;
|
||||
import bisq.core.util.BsqFormatter;
|
||||
|
||||
import bisq.common.crypto.KeyRing;
|
||||
import bisq.common.crypto.KeyStorage;
|
||||
|
||||
import org.springframework.mock.env.MockPropertySource;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
|
@ -77,6 +81,9 @@ public class GuiceSetupTest {
|
|||
assertSingleton(P2PNetworkSetup.class);
|
||||
assertSingleton(WalletAppSetup.class);
|
||||
assertSingleton(TradeLimits.class);
|
||||
assertSingleton(KeyStorage.class);
|
||||
assertSingleton(KeyRing.class);
|
||||
assertSingleton(User.class);
|
||||
}
|
||||
|
||||
private void assertSingleton(Class type) {
|
||||
|
|
Loading…
Add table
Reference in a new issue