BlockStore: remove getParams() from the hierarchy

Nothing in bitcoinj is using this method and applications should not
be getting their `NetworkParameters` from their storage layer.
This commit is contained in:
Sean Gilligan 2023-03-30 18:52:38 -07:00 committed by Andreas Schildbach
parent 99f6860ceb
commit cc901ee863
4 changed files with 0 additions and 25 deletions

View File

@ -17,7 +17,6 @@
package org.bitcoinj.store;
import org.bitcoinj.core.BlockChain;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.base.Sha256Hash;
import org.bitcoinj.core.StoredBlock;
@ -60,10 +59,4 @@ public interface BlockStore {
/** Closes the store. */
void close() throws BlockStoreException;
/**
* Get the {@link NetworkParameters} of this store.
* @return The network params.
*/
NetworkParameters getParams();
}

View File

@ -36,16 +36,13 @@ public class MemoryBlockStore implements BlockStore {
}
};
private StoredBlock chainHead;
private NetworkParameters params;
public MemoryBlockStore(NetworkParameters params) {
// Insert the genesis block.
try {
Block genesisHeader = params.getGenesisBlock().cloneAsHeader();
StoredBlock storedGenesis = new StoredBlock(genesisHeader, genesisHeader.getWork(), 0);
put(storedGenesis);
setChainHead(storedGenesis);
this.params = params;
} catch (BlockStoreException | VerificationException e) {
throw new RuntimeException(e); // Cannot happen.
}
@ -80,9 +77,4 @@ public class MemoryBlockStore implements BlockStore {
public void close() {
blockMap = null;
}
@Override
public NetworkParameters getParams() {
return params;
}
}

View File

@ -411,11 +411,6 @@ public class MemoryFullPrunedBlockStore implements FullPrunedBlockStore {
return false;
}
@Override
public NetworkParameters getParams() {
return params;
}
@Override
public Network network() {
return params.network();

View File

@ -309,11 +309,6 @@ public class SPVBlockStore implements BlockStore {
}
}
@Override
public NetworkParameters getParams() {
return params;
}
protected static final int RECORD_SIZE = 32 /* hash */ + StoredBlock.COMPACT_SERIALIZED_SIZE;
// File format: