我和网络世界中许多无望的浪漫主义者一样,相信我可以成功地挖掘硬币。问题是,我无法使基本算法正确地从先前的矿块获取数据并为下一个采矿块创建哈希。我从几篇文章中了解到,我们从块的当前哈希开始,反向并附加merkel根,添加nonce,然后获取该字符串的SHA256哈希值。
static void Main(string[] args)
{
//get the hash of the current block
string currentHash =
@"000000000000000000c5c04011f9a3fb5f46064fed7e06dcdae69024ed6484c1";
//get the merkel root
string merkel =
@"f73a382814c51cbc5a59ab9817ac54c63decb7b3dac5b049df5213c029162bdf";
//reverese the merkel root
char[] c = merkel.ToCharArray();
Array.Reverse(c);
merkel = new string(c);
//get a hash object that returns SHA256
Hash hash = new Hash();
//get the nonce that mined the block
uint nonce = 3546041956;
//string together current hash, merkel root and the hex of the nonce
string stringTotal = currentHash + merkel + nonce.ToString("x2");
//calculate the SHA256 hash of the
string nextHash = hash.GetHash(stringTotal);
Console.WriteLine(nextHash);
Console.ReadKey();
}
有人知道正确的算法吗?我使用了这个块https://blockchain.info/block-height/477065并尝试计算下一个块的哈希值。
答案 0 :(得分:0)
所以我对同样的事感到好奇。这就是我提出的。它显然不是生产质量,但它得到了整个想法并且似乎有效。
如果它不是反向和交换逻辑,实际上没有记录我所看到的一切,那可能会容易得多。
无论如何,希望这会有所帮助。如果您有兴趣,我在这里找到了一堆帮助:http://trogers.net/2018/01/29/how-to-validate-a-bitcoin-blocks-proof-of-work-c/
const jsonArray = [
{
"name": "PATCHING-vhdb",
"ctm": "controlm-server",
"available": "1",
"max": 1,
"workloadPolicy": "N/A"
},
{
"name": "PATCHING-vhi",
"ctm": "controlm-server",
"available": "0",
"max": 0,
"workloadPolicy": "N/A"
},
{
"name": "PATCHING-vhr",
"ctm": "controlm-server",
"available": "1",
"max": 1,
"workloadPolicy": "N/A"
},
{
"name": "PATCHING-vhs",
"ctm": "controlm-server",
"available": "1",
"max": 1,
"workloadPolicy": "N/A"
}
]
const filteredArray = jsonArray.filter( el => el["max"] === 0 );
console.log(filteredArray);