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:
parent
ebfd7e4147
commit
7f30e20170
@ -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");
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user