Skip to content

Commit

Permalink
Warning's fix and naming convention changed
Browse files Browse the repository at this point in the history
  • Loading branch information
MsBarber committed Nov 29, 2018
1 parent db5d019 commit 42392ae
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 77 deletions.
30 changes: 15 additions & 15 deletions NBitcoin/Protocol/Payloads/CompactFilterCheckPointPayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ namespace NBitcoin.Protocol
[Payload("cfcheckpt")]
public class CompactFilterCheckPointPayload : Payload, IBitcoinSerializable
{
private byte _filterType = 0;
private uint256 _stopHash = new uint256();
private uint256[] _filterHeaders = { };
private byte _FilterType = 0;
private uint256 _StopHash = new uint256();
private uint256[] _FilterHeaders = { };
private VarInt _FilterHeadersLength = new VarInt(0);
public CompactFilterCheckPointPayload()
{
Expand All @@ -28,8 +28,8 @@ public CompactFilterCheckPointPayload(FilterType filterType, uint256 stopHash, u
throw new ArgumentException(nameof(filterHeaders));

FilterType = filterType;
_stopHash = stopHash;
_filterHeaders = GetHashes(filterHeaders);
_StopHash = stopHash;
_FilterHeaders = GetHashes(filterHeaders);
}

private uint256[] GetHashes(byte[] filterHeaders)
Expand All @@ -52,19 +52,19 @@ private uint256[] GetHashes(byte[] filterHeaders)

public FilterType FilterType
{
get => (FilterType)_filterType;
internal set => _filterType = (byte)value;
get => (FilterType)_FilterType;
internal set => _FilterType = (byte)value;
}
public uint256 StopHash { get => _stopHash; set => _stopHash = value; }
public uint256[] FilterHeaders { get => _filterHeaders; set => _filterHeaders = value; }
public uint256 StopHash { get => _StopHash; set => _StopHash = value; }
public uint256[] FilterHeaders { get => _FilterHeaders; set => _FilterHeaders = value; }
public VarInt FilterHeadersLength { get => _FilterHeadersLength; set => _FilterHeadersLength = value; }

public void ReadWrite(BitcoinStream stream)
public new void ReadWrite(BitcoinStream stream)
{
var length = stream.Inner.Length;

stream.ReadWrite(ref _filterType);
stream.ReadWrite(ref _stopHash);
stream.ReadWrite(ref _FilterType);
stream.ReadWrite(ref _StopHash);
stream.ReadWrite(ref _FilterHeadersLength);

//when serializing(Writing) we have to fill the tempfilterHeaders
Expand All @@ -74,7 +74,7 @@ public void ReadWrite(BitcoinStream stream)
List<byte> _tempfilterHeaders = new List<byte>();
byte[] _tempFilterHeaderBytes = new byte[_FilterHeadersLength.ToLong() * 32]; //Init byte array to hold list after conversion

foreach (var hash in _filterHeaders)
foreach (var hash in _FilterHeaders)
{
foreach (var bytee in hash.ToBytes())
{
Expand All @@ -97,14 +97,14 @@ public void ReadWrite(BitcoinStream stream)
stream.ReadWrite(ref _tempfilterHeaders);

//Convert the byte[] into "readable" uint256 hashes
_filterHeaders = GetHashes(_tempfilterHeaders);
_FilterHeaders = GetHashes(_tempfilterHeaders);
}
}


public override string ToString()
{
return $"cfcheckpt - filter type: {this._filterType}| Stop Hash {this.StopHash}| # of checkpoints: {this._FilterHeadersLength.ToLong()}";
return $"cfcheckpt - filter type: {this._FilterType}| Stop Hash {this.StopHash}| # of checkpoints: {this._FilterHeadersLength.ToLong()}";
}
}
}
46 changes: 23 additions & 23 deletions NBitcoin/Protocol/Payloads/CompactFilterHeadersPayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ namespace NBitcoin.Protocol
[Payload("cfheaders")]
public class CompactFilterHeadersPayload: Payload, IBitcoinSerializable
{
private byte _filterType = 0;
private uint256 _stopHash = new uint256();
private uint256 _previousFilterHeader = new uint256();
private VarInt _filterHashesLength = new VarInt(0);
private uint256[] _filterHashes = { };
private byte _FilterType = 0;
private uint256 _StopHash = new uint256();
private uint256 _PreviousFilterHeader = new uint256();
private VarInt _FilterHashesLength = new VarInt(0);
private uint256[] _FilterHashes = { };

public CompactFilterHeadersPayload(FilterType filterType, uint256 stopHash, uint256 previousFilterHeader, byte[] filterHashes)
{
Expand All @@ -35,34 +35,34 @@ public CompactFilterHeadersPayload(FilterType filterType, uint256 stopHash, uint


FilterType = filterType;
_stopHash = stopHash;
_previousFilterHeader = previousFilterHeader;
_filterHashes = GetHashes(filterHashes);
_StopHash = stopHash;
_PreviousFilterHeader = previousFilterHeader;
_FilterHashes = GetHashes(filterHashes);
}

public CompactFilterHeadersPayload() { }

public FilterType FilterType
{
get => (FilterType)_filterType;
internal set => _filterType = (byte)value;
get => (FilterType)_FilterType;
internal set => _FilterType = (byte)value;
}

public void ReadWrite(BitcoinStream stream)
public new void ReadWrite(BitcoinStream stream)
{
stream.ReadWrite(ref _filterType);
stream.ReadWrite(ref _stopHash);
stream.ReadWrite(ref _previousFilterHeader);
stream.ReadWrite(ref _filterHashesLength);
stream.ReadWrite(ref _FilterType);
stream.ReadWrite(ref _StopHash);
stream.ReadWrite(ref _PreviousFilterHeader);
stream.ReadWrite(ref _FilterHashesLength);
//var _tempfilterHeaders = new byte[_filterHashesLength.ToLong() * 32];

if (stream.Serializing)
{
//turn the uint256[] into a byte array to write back into the bitcoin stream
List<byte> _tempfilterHeaders = new List<byte>();
byte[] _tempFilterHeaderBytes = new byte[_filterHashesLength.ToLong() * 32]; //Init byte array to hold list after conversion
byte[] _tempFilterHeaderBytes = new byte[_FilterHashesLength.ToLong() * 32]; //Init byte array to hold list after conversion

foreach (var hash in _filterHashes)
foreach (var hash in _FilterHashes)
{
foreach (var bytee in hash.ToBytes())
{
Expand All @@ -79,13 +79,13 @@ public void ReadWrite(BitcoinStream stream)
if (!stream.Serializing)
{
//instantiate a byte[] to hold the incoming hashes
var _tempfilterHeaders = new byte[_filterHashesLength.ToLong() * 32];
var _tempfilterHeaders = new byte[_FilterHashesLength.ToLong() * 32];

//Write filters to temp variable
stream.ReadWrite(ref _tempfilterHeaders);

//Convert the byte[] into "readable" uint256 hashes
_filterHashes = GetHashes(_tempfilterHeaders);
_FilterHashes = GetHashes(_tempfilterHeaders);
}
}

Expand All @@ -108,15 +108,15 @@ private uint256[] GetHashes(byte[] filterHeaders)
}


public uint256 StopHash => _stopHash;
public uint256 PreviousFilterHeader => _previousFilterHeader;
public uint256[] FilterHashes => _filterHashes;
public uint256 StopHash => _StopHash;
public uint256 PreviousFilterHeader => _PreviousFilterHeader;
public uint256[] FilterHashes => _FilterHashes;



public override string ToString()
{
return $"Cheaders type: {this.FilterType}| # of headers: {this._filterHashesLength.ToLong()}| Stop Hash: {this.StopHash}| Previous Filter Header Hash: {this.PreviousFilterHeader}";
return $"Cheaders type: {this.FilterType}| # of headers: {this._FilterHashesLength.ToLong()}| Stop Hash: {this.StopHash}| Previous Filter Header Hash: {this.PreviousFilterHeader}";
}
}
}
Expand Down
38 changes: 19 additions & 19 deletions NBitcoin/Protocol/Payloads/CompactFilterPayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,29 @@ namespace NBitcoin.Protocol
[Payload("cfilter")]
public class CompactFilterPayload : Payload
{
private byte _filterType = 0;
private byte[] _filterBytes;
private VarInt _numFilterBytes = new VarInt(0);
private uint256 _blockHash = new uint256();
private byte _FilterType = 0;
private byte[] _FilterBytes;
private VarInt _NumFilterBytes = new VarInt(0);
private uint256 _BlockHash = new uint256();

/// <summary>
/// Gets the Filter type for which headers are requested
/// </summary>
public FilterType FilterType
{
get => (FilterType)_filterType;
internal set => _filterType = (byte)value;
get => (FilterType)_FilterType;
internal set => _FilterType = (byte)value;
}
/// <summary>
/// Gets the serialized compact filter for this block
/// </summary>
public byte[] FilterBytes => _filterBytes;
public byte[] FilterBytes => _FilterBytes;


/// <summary>
/// Gets block hash of the Bitcoin block for which the filter is being returned
/// </summary>
public uint256 BlockHash => _blockHash;
public uint256 BlockHash => _BlockHash;
public CompactFilterPayload(FilterType filterType, uint256 blockhash, byte[] filterBytes)
{
if (filterType != FilterType.Basic /*&& filterType != FilterType.Extended*/) //Extended filters removed
Expand All @@ -53,8 +53,8 @@ public CompactFilterPayload(FilterType filterType, uint256 blockhash, byte[] fil


FilterType = filterType;
_blockHash = blockhash;
_filterBytes = filterBytes;
_BlockHash = blockhash;
_FilterBytes = filterBytes;
}

public CompactFilterPayload()
Expand All @@ -63,26 +63,26 @@ public CompactFilterPayload()

#region IBitcoinSerializable Members

public void ReadWrite(BitcoinStream stream)
public new void ReadWrite(BitcoinStream stream)
{
stream.ReadWrite(ref _filterType);
stream.ReadWrite(ref _blockHash);
stream.ReadWrite(ref _filterBytes);
stream.ReadWrite(ref _FilterType);
stream.ReadWrite(ref _BlockHash);
stream.ReadWrite(ref _FilterBytes);
}

#endregion

public override void ReadWriteCore(BitcoinStream stream)
{
stream.ReadWrite(ref _filterType);
stream.ReadWrite(ref _FilterType);

stream.ReadWrite(ref _blockHash);
stream.ReadWrite(ref _BlockHash);

stream.ReadWrite(ref _numFilterBytes);
stream.ReadWrite(ref _NumFilterBytes);

_filterBytes = new byte[_numFilterBytes.ToLong()];
_FilterBytes = new byte[_NumFilterBytes.ToLong()];

stream.ReadWrite(ref _filterBytes);
stream.ReadWrite(ref _FilterBytes);
}

public override string ToString()
Expand Down
40 changes: 20 additions & 20 deletions NBitcoin/Protocol/Payloads/GetCompactFiltersPayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,25 @@ public enum FilterType : byte
/// </summary>
public abstract class CompactFiltersQueryPayload : Payload
{
private byte _filterType = 0;
private uint _startHeight = 0;
private uint256 _stopHash = new uint256();
private byte _FilterType = 0;
private uint _StartHeight = 0;
private uint256 _StopHash = new uint256();
/// <summary>
/// Gets the Filter type for which headers are requested
/// </summary>
public FilterType FilterType
{
get => (FilterType)_filterType;
internal set => _filterType = (byte)value;
get => (FilterType)_FilterType;
internal set => _FilterType = (byte)value;
}
/// <summary>
/// Gets the height of the first block in the requested range
/// </summary>
public uint StartHeight => _startHeight;
public uint StartHeight => _StartHeight;
/// <summary>
/// Gets the hash of the last block in the requested range
/// </summary>
public uint256 StopHash => _stopHash;
public uint256 StopHash => _StopHash;
protected CompactFiltersQueryPayload(FilterType filterType, uint startHeight, uint256 stopHash)
{
if (filterType != FilterType.Basic /*&& filterType != FilterType.Extended*/) //Extended Filter removed
Expand All @@ -52,18 +52,18 @@ protected CompactFiltersQueryPayload(FilterType filterType, uint startHeight, ui
throw new ArgumentNullException(nameof(stopHash));

FilterType = filterType;
_startHeight = startHeight;
_stopHash = stopHash;
_StartHeight = startHeight;
_StopHash = stopHash;
}

protected CompactFiltersQueryPayload() { }

#region IBitcoinSerializable Members
public override void ReadWriteCore(BitcoinStream stream)
{
stream.ReadWrite(ref _filterType);
stream.ReadWrite(ref _startHeight);
stream.ReadWrite(ref _stopHash);
stream.ReadWrite(ref _FilterType);
stream.ReadWrite(ref _StartHeight);
stream.ReadWrite(ref _StopHash);
}
#endregion
}
Expand Down Expand Up @@ -99,8 +99,8 @@ public GetCompactFilterHeadersPayload() { }
[Payload("getcfcheckpt")]
public class GetCompactFilterCheckPointPayload : Payload
{
private byte _filterType;
private uint256 _stopHash;
private byte _FilterType;
private uint256 _StopHash;

public GetCompactFilterCheckPointPayload(FilterType filterType, uint256 stopHash)
{
Expand All @@ -110,22 +110,22 @@ public GetCompactFilterCheckPointPayload(FilterType filterType, uint256 stopHash
throw new ArgumentNullException(nameof(stopHash));

FilterType = filterType;
_stopHash = stopHash;
_StopHash = stopHash;
}

public GetCompactFilterCheckPointPayload() { }

public override void ReadWriteCore(BitcoinStream stream)
{
stream.ReadWrite(ref _filterType);
stream.ReadWrite(ref _stopHash);
stream.ReadWrite(ref _FilterType);
stream.ReadWrite(ref _StopHash);
}


public FilterType FilterType
{
get => (FilterType)_filterType;
internal set => _filterType = (byte)value;
get => (FilterType)_FilterType;
internal set => _FilterType = (byte)value;
}
/// <summary>
/// Gets the height of the first block in the requested range
Expand All @@ -136,7 +136,7 @@ public FilterType FilterType
/// <summary>
/// Gets the hash of the last block in the requested range
/// </summary>
public uint256 StopHash => _stopHash;
public uint256 StopHash => _StopHash;
}


Expand Down

0 comments on commit 42392ae

Please sign in to comment.