From 513eff26f9aaab69f01af6dc5a8c8d3756e9d895 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Fri, 25 Mar 2011 17:28:03 +0000 Subject: [PATCH] Don't serialize the block hash, recalculate on demand using getHash() --- src/com/google/bitcoin/core/Block.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/com/google/bitcoin/core/Block.java b/src/com/google/bitcoin/core/Block.java index 4cf8ce98b..963ea37d8 100644 --- a/src/com/google/bitcoin/core/Block.java +++ b/src/com/google/bitcoin/core/Block.java @@ -52,7 +52,7 @@ public class Block extends Message { /** If null, it means this object holds only the headers. */ List transactions; /** Stores the hash of the block. If null, getHash() will recalculate it. */ - private byte[] hash; + transient private byte[] hash; // If set, points towards the previous block in the chain. Note that a block may have multiple other blocks // pointing back to it because despite being called a "chain", the block chain is in fact a tree. There can be @@ -352,9 +352,6 @@ public class Block extends Message { public boolean equals(Object o) { if (!(o instanceof Block)) return false; Block other = (Block) o; - if (hash != null && other.hash != null) - return Arrays.equals(hash, other.hash); - // Otherwise we have to do it the slow way. return Arrays.equals(getHash(), other.getHash()); }