3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-30 23:02:15 +00:00

Implement the equals method on StoredBlock and use it.

This commit is contained in:
Mike Hearn 2011-03-24 17:37:40 +00:00
parent ebfd7e4147
commit 7f30e20170
2 changed files with 8 additions and 1 deletions

View File

@ -145,7 +145,7 @@ public class BlockChain {
// Store it.
blockStore.put(newStoredBlock);
// TODO: Break the assumption of object equality here.
if (storedPrev == chainHead) {
if (storedPrev.equals(chainHead)) {
// This block connects to the best known block, it is a normal continuation of the system.
chainHead = newStoredBlock;
LOG("Received new block, chain is now " + chainHead.height + " blocks high");

View File

@ -56,4 +56,11 @@ class StoredBlock {
boolean moreWorkThan(StoredBlock other) {
return chainWork.compareTo(other.chainWork) > 0;
}
@Override
public boolean equals(Object other) {
if (!(other instanceof StoredBlock)) return false;
StoredBlock o = (StoredBlock) other;
return o.header.equals(header) && o.chainWork.equals(chainWork) && o.height == height;
}
}