FakeTxBuilder: make BlockPair fields immutable

This commit is contained in:
Sean Gilligan 2023-10-01 16:44:43 -07:00 committed by Andreas Schildbach
parent fea737b39b
commit 04a783282d

View file

@ -262,8 +262,13 @@ public class FakeTxBuilder {
} }
public static class BlockPair { public static class BlockPair {
public StoredBlock storedBlock; public final Block block;
public Block block; public final StoredBlock storedBlock;
public BlockPair(Block block, StoredBlock storedBlock) {
this.storedBlock = storedBlock;
this.block = block;
}
} }
/** Emulates receiving a valid block that builds on top of the chain. */ /** Emulates receiving a valid block that builds on top of the chain. */
@ -291,9 +296,7 @@ public class FakeTxBuilder {
b.addTransaction(tx); b.addTransaction(tx);
} }
b.solve(); b.solve();
BlockPair pair = new BlockPair(); BlockPair pair = new BlockPair(b, previousStoredBlock.build(b));
pair.block = b;
pair.storedBlock = previousStoredBlock.build(b);
blockStore.put(pair.storedBlock); blockStore.put(pair.storedBlock);
blockStore.setChainHead(pair.storedBlock); blockStore.setChainHead(pair.storedBlock);
return pair; return pair;