Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

Commit

Permalink
Merge from Develop
Browse files Browse the repository at this point in the history
Merge from Develop
  • Loading branch information
dangershony authored Mar 8, 2017
2 parents 1541ee0 + d1f0e01 commit 2140095
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 47 deletions.
2 changes: 1 addition & 1 deletion Stratis.Bitcoin.Tests/NodeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ public Block[] Generate(int blockCount, bool includeUnbroadcasted = true, bool b
public bool AddToStratisMempool(Transaction trx)
{
var fullNode = (_Runner as StratisBitcoinRunner).FullNode;
var state = new MemepoolValidationState(true);
var state = new MempoolValidationState(true);

return fullNode.MempoolManager.Validator.AcceptToMemoryPool(state, trx).Result;
}
Expand Down
4 changes: 1 addition & 3 deletions Stratis.Bitcoin.Tests/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
"buildOptions": { "emitEntryPoint": true },
"dependencies": {
"Stratis.Bitcoin": "1.0.0-*",
"NBitcoin": "3.0.2.4",
"NBitcoin": "3.0.2.5",
"xunit": "2.2.0",
"dotnet-test-xunit": "1.0.0-rc2-build10025",

// xunit hack https://github.com/xunit/xunit/issues/1015
"Microsoft.DotNet.InternalAbstractions": "1.0.0"

},

"frameworks": {
Expand Down
2 changes: 1 addition & 1 deletion Stratis.Bitcoin/BlockStore/BlockStoreSignaled.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Stratis.Bitcoin.BlockStore
{
public class BlockStoreSignaled : SignaleObserver<Block>
public class BlockStoreSignaled : SignalObserver<Block>
{
private readonly BlockStoreLoop storeLoop;
private readonly ConcurrentChain chain;
Expand Down
12 changes: 1 addition & 11 deletions Stratis.Bitcoin/FullNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,13 @@ public bool IsInitialBlockDownload()
// return true;
if (this.ConsensusLoop.Tip == null)
return true;
if (this.ConsensusLoop.Tip.ChainWork < MinimumChainWork(this.Args))
if (this.ConsensusLoop.Tip.ChainWork < this.Network.Consensus.MinimumChainWork)
return true;
if (this.ConsensusLoop.Tip.Header.BlockTime.ToUnixTimeSeconds() < (this.DateTimeProvider.GetTime() - this.Args.MaxTipAge))
return true;
return false;
}

private static uint256 MinimumChainWork(NodeArgs args)
{
// TODO: move this to Network.Consensus
if (args.RegTest)
return uint256.Zero;
if (args.Testnet)
return uint256.Parse("0x0000000000000000000000000000000000000000000000198b4def2baa9338d6");
return uint256.Parse("0x0000000000000000000000000000000000000000002cb971dd56d1c583c20f90");
}

List<IDisposable> _Resources = new List<IDisposable>();
public void Start()
{
Expand Down
2 changes: 1 addition & 1 deletion Stratis.Bitcoin/MemoryPool/MempoolBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ private async Task ProcessTxPayloadAsync(Node node, TxPayload transactionPayload
// add to local filter
await this.manager.MempoolScheduler.WriteAsync(() => this.filterInventoryKnown.TryAdd(trxHash, trxHash));

var state = new MemepoolValidationState(true);
var state = new MempoolValidationState(true);
if (!await this.orphans.AlreadyHave(trxHash) && await this.validator.AcceptToMemoryPool(state, trx))
{
await this.validator.SanityCheck();
Expand Down
4 changes: 2 additions & 2 deletions Stratis.Bitcoin/MemoryPool/MempoolErrors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ namespace Stratis.Bitcoin.MemoryPool

public class MempoolErrorException : Exception
{
public MempoolErrorException(MemepoolValidationState state) : base(state.ErrorMessage)
public MempoolErrorException(MempoolValidationState state) : base(state.ErrorMessage)
{
ValidationState = state;
}

public MemepoolValidationState ValidationState
public MempoolValidationState ValidationState
{
get;
private set;
Expand Down
2 changes: 1 addition & 1 deletion Stratis.Bitcoin/MemoryPool/MempoolOrphans.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public async Task ProcessesOrphans(MempoolBehavior behavior, Transaction tx)
// Use a dummy CValidationState so someone can't setup nodes to counter-DoS based on orphan
// resolution (that is, feeding people an invalid transaction based on LegitTxX in order to get
// anyone relaying LegitTxX banned)
MemepoolValidationState stateDummy = new MemepoolValidationState(true);
MempoolValidationState stateDummy = new MempoolValidationState(true);
if (await this.Validator.AcceptToMemoryPool(stateDummy, orphanTx))
{
Logging.Logs.Mempool.LogInformation($"accepted orphan tx {orphanHash}");
Expand Down
2 changes: 1 addition & 1 deletion Stratis.Bitcoin/MemoryPool/MempoolSignaled.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Stratis.Bitcoin.MemoryPool
{
public class MempoolSignaled : SignaleObserver<Block>
public class MempoolSignaled : SignalObserver<Block>
{
private readonly MempoolManager manager;
private readonly ConcurrentChain chain;
Expand Down
18 changes: 9 additions & 9 deletions Stratis.Bitcoin/MemoryPool/MempoolValidationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

namespace Stratis.Bitcoin.MemoryPool
{
public class MemepoolValidationState
public class MempoolValidationState
{
public MemepoolValidationState(bool limitFree) : this(limitFree, false, Money.Zero)
public MempoolValidationState(bool limitFree) : this(limitFree, false, Money.Zero)
{
}

public MemepoolValidationState(bool limitFree, bool overrideMempoolLimit, Money absurdFee)
public MempoolValidationState(bool limitFree, bool overrideMempoolLimit, Money absurdFee)
{
this.LimitFree = limitFree;
this.AbsurdFee = absurdFee;
Expand All @@ -23,28 +23,28 @@ public MemepoolValidationState(bool limitFree, bool overrideMempoolLimit, Money

public string ErrorMessage { get; set; }

public MemepoolValidationState Invalid(MempoolError error)
public MempoolValidationState Invalid(MempoolError error)
{
this.Error = error;
this.IsInvalid = true;
return this;
}

public MemepoolValidationState Invalid(MempoolError error, string errorMessage)
public MempoolValidationState Invalid(MempoolError error, string errorMessage)
{
this.Error = error;
this.IsInvalid = true;
this.ErrorMessage = errorMessage;
return this;
}

public MemepoolValidationState Fail(MempoolError error)
public MempoolValidationState Fail(MempoolError error)
{
this.Error = error;
return this;
}

public MemepoolValidationState Fail(MempoolError error, string errorMessage)
public MempoolValidationState Fail(MempoolError error, string errorMessage)
{
this.Error = error;
this.ErrorMessage = errorMessage;
Expand Down Expand Up @@ -85,7 +85,7 @@ public override string ToString()
/// </summary>
public class MempoolValidationContext
{
public MemepoolValidationState State { get; }
public MempoolValidationState State { get; }

public List<uint256> SetConflicts { get; set; }

Expand Down Expand Up @@ -114,7 +114,7 @@ public class MempoolValidationContext
public Money ModifiedFees { get; set; }
public long SigOpsCost { get; set; }

public MempoolValidationContext(Transaction transaction, MemepoolValidationState state)
public MempoolValidationContext(Transaction transaction, MempoolValidationState state)
{
this.Transaction = transaction;
this.TransactionHash = transaction.GetHash();
Expand Down
6 changes: 3 additions & 3 deletions Stratis.Bitcoin/MemoryPool/MempoolValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public MempoolValidator(TxMempool memPool, AsyncLock mempoolScheduler,
this.PerformanceCounter = new MempoolPerformanceCounter();
}

public async Task<bool> AcceptToMemoryPoolWithTime(MemepoolValidationState state, Transaction tx)
public async Task<bool> AcceptToMemoryPoolWithTime(MempoolValidationState state, Transaction tx)
{
try
{
Expand All @@ -90,13 +90,13 @@ public async Task<bool> AcceptToMemoryPoolWithTime(MemepoolValidationState state
//FlushStateToDisk(stateDummy, FLUSH_STATE_PERIODIC);
}

public Task<bool> AcceptToMemoryPool(MemepoolValidationState state, Transaction tx)
public Task<bool> AcceptToMemoryPool(MempoolValidationState state, Transaction tx)
{
state.AcceptTime = dateTimeProvider.GetTime();
return AcceptToMemoryPoolWithTime(state, tx);
}

private async Task AcceptToMemoryPoolWorker(MemepoolValidationState state, Transaction tx, List<uint256> vHashTxnToUncache)
private async Task AcceptToMemoryPoolWorker(MempoolValidationState state, Transaction tx, List<uint256> vHashTxnToUncache)
{
var context = new MempoolValidationContext(tx, state);

Expand Down
12 changes: 1 addition & 11 deletions Stratis.Bitcoin/Signal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public interface IBroadcast<in T>
void Broadcast(T item);
}

public abstract class SignaleObserver<T> : ObserverBase<T>
public abstract class SignalObserver<T> : ObserverBase<T>
{
protected override void OnErrorCore(Exception error)
{
Expand Down Expand Up @@ -61,15 +61,5 @@ public Signals()

public Signaler<Block> Blocks { get; }
public Signaler<Transaction> Transactions { get; }

public void Signal(Block block)
{
this.Blocks.Broadcast(block);
}

public void Signal(Transaction trx)
{
this.Transactions.Broadcast(trx);
}
}
}
4 changes: 2 additions & 2 deletions Stratis.Bitcoin/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"dependencies": {
"System.Reactive": "3.1.1",
"DBreeze": "1.82.0",
"DBreeze": "1.83.0",
"Microsoft.AspNetCore.Diagnostics": "1.1.0",
"Microsoft.AspNetCore.Hosting": "1.1.0",
"Microsoft.AspNetCore.Mvc.Core": "1.1.1",
Expand All @@ -14,7 +14,7 @@
"Microsoft.Extensions.Logging.Abstractions": "1.1.0",
"Microsoft.Extensions.Logging.Console": "1.1.0",
"Microsoft.Extensions.Logging.Filter": "1.1.0",
"NBitcoin": "3.0.2.4",
"NBitcoin": "3.0.2.5",
"System.Xml.XmlSerializer": "4.3.0",
"Microsoft.Extensions.Caching.Memory": "1.1.0"
},
Expand Down
2 changes: 1 addition & 1 deletion Stratis.BitcoinD/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"Stratis.Bitcoin": "1.0.0-*",
"Microsoft.Extensions.Logging.Abstractions": "1.1.0",
"Microsoft.Extensions.Logging.Console": "1.1.0",
"NBitcoin": "3.0.2.4"
"NBitcoin": "3.0.2.5"
},

"frameworks": {
Expand Down

0 comments on commit 2140095

Please sign in to comment.