c# pow implementation work
This commit is contained in:
parent
60c1ec07e9
commit
499981ed52
@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using onionrpow;
|
||||
|
||||
@ -9,8 +11,18 @@ namespace onionrpow_cli
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello World!");
|
||||
onionrpow.OnionrPow.compute(Encoding.UTF8.GetBytes("test"), 4);
|
||||
|
||||
using (Stream stdin = Console.OpenStandardInput())
|
||||
{
|
||||
var data = new List<byte>();
|
||||
byte[] buffer = new byte[60000];
|
||||
int bytes;
|
||||
while ((bytes = stdin.Read(buffer, 0, buffer.Length)) > 0) {
|
||||
//stdout.Write(buffer, 0, bytes);
|
||||
data.AddRange(buffer);
|
||||
}
|
||||
onionrpow.OnionrPow.compute(data.ToArray(), 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ namespace onionrpow
|
||||
public static void compute(byte[] data, int difficulty){
|
||||
using (var shaAlg = SHA3.Net.Sha3.Sha3256())
|
||||
{
|
||||
// Replace beginning json with nonce
|
||||
// Replace beginning json with counter
|
||||
int counter = 0;
|
||||
var copy = new List<byte>();
|
||||
|
||||
@ -25,12 +25,12 @@ namespace onionrpow
|
||||
copy.Add(co);
|
||||
}
|
||||
int c = 0;
|
||||
var copy2 = new List<byte>();
|
||||
while (true){
|
||||
toploop:
|
||||
c += 1;
|
||||
var num = Encoding.UTF8.GetBytes("{\"pow\": " + c.ToString() + ",");
|
||||
var copy2 = new List<byte>();
|
||||
|
||||
copy2.Clear();
|
||||
copy2.AddRange(num);
|
||||
copy2.AddRange(copy);
|
||||
var hash = shaAlg.ComputeHash(copy2.ToArray());
|
||||
@ -45,7 +45,9 @@ namespace onionrpow
|
||||
break;
|
||||
}
|
||||
}
|
||||
Console.WriteLine(Encoding.UTF8.GetString(copy2.ToArray()));
|
||||
Console.WriteLine(BitConverter.ToString(hash));
|
||||
Console.WriteLine(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
12
scripts/testblock.py
Executable file
12
scripts/testblock.py
Executable file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import os
|
||||
if not os.path.exists('onionr.sh'):
|
||||
os.chdir('../')
|
||||
sys.path.append("src/")
|
||||
import onionrblocks
|
||||
|
||||
expire = 600
|
||||
print(onionrblocks.insert(data=os.urandom(32), expire=expire))
|
||||
|
@ -113,7 +113,7 @@ class SubprocessPOW:
|
||||
nonce = 0
|
||||
data = self.data
|
||||
metadata = self.metadata
|
||||
metadata['nonce'] = secrets.randbits(16)
|
||||
metadata['n'] = secrets.randbits(16)
|
||||
puzzle = self.puzzle
|
||||
difficulty = self.difficulty
|
||||
|
||||
|
@ -14,8 +14,8 @@
|
||||
"hide_created_blocks": true,
|
||||
"insert_deniable_blocks": true,
|
||||
"max_block_age": 2678400,
|
||||
"minimum_block_pow": 5,
|
||||
"minimum_send_pow": 5,
|
||||
"minimum_block_pow": 6,
|
||||
"minimum_send_pow": 6,
|
||||
"public_key": "",
|
||||
"random_bind_ip": true,
|
||||
"security_level": 0,
|
||||
|
Loading…
Reference in New Issue
Block a user