Change the WatchMempool pool to build statistics about risk analysis. Removes the pay-to-pubkey detection which was in there.

This commit is contained in:
Andreas Schildbach
2014-12-21 18:51:24 +01:00
parent e8e13de4d4
commit 121d2fcb63
2 changed files with 58 additions and 17 deletions

View File

@@ -51,7 +51,7 @@ public class DefaultRiskAnalysis implements RiskAnalysis {
protected final Transaction tx;
protected final List<Transaction> dependencies;
protected final Wallet wallet;
protected final @Nullable Wallet wallet;
private Transaction nonStandard;
protected Transaction nonFinal;
@@ -69,17 +69,20 @@ public class DefaultRiskAnalysis implements RiskAnalysis {
analyzed = true;
Result result = analyzeIsFinal();
if (result != Result.OK)
if (result != null && result != Result.OK)
return result;
return analyzeIsStandard();
}
private Result analyzeIsFinal() {
private @Nullable Result analyzeIsFinal() {
// Transactions we create ourselves are, by definition, not at risk of double spending against us.
if (tx.getConfidence().getSource() == TransactionConfidence.Source.SELF)
return Result.OK;
if (wallet == null)
return null;
final int height = wallet.getLastBlockSeenHeight();
final long time = wallet.getLastBlockSeenTimeSecs();
// If the transaction has a lock time specified in blocks, we consider that if the tx would become final in the
@@ -172,7 +175,7 @@ public class DefaultRiskAnalysis implements RiskAnalysis {
private Result analyzeIsStandard() {
// The IsStandard rules don't apply on testnet, because they're just a safety mechanism and we don't want to
// crush innovation with valueless test coins.
if (!wallet.getNetworkParameters().getId().equals(NetworkParameters.ID_MAINNET))
if (wallet != null && !wallet.getNetworkParameters().getId().equals(NetworkParameters.ID_MAINNET))
return Result.OK;
RuleViolation ruleViolation = isStandard(tx);