Skip to content

Commit

Permalink
Merge pull request #13 from rsksmart/remove-versiontally
Browse files Browse the repository at this point in the history
Remove version tally
  • Loading branch information
lsebrie authored Apr 11, 2019
2 parents a05e2de + 4bba44c commit be97085
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 29 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>co.rsk.bitcoinj</groupId>
<version>0.14.4-rsk-6</version>
<version>0.14.4-rsk-7</version>

<artifactId>bitcoinj-thin</artifactId>

Expand Down
34 changes: 6 additions & 28 deletions src/main/java/co/rsk/bitcoinj/core/BtcAbstractBlockChain.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@

package co.rsk.bitcoinj.core;

import com.google.common.base.*;
import co.rsk.bitcoinj.store.*;
import co.rsk.bitcoinj.utils.*;
import co.rsk.bitcoinj.store.BlockStoreException;
import co.rsk.bitcoinj.store.BtcBlockStore;
import co.rsk.bitcoinj.wallet.Wallet;
import org.slf4j.*;
import com.google.common.base.Preconditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.*;
import javax.annotation.Nullable;
import java.util.*;

import static com.google.common.base.Preconditions.*;
Expand Down Expand Up @@ -128,8 +129,6 @@ public Boolean hasFilteredBlock() {
private double falsePositiveTrend;
private double previousFalsePositiveRate;

private final VersionTally versionTally;

/** See {@link #BtcAbstractBlockChain(Context, BtcBlockStore)} */
public BtcAbstractBlockChain(NetworkParameters params,
BtcBlockStore blockStore) throws BlockStoreException {
Expand All @@ -145,9 +144,6 @@ public BtcAbstractBlockChain(Context context,
chainHead = blockStore.getChainHead();
log.debug("chain head is at height {}:\n{}", chainHead.getHeight(), chainHead.getHeader());
this.params = context.getParams();

this.versionTally = new VersionTally(context.getParams());
this.versionTally.initialize(blockStore, chainHead);
}

/**
Expand Down Expand Up @@ -381,23 +377,9 @@ private void connectBlock(final BtcBlock block, StoredBlock storedPrev, boolean
if (expensiveChecks && block.getTimeSeconds() <= getMedianTimestampOfRecentBlocks(head, blockStore))
throw new VerificationException("Block's timestamp is too early");

// BIP 66 & 65: Enforce block version 3/4 once they are a supermajority of blocks
// NOTE: This requires 1,000 blocks since the last checkpoint (on main
// net, less on test) in order to be applied. It is also limited to
// stopping addition of new v2/3 blocks to the tip of the chain.
if (block.getVersion() == BtcBlock.BLOCK_VERSION_BIP34
|| block.getVersion() == BtcBlock.BLOCK_VERSION_BIP66) {
final Integer count = versionTally.getCountAtOrAbove(block.getVersion() + 1);
if (count != null
&& count >= params.getMajorityRejectBlockOutdated()) {
throw new VerificationException.BlockVersionOutOfDate(block.getVersion());
}
}

// This block connects to the best known block, it is a normal continuation of the system.
StoredBlock newStoredBlock = addToBlockStore(storedPrev,
block.transactions == null ? block : block.cloneAsHeader());
versionTally.add(block.getVersion());
setChainHead(newStoredBlock);
log.debug("Chain is now {} blocks high, running listeners", newStoredBlock.getHeight());
} else {
Expand Down Expand Up @@ -700,8 +682,4 @@ public void resetFalsePositiveEstimate() {
falsePositiveTrend = 0;
previousFalsePositiveRate = 0;
}

protected VersionTally getVersionTally() {
return versionTally;
}
}

0 comments on commit be97085

Please sign in to comment.