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

Resolved warnings #194

Merged
merged 7 commits into from
Jun 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Stratis.Bitcoin.Common/JsonErrors/ErrorResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class ErrorResult : ObjectResult
{
public ErrorResult(int statusCode, ErrorResponse value) : base(value)
{
StatusCode = statusCode;
this.StatusCode = statusCode;
}
}
}
4 changes: 4 additions & 0 deletions Stratis.Bitcoin.Common/Stratis.Bitcoin.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
<TargetFramework>netstandard1.6</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1701;1702;1705;IDE0008;</NoWarn>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see any warnings for CS1701, CS1702, CS1705. Also I don't think they need to be ignored should they show up.

Copy link
Contributor Author

@Neurosploit Neurosploit Jun 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll just leave this here. Removing these from the NoWarn list resulted in close to 8000 warnings. I think it is an issue in the sdk that will be fixed in version 2. dotnet/roslyn#19640

</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="1.1.3" />
Expand Down
2 changes: 1 addition & 1 deletion Stratis.Bitcoin.IntegrationTests/BlockStoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Stratis.Bitcoin.IntegrationTests
public class BlockStoreTests
{

//[Fact]
// [Fact]
public void BlockRepositoryBench()
{
using (var dir = TestDirectory.Create())
Expand Down
42 changes: 21 additions & 21 deletions Stratis.Bitcoin.IntegrationTests/ChainBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ public class ChainBuilder
public ChainBuilder(Network network)
{
Guard.NotNull(network, nameof(network));
_Network = network;
_Chain = new ConcurrentChain(_Network);
MinerKey = new Key();
MinerScriptPubKey = MinerKey.PubKey.Hash.ScriptPubKey;

this._Network = network;
this._Chain = new ConcurrentChain(this._Network);
this.MinerKey = new Key();
this.MinerScriptPubKey = this.MinerKey.PubKey.Hash.ScriptPubKey;
}

public ConcurrentChain Chain
{
get
{
return _Chain;
return this._Chain;
}
}

Expand All @@ -47,24 +47,24 @@ public Transaction Spend(ICoin[] coins, Money amount)
{
TransactionBuilder builder = new TransactionBuilder();
builder.AddCoins(coins);
builder.AddKeys(MinerKey);
builder.Send(MinerScriptPubKey, amount);
builder.AddKeys(this.MinerKey);
builder.Send(this.MinerScriptPubKey, amount);
builder.SendFees(Money.Coins(0.01m));
builder.SetChange(MinerScriptPubKey);
builder.SetChange(this.MinerScriptPubKey);
var tx = builder.BuildTransaction(true);
return tx;
}

public ICoin[] GetSpendableCoins()
{
return _Blocks
return this._Blocks
.Select(b => b.Value)
.SelectMany(b => b.Transactions.Select(t => new
{
Tx = t,
Block = b
}))
.Where(b => !b.Tx.IsCoinBase || (_Chain.Height + 1) - _Chain.GetBlock(b.Block.GetHash()).Height >= 100)
.Where(b => !b.Tx.IsCoinBase || (this._Chain.Height + 1) - this._Chain.GetBlock(b.Block.GetHash()).Height >= 100)
.Select(b => b.Tx)
.SelectMany(b => b.Outputs.AsIndexedOutputs())
.Where(o => o.TxOut.ScriptPubKey == this.MinerScriptPubKey)
Expand All @@ -80,14 +80,14 @@ public void Mine(int blockCount)
{
uint nonce = 0;
Block block = new Block();
block.Header.HashPrevBlock = _Chain.Tip.HashBlock;
block.Header.Bits = block.Header.GetWorkRequired(_Network, _Chain.Tip);
block.Header.UpdateTime(now, _Network, _Chain.Tip);
block.Header.HashPrevBlock = this._Chain.Tip.HashBlock;
block.Header.Bits = block.Header.GetWorkRequired(this._Network, this._Chain.Tip);
block.Header.UpdateTime(now, this._Network, this._Chain.Tip);
var coinbase = new Transaction();
coinbase.AddInput(TxIn.CreateCoinbase(_Chain.Height + 1));
coinbase.AddOutput(new TxOut(_Network.GetReward(_Chain.Height + 1), MinerScriptPubKey));
coinbase.AddInput(TxIn.CreateCoinbase(this._Chain.Height + 1));
coinbase.AddOutput(new TxOut(this._Network.GetReward(this._Chain.Height + 1), this.MinerScriptPubKey));
block.AddTransaction(coinbase);
foreach(var tx in _Transactions)
foreach(var tx in this._Transactions)
{
block.AddTransaction(tx);
}
Expand All @@ -96,21 +96,21 @@ public void Mine(int blockCount)
block.Header.Nonce = ++nonce;
block.Header.CacheHashes();
blocks.Add(block);
_Transactions.Clear();
_Chain.SetTip(block.Header);
this._Transactions.Clear();
this._Chain.SetTip(block.Header);
}

foreach(var b in blocks)
{
_Blocks.Add(b.GetHash(), b);
this._Blocks.Add(b.GetHash(), b);
}
}

internal Dictionary<uint256, Block> _Blocks = new Dictionary<uint256, Block>();
private List<Transaction> _Transactions = new List<Transaction>();
public void Broadcast(Transaction tx)
{
_Transactions.Add(tx);
this._Transactions.Add(tx);
}
}
}
26 changes: 13 additions & 13 deletions Stratis.Bitcoin.IntegrationTests/CoinViewTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class SpendableCoin
public CoinViewTester(CoinView coinView)
{
this.coinView = coinView;
_Hash = coinView.GetBlockHashAsync().Result;
this._Hash = coinView.GetBlockHashAsync().Result;
}

List<UnspentOutputs> _PendingCoins = new List<UnspentOutputs>();
Expand All @@ -28,14 +28,14 @@ public Coin[] CreateCoins(int coinCount)
.Select(t => new TxOut(Money.Zero, new Key()))
.ToArray());
var output = new UnspentOutputs(1, tx);
_PendingCoins.Add(output);
this._PendingCoins.Add(output);
return tx.Outputs.AsCoins().ToArray();
}

public bool Exists(Coin c)
{
var result = coinView.FetchCoinsAsync(new[] { c.Outpoint.Hash }).Result;
if(result.BlockHash != _Hash)
var result = this.coinView.FetchCoinsAsync(new[] { c.Outpoint.Hash }).Result;
if(result.BlockHash != this._Hash)
throw new InvalidOperationException("Unexepected hash");
if(result.UnspentOutputs[0] == null)
return false;
Expand All @@ -44,18 +44,18 @@ public bool Exists(Coin c)

public void Spend(Coin c)
{
var coin = _PendingCoins.FirstOrDefault(u => u.TransactionId == c.Outpoint.Hash);
var coin = this._PendingCoins.FirstOrDefault(u => u.TransactionId == c.Outpoint.Hash);
if(coin == null)
{
var result = coinView.FetchCoinsAsync(new[] { c.Outpoint.Hash }).Result;
if(result.BlockHash != _Hash)
var result = this.coinView.FetchCoinsAsync(new[] { c.Outpoint.Hash }).Result;
if(result.BlockHash != this._Hash)
throw new InvalidOperationException("Unexepected hash");
if(result.UnspentOutputs[0] == null)
throw new InvalidOperationException("Coin unavailable");

if(!result.UnspentOutputs[0].Spend(c.Outpoint.N))
throw new InvalidOperationException("Coin unspendable");
_PendingCoins.Add(result.UnspentOutputs[0]);
this._PendingCoins.Add(result.UnspentOutputs[0]);
}
else
{
Expand All @@ -68,16 +68,16 @@ public void Spend(Coin c)
public uint256 NewBlock()
{
var newHash = new uint256(RandomUtils.GetBytes(32));
coinView.SaveChangesAsync(_PendingCoins, null, _Hash, newHash).Wait();
_PendingCoins.Clear();
_Hash = newHash;
this.coinView.SaveChangesAsync(this._PendingCoins, null, this._Hash, newHash).Wait();
this._PendingCoins.Clear();
this._Hash = newHash;
return newHash;
}

public uint256 Rewind()
{
_Hash = coinView.Rewind().Result;
return _Hash;
this._Hash = this.coinView.Rewind().Result;
return this._Hash;
}
}
}
Loading