Skip to content

Commit

Permalink
Ensure cache is outside of hash verifying storage!
Browse files Browse the repository at this point in the history
Can now log in to remote server in < 2s.
  • Loading branch information
ianopolous committed Sep 4, 2019
1 parent d80cb35 commit d75b881
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/peergos/shared/NetworkAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static CoreNode buildDirectCorenode(HttpPoster poster) {
}

public static ContentAddressedStorage buildLocalDht(HttpPoster apiPoster, boolean isPeergosServer) {
return new CachingStorage(new ContentAddressedStorage.HTTP(apiPoster, isPeergosServer), 1_000, 50 * 1024);
return new ContentAddressedStorage.HTTP(apiPoster, isPeergosServer);
}

@JsMethod
Expand Down Expand Up @@ -180,9 +180,11 @@ private static CompletableFuture<NetworkAccess> build(CoreNode core,
.exceptionally(t -> new Multihash(Multihash.Type.sha2_256, new byte[32]))
.thenApply(nodeId -> {
ContentAddressedStorageProxy proxingDht = new ContentAddressedStorageProxy.HTTP(p2pPoster);
ContentAddressedStorage p2pDht = isPeergosServer ?
ContentAddressedStorage storage = isPeergosServer ?
localDht :
new ContentAddressedStorage.Proxying(localDht, proxingDht, nodeId, core);
HashVerifyingStorage verifyingStorage = new HashVerifyingStorage(storage, isJavascript ? new ScryptJS() : new ScryptJava());
ContentAddressedStorage p2pDht = new CachingStorage(verifyingStorage, 1_000, 50 * 1024);
MutablePointersProxy httpMutable = new HttpMutablePointers(apiPoster, p2pPoster);
MutablePointers p2pMutable =
isPeergosServer ?
Expand Down Expand Up @@ -211,8 +213,7 @@ private static NetworkAccess build(ContentAddressedStorage dht,
boolean isJavascript) {
WriteSynchronizer synchronizer = new WriteSynchronizer(mutable, dht);
MutableTree btree = new MutableTreeImpl(mutable, dht, synchronizer);
HashVerifyingStorage dhtClient = new HashVerifyingStorage(dht, isJavascript ? new ScryptJS() : new ScryptJava());
return new NetworkAccess(coreNode, social, dhtClient, mutable, btree, synchronizer, instanceAdmin, usage, usernames, isJavascript);
return new NetworkAccess(coreNode, social, dht, mutable, btree, synchronizer, instanceAdmin, usage, usernames, isJavascript);
}

public static CompletableFuture<NetworkAccess> buildJava(URL target) {
Expand Down

0 comments on commit d75b881

Please sign in to comment.