mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +01:00
We do not need to lookup in getSignedWitnessMapValues
anymore as we maintain the signedWitnessSetByAccountAgeWitnessHash at each add/remove operation.
This commit is contained in:
parent
b6a01d0ac7
commit
aea904d24f
1 changed files with 3 additions and 16 deletions
|
@ -353,22 +353,9 @@ public class SignedWitnessService {
|
|||
}
|
||||
}
|
||||
|
||||
private Set<SignedWitness> getSignedWitnessSet(AccountAgeWitness accountAgeWitness) {
|
||||
byte[] accountAgeWitnessHash = accountAgeWitness.getHash();
|
||||
P2PDataStorage.ByteArray key = new P2PDataStorage.ByteArray(accountAgeWitnessHash);
|
||||
// In case we get a new entry added to signedWitnessMap with our hash we remove the entry from the cache so
|
||||
// that we use the updated signedWitnessMap to fill the cache new.
|
||||
if (signedWitnessSetByAccountAgeWitnessHash.containsKey(key)) {
|
||||
return signedWitnessSetByAccountAgeWitnessHash.get(key);
|
||||
}
|
||||
|
||||
Set<SignedWitness> result = getSignedWitnessMapValues().stream()
|
||||
.filter(signedWitness -> Arrays.equals(signedWitness.getAccountAgeWitnessHash(), accountAgeWitnessHash))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
signedWitnessSetByAccountAgeWitnessHash.put(key, result);
|
||||
|
||||
return result;
|
||||
public Set<SignedWitness> getSignedWitnessSet(AccountAgeWitness accountAgeWitness) {
|
||||
P2PDataStorage.ByteArray key = new P2PDataStorage.ByteArray(accountAgeWitness.getHash());
|
||||
return signedWitnessSetByAccountAgeWitnessHash.getOrDefault(key, new HashSet<>());
|
||||
}
|
||||
|
||||
// SignedWitness objects signed by arbitrators
|
||||
|
|
Loading…
Add table
Reference in a new issue