Skip to content

Commit

Permalink
Implemented another optimization, algorithms Hash() function doesn't …
Browse files Browse the repository at this point in the history
…require dynamic config parameter anymore.
  • Loading branch information
bonesoul committed Oct 28, 2014
1 parent 0433e47 commit f756002
Show file tree
Hide file tree
Showing 22 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/CoiniumServ/Algorithms/HashAlgorithmBase.cs
Expand Up @@ -46,7 +46,7 @@ public HashAlgorithmBase()
_storage = new List<IPool>(); // initialize the pool storage.
}

public virtual byte[] Hash(byte[] input, dynamic config)
public virtual byte[] Hash(byte[] input)
{
throw new NotImplementedException();
}
Expand Down
3 changes: 1 addition & 2 deletions src/CoiniumServ/Algorithms/IHashAlgorithm.cs
Expand Up @@ -56,9 +56,8 @@ public interface IHashAlgorithm: IRepository<IPool>, IJsonService
/// Hashes the input data.
/// </summary>
/// <param name="input"></param>
/// <param name="config"></param>
/// <returns></returns>
byte[] Hash(byte[] input, dynamic config);
byte[] Hash(byte[] input);

/// <summary>
/// Assigns pools that runs on the algorithm.
Expand Down
2 changes: 1 addition & 1 deletion src/CoiniumServ/Algorithms/Implementations/Blake.cs
Expand Up @@ -39,7 +39,7 @@ public Blake()
Multiplier = (UInt32) Math.Pow(2, 8);
}

public override byte[] Hash(byte[] input, dynamic config)
public override byte[] Hash(byte[] input)
{
return _hasher.ComputeBytes(input).GetBytes();
}
Expand Down
2 changes: 1 addition & 1 deletion src/CoiniumServ/Algorithms/Implementations/Fresh.cs
Expand Up @@ -44,7 +44,7 @@ public Fresh()
Multiplier = 1;
}

public override byte[] Hash(byte[] input, dynamic config)
public override byte[] Hash(byte[] input)
{
var buffer = input;

Expand Down
2 changes: 1 addition & 1 deletion src/CoiniumServ/Algorithms/Implementations/Fugue.cs
Expand Up @@ -39,7 +39,7 @@ public Fugue()
Multiplier = (UInt32)Math.Pow(2, 8);
}

public override byte[] Hash(byte[] input, dynamic config)
public override byte[] Hash(byte[] input)
{
return _hasher.ComputeBytes(input).GetBytes();
}
Expand Down
2 changes: 1 addition & 1 deletion src/CoiniumServ/Algorithms/Implementations/Groestl.cs
Expand Up @@ -39,7 +39,7 @@ public Groestl()
Multiplier = (UInt32)Math.Pow(2, 8);
}

public override byte[] Hash(byte[] input, dynamic config)
public override byte[] Hash(byte[] input)
{
return _hasher.ComputeBytes(input).GetBytes();
}
Expand Down
2 changes: 1 addition & 1 deletion src/CoiniumServ/Algorithms/Implementations/Keccak.cs
Expand Up @@ -39,7 +39,7 @@ public Keccak()
Multiplier = (UInt32)Math.Pow(2, 8);
}

public override byte[] Hash(byte[] input, dynamic config)
public override byte[] Hash(byte[] input)
{
return _hasher.ComputeBytes(input).GetBytes();
}
Expand Down
2 changes: 1 addition & 1 deletion src/CoiniumServ/Algorithms/Implementations/Nist5.cs
Expand Up @@ -46,7 +46,7 @@ public Nist5()
Multiplier = 1;
}

public override byte[] Hash(byte[] input, dynamic config)
public override byte[] Hash(byte[] input)
{
var buffer = input;

Expand Down
2 changes: 1 addition & 1 deletion src/CoiniumServ/Algorithms/Implementations/Qubit.cs
Expand Up @@ -46,7 +46,7 @@ public Qubit()
Multiplier = 1;
}

public override byte[] Hash(byte[] input, dynamic config)
public override byte[] Hash(byte[] input)
{
var buffer = input;

Expand Down
2 changes: 1 addition & 1 deletion src/CoiniumServ/Algorithms/Implementations/Scrypt.cs
Expand Up @@ -55,7 +55,7 @@ public Scrypt()
Multiplier = (UInt32) Math.Pow(2, 16);
}

public override byte[] Hash(byte[] input, dynamic config)
public override byte[] Hash(byte[] input)
{
return SCrypt.ComputeDerivedKey(input, input, _n, _r, _p, null, 32);
}
Expand Down
2 changes: 1 addition & 1 deletion src/CoiniumServ/Algorithms/Implementations/ScryptN.cs
Expand Up @@ -85,7 +85,7 @@ private void InitTimeTable(dynamic table)
}
}

public override byte[] Hash(byte[] input, dynamic config)
public override byte[] Hash(byte[] input)
{
var now = (UInt64)TimeHelpers.NowInUnixTimestamp();

Expand Down
2 changes: 1 addition & 1 deletion src/CoiniumServ/Algorithms/Implementations/ScryptOg.cs
Expand Up @@ -53,7 +53,7 @@ public ScryptOg()
Multiplier = (UInt32)Math.Pow(2, 16);
}

public override byte[] Hash(byte[] input, dynamic config)
public override byte[] Hash(byte[] input)
{
return SCrypt.ComputeDerivedKey(input, input, _n, _r, _p, null, 32);
}
Expand Down
2 changes: 1 addition & 1 deletion src/CoiniumServ/Algorithms/Implementations/Sha1.cs
Expand Up @@ -38,7 +38,7 @@ public Sha1()
Multiplier = 1;
}

public override byte[] Hash(byte[] input, dynamic config)
public override byte[] Hash(byte[] input)
{
return _hasher.ComputeBytes(input).GetBytes();
}
Expand Down
2 changes: 1 addition & 1 deletion src/CoiniumServ/Algorithms/Implementations/Sha256.cs
Expand Up @@ -38,7 +38,7 @@ public Sha256()
Multiplier = 1;
}

public override byte[] Hash(byte[] input, dynamic config)
public override byte[] Hash(byte[] input)
{
return DoubleDigest(input); // coins like bitcoin (sha256d coins) uses double-digest.
}
Expand Down
2 changes: 1 addition & 1 deletion src/CoiniumServ/Algorithms/Implementations/Shavite3.cs
Expand Up @@ -38,7 +38,7 @@ public Shavite3()
Multiplier = 1;
}

public override byte[] Hash(byte[] input, dynamic config)
public override byte[] Hash(byte[] input)
{
return _hasher.ComputeBytes(input).GetBytes();
}
Expand Down
2 changes: 1 addition & 1 deletion src/CoiniumServ/Algorithms/Implementations/Skein.cs
Expand Up @@ -38,7 +38,7 @@ public Skein()
Multiplier = 1;
}

public override byte[] Hash(byte[] input, dynamic config)
public override byte[] Hash(byte[] input)
{
return _hasher.ComputeBytes(input).GetBytes();
}
Expand Down
2 changes: 1 addition & 1 deletion src/CoiniumServ/Algorithms/Implementations/X11.cs
Expand Up @@ -52,7 +52,7 @@ public X11()
Multiplier = 1;
}

public override byte[] Hash(byte[] input, dynamic config)
public override byte[] Hash(byte[] input)
{
var buffer = input;

Expand Down
2 changes: 1 addition & 1 deletion src/CoiniumServ/Algorithms/Implementations/X13.cs
Expand Up @@ -54,7 +54,7 @@ public X13()
Multiplier = 1;
}

public override byte[] Hash(byte[] input, dynamic config)
public override byte[] Hash(byte[] input)
{
var buffer = input;

Expand Down
2 changes: 1 addition & 1 deletion src/CoiniumServ/Algorithms/Implementations/X14.cs
Expand Up @@ -55,7 +55,7 @@ public X14()
Multiplier = 1;
}

public override byte[] Hash(byte[] input, dynamic config)
public override byte[] Hash(byte[] input)
{
var buffer = input;

Expand Down
2 changes: 1 addition & 1 deletion src/CoiniumServ/Algorithms/Implementations/X15.cs
Expand Up @@ -56,7 +56,7 @@ public X15()
Multiplier = 1;
}

public override byte[] Hash(byte[] input, dynamic config)
public override byte[] Hash(byte[] input)
{
var buffer = input;

Expand Down
2 changes: 1 addition & 1 deletion src/CoiniumServ/Algorithms/Implementations/X17.cs
Expand Up @@ -58,7 +58,7 @@ public X17()
Multiplier = 1;
}

public override byte[] Hash(byte[] input, dynamic config)
public override byte[] Hash(byte[] input)
{
var buffer = input;

Expand Down
2 changes: 1 addition & 1 deletion src/CoiniumServ/Shares/Share.cs
Expand Up @@ -128,7 +128,7 @@ public Share(IStratumMiner miner, UInt64 jobId, IJob job, string extraNonce2, st

// create the block headers
HeaderBuffer = Serializers.SerializeHeader(Job, MerkleRoot, NTime, Nonce);
HeaderHash = Job.HashAlgorithm.Hash(HeaderBuffer, miner.Pool.Config.Coin.Extra);
HeaderHash = Job.HashAlgorithm.Hash(HeaderBuffer);
HeaderValue = new BigInteger(HeaderHash);

// calculate the share difficulty
Expand Down

0 comments on commit f756002

Please sign in to comment.