mirror of
https://github.com/jwinterm/myriadcoin.git
synced 2026-10-17 05:41:34 +02:00
88 lines
2.3 KiB
C++
88 lines
2.3 KiB
C++
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
|
// Copyright (c) 2009-2014 The Bitcoin developers
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#include "primitives/pureheader.h"
|
|
|
|
#include "chainparams.h"
|
|
#include "crypto/hashgroestl.h"
|
|
#include "crypto/hashqubit.h"
|
|
#include "crypto/hashskein.h"
|
|
#include "crypto/scrypt.h"
|
|
#include "crypto/yescrypt.h"
|
|
#include "hash.h"
|
|
#include "utilstrencodings.h"
|
|
|
|
uint256 CPureBlockHeader::GetHash() const
|
|
{
|
|
return SerializeHash(*this);
|
|
}
|
|
|
|
uint256 CPureBlockHeader::GetPoWHash(int algo) const
|
|
{
|
|
switch(algo)
|
|
{
|
|
case ALGO_SHA256D:
|
|
return GetHash();
|
|
case ALGO_SCRYPT:
|
|
{
|
|
uint256 thash;
|
|
scrypt_1024_1_1_256(BEGIN(nVersion), BEGIN(thash));
|
|
return thash;
|
|
}
|
|
case ALGO_GROESTL:
|
|
return HashGroestl(BEGIN(nVersion), END(nNonce));
|
|
case ALGO_SKEIN:
|
|
return HashSkein(BEGIN(nVersion), END(nNonce));
|
|
case ALGO_QUBIT:
|
|
return HashQubit(BEGIN(nVersion), END(nNonce));
|
|
case ALGO_YESCRYPT:
|
|
{
|
|
uint256 thash;
|
|
yescrypt_hash(BEGIN(nVersion), BEGIN(thash));
|
|
return thash;
|
|
}
|
|
}
|
|
return GetHash();
|
|
}
|
|
|
|
int GetAlgo(int nVersion)
|
|
{
|
|
switch (nVersion & BLOCK_VERSION_ALGO)
|
|
{
|
|
case 0:
|
|
return ALGO_SHA256D;
|
|
case BLOCK_VERSION_SCRYPT:
|
|
return ALGO_SCRYPT;
|
|
case BLOCK_VERSION_GROESTL:
|
|
return ALGO_GROESTL;
|
|
case BLOCK_VERSION_SKEIN:
|
|
return ALGO_SKEIN;
|
|
case BLOCK_VERSION_QUBIT:
|
|
return ALGO_QUBIT;
|
|
case BLOCK_VERSION_YESCRYPT:
|
|
return ALGO_YESCRYPT;
|
|
}
|
|
return ALGO_SHA256D;
|
|
}
|
|
|
|
std::string GetAlgoName(int Algo)
|
|
{
|
|
switch (Algo)
|
|
{
|
|
case ALGO_SHA256D:
|
|
return std::string("sha256d");
|
|
case ALGO_SCRYPT:
|
|
return std::string("scrypt");
|
|
case ALGO_GROESTL:
|
|
return std::string("groestl");
|
|
case ALGO_SKEIN:
|
|
return std::string("skein");
|
|
case ALGO_QUBIT:
|
|
return std::string("qubit");
|
|
case ALGO_YESCRYPT:
|
|
return std::string("yescrypt");
|
|
}
|
|
return std::string("unknown");
|
|
} |