Skip to content

Commit

Permalink
test hash without clear
Browse files Browse the repository at this point in the history
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
  • Loading branch information
matkt committed Oct 22, 2021
1 parent f2e4c54 commit 44e36a8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package org.hyperledger.besu.ethereum.eth.sync.worldstate;

import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.bonsai.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.rlp.RLPOutput;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage.Updater;
Expand Down Expand Up @@ -46,7 +47,12 @@ public Stream<NodeDataRequest> getChildRequests(final WorldStateStorage worldSta

@Override
public Optional<Bytes> getExistingData(final WorldStateStorage worldStateStorage) {
return worldStateStorage.getCode(getHash(), accountHash.orElse(Hash.EMPTY));
return worldStateStorage
.getCode(getHash(), accountHash.orElse(Hash.EMPTY))
.filter(
node ->
!(worldStateStorage instanceof BonsaiWorldStateKeyValueStorage)
|| Hash.hash(node).equals(getHash()));
}

public Optional<Hash> getAccountHash() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ protected void doPersist(final Updater updater) {

@Override
public Optional<Bytes> getExistingData(final WorldStateStorage worldStateStorage) {
return worldStateStorage.getAccountStorageTrieNode(
getAccountHash().orElse(Hash.EMPTY), getLocation().orElse(Hash.EMPTY), getHash());
return worldStateStorage
.getAccountStorageTrieNode(
getAccountHash().orElse(Hash.EMPTY), getLocation().orElse(Hash.EMPTY), getHash())
.filter(
node ->
!(worldStateStorage instanceof BonsaiWorldStateKeyValueStorage)
|| Hash.hash(node).equals(getHash()));
}

@Override
Expand Down

0 comments on commit 44e36a8

Please sign in to comment.