Skip to content

Commit

Permalink
Remove a couple of unnecessary methods.
Browse files Browse the repository at this point in the history
1. Don't require manually storing current consensus
2. Don't remove a router just because a downloaded descriptor failed to
parse.
  • Loading branch information
brl committed Nov 17, 2013
1 parent d75f433 commit ff02993
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 32 deletions.
2 changes: 0 additions & 2 deletions src/com/subgraph/orchid/Directory.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public interface Directory {
void loadFromStore();
void waitUntilLoaded();
void storeCertificates();
void storeConsensus();

Collection<DirectoryServer> getDirectoryAuthorities();
DirectoryServer getRandomDirectoryAuthority();
Expand All @@ -37,7 +36,6 @@ public interface Directory {
List<Router> getRouterListByNames(List<String> names);
List<Router> getRoutersWithDownloadableDescriptors();
List<Router> getAllRouters();
void markDescriptorInvalid(RouterDescriptor descriptor);

RouterMicrodescriptor getMicrodescriptorFromCache(HexDigest descriptorDigest);
RouterDescriptor getBasicDescriptorFromCache(HexDigest descriptorDigest);
Expand Down
40 changes: 10 additions & 30 deletions src/com/subgraph/orchid/directory/DirectoryImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -278,16 +278,6 @@ public void addRouterDescriptors(List<RouterDescriptor> descriptors) {
needRecalculateMinimumRouterInfo = true;
}

public void storeConsensus() {
if(currentConsensus != null) {
if(currentConsensus.getFlavor() == ConsensusFlavor.MICRODESC) {
store.writeDocument(CacheFile.CONSENSUS_MICRODESC, currentConsensus);
} else {
store.writeDocument(CacheFile.CONSENSUS, currentConsensus);
}
}
}

public synchronized void addConsensusDocument(ConsensusDocument consensus, boolean fromCache) {
if(consensus.equals(currentConsensus))
return;
Expand Down Expand Up @@ -334,14 +324,19 @@ public synchronized void addConsensusDocument(ConsensusDocument consensus, boole
currentConsensus = consensus;

if(!fromCache) {
if(consensus.getFlavor() == ConsensusFlavor.MICRODESC) {
store.writeDocument(CacheFile.CONSENSUS_MICRODESC, consensus);
storeCurrentConsensus();
}
consensusChangedManager.fireEvent(new Event() {});
}

private void storeCurrentConsensus() {
if(currentConsensus != null) {
if(currentConsensus.getFlavor() == ConsensusFlavor.MICRODESC) {
store.writeDocument(CacheFile.CONSENSUS_MICRODESC, currentConsensus);
} else {
store.writeDocument(CacheFile.CONSENSUS, consensus);
store.writeDocument(CacheFile.CONSENSUS, currentConsensus);
}
}

consensusChangedManager.fireEvent(new Event() {});
}

private Descriptor getDescriptorForRouterStatus(RouterStatus rs, boolean isMicrodescriptor) {
Expand Down Expand Up @@ -422,21 +417,6 @@ synchronized public List<Router> getRoutersWithDownloadableDescriptors() {
return routers;
}

synchronized public void markDescriptorInvalid(RouterDescriptor descriptor) {
removeRouterByIdentity(descriptor.getIdentityKey().getFingerprint());
}

private void removeRouterByIdentity(HexDigest identity) {
logger.fine("Removing: "+ identity);
final RouterImpl router = routersByIdentity.remove(identity);
if(router == null)
return;
final RouterImpl routerByName = routersByNickname.get(router.getNickname());
if(routerByName.equals(router))
routersByNickname.remove(router.getNickname());
directoryCaches.remove(router);
}

public ConsensusDocument getCurrentConsensusDocument() {
return currentConsensus;
}
Expand Down

0 comments on commit ff02993

Please sign in to comment.