mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-14 16:57:57 +00:00
fix genesis block hash
This commit is contained in:
parent
0b753e0ce2
commit
6ff04a0de2
@ -123,12 +123,15 @@ bool AppInit(int argc, char* argv[])
|
|||||||
return fRet;
|
return fRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern void GenesisMiner();
|
||||||
extern void noui_connect();
|
extern void noui_connect();
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
bool fRet = false;
|
bool fRet = false;
|
||||||
fHaveGUI = false;
|
fHaveGUI = false;
|
||||||
|
|
||||||
|
//GenesisMiner();
|
||||||
|
|
||||||
// Connect bitcoind signal handlers
|
// Connect bitcoind signal handlers
|
||||||
noui_connect();
|
noui_connect();
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ public:
|
|||||||
vAlertPubKey = ParseHex("04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284");
|
vAlertPubKey = ParseHex("04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284");
|
||||||
nDefaultPort = 28333;
|
nDefaultPort = 28333;
|
||||||
nRPCPort = 28332;
|
nRPCPort = 28332;
|
||||||
//bnProofOfWorkLimit = CBigNum(~uint256(0) >> 32);
|
|
||||||
bnProofOfWorkLimit = CBigNum(~uint256(0) >> 1);
|
bnProofOfWorkLimit = CBigNum(~uint256(0) >> 1);
|
||||||
nTxBits = 0x207fffff;
|
nTxBits = 0x207fffff;
|
||||||
nSubsidyHalvingInterval = 210000;
|
nSubsidyHalvingInterval = 210000;
|
||||||
@ -45,7 +44,7 @@ public:
|
|||||||
// CTxIn(COutPoint(000000, -1), coinbase 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73)
|
// CTxIn(COutPoint(000000, -1), coinbase 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73)
|
||||||
// CTxOut(nValue=50.00000000, scriptPubKey=0x5F1DF16B2B704C8A578D0B)
|
// CTxOut(nValue=50.00000000, scriptPubKey=0x5F1DF16B2B704C8A578D0B)
|
||||||
// vMerkleTree: 4a5e1e
|
// vMerkleTree: 4a5e1e
|
||||||
const char* pszTimestamp = "The Times 14/Jul/2013 Globo caught bribing Receita Federal employee to rob R$615M tax evasion documents.";
|
const char* pszTimestamp = "The Times 09/Jul/2013 Globo caught bribing Receita Federal employee to rob R$615M worth tax evasion documents.";
|
||||||
CTransaction txNew;
|
CTransaction txNew;
|
||||||
txNew.message = CScript() << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
|
txNew.message = CScript() << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
|
||||||
txNew.nNonce = 0; // spamMessage is not required to show POW to ease "extranonce" support
|
txNew.nNonce = 0; // spamMessage is not required to show POW to ease "extranonce" support
|
||||||
@ -53,16 +52,13 @@ public:
|
|||||||
genesis.hashPrevBlock = 0;
|
genesis.hashPrevBlock = 0;
|
||||||
genesis.hashMerkleRoot = genesis.BuildMerkleTree();
|
genesis.hashMerkleRoot = genesis.BuildMerkleTree();
|
||||||
genesis.nVersion = 1;
|
genesis.nVersion = 1;
|
||||||
genesis.nTime = 1231006505;
|
genesis.nTime = 1373331180;
|
||||||
//genesis.nBits = 0x1d00ffff;
|
//genesis.nBits = 0x1d00ffff;
|
||||||
genesis.nBits = 0x207fffff;
|
genesis.nBits = 0x1d7fffff;
|
||||||
genesis.nNonce = 0;
|
genesis.nNonce = 636561156;
|
||||||
|
|
||||||
hashGenesisBlock = genesis.GetHash();
|
hashGenesisBlock = genesis.GetHash();
|
||||||
printf("hashGenesisBlock %s\n", hashGenesisBlock.ToString().c_str());
|
assert(hashGenesisBlock == uint256("0x000000792bc5674af6fa5c006149d78c47265f7e03d2ca7f5a094b2475ef1328"));
|
||||||
printf("genesis.hashMerkleRoot %s\n", genesis.hashMerkleRoot.ToString().c_str());
|
|
||||||
//assert(hashGenesisBlock == uint256("0xa63d06dc9817b06f16f6ccfbe558400366eb2507825e29667c910decfaadd2b9"));
|
|
||||||
//assert(genesis.hashMerkleRoot == uint256("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
|
|
||||||
|
|
||||||
//vSeeds.push_back(CDNSSeedData("bitcoin.sipa.be", "seed.bitcoin.sipa.be"));
|
//vSeeds.push_back(CDNSSeedData("bitcoin.sipa.be", "seed.bitcoin.sipa.be"));
|
||||||
|
|
||||||
|
94
src/main.cpp
94
src/main.cpp
@ -3398,7 +3398,7 @@ unsigned int static ScanHash_CryptoPP(char* pmidstate, char* pdata, char* phash1
|
|||||||
|
|
||||||
// Return the nonce if the hash has at least some zero bits,
|
// Return the nonce if the hash has at least some zero bits,
|
||||||
// caller will check if it has enough to reach the target
|
// caller will check if it has enough to reach the target
|
||||||
if (((unsigned short*)phash)[14 + 4] == 0)
|
if (((unsigned short*)phash)[14] == 0)
|
||||||
return nNonce;
|
return nNonce;
|
||||||
|
|
||||||
// If nothing found after trying for a while, return -1
|
// If nothing found after trying for a while, return -1
|
||||||
@ -3696,6 +3696,98 @@ bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GenesisMiner()
|
||||||
|
{
|
||||||
|
fPrintToConsole = false;
|
||||||
|
//
|
||||||
|
// Create new block
|
||||||
|
//
|
||||||
|
CBlock block = Params().GenesisBlock();
|
||||||
|
CBlock *pblock = █
|
||||||
|
pblock->nNonce = 0;
|
||||||
|
|
||||||
|
printf("Running GenesisMiner with %"PRIszu" transactions in block (%u bytes)\n", pblock->vtx.size(),
|
||||||
|
::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Pre-build hash buffers
|
||||||
|
//
|
||||||
|
char pmidstatebuf[32+16]; char* pmidstate = alignup<16>(pmidstatebuf);
|
||||||
|
char pdatabuf[128+16]; char* pdata = alignup<16>(pdatabuf);
|
||||||
|
char phash1buf[64+16]; char* phash1 = alignup<16>(phash1buf);
|
||||||
|
|
||||||
|
FormatHashBuffers(pblock, pmidstate, pdata, phash1);
|
||||||
|
|
||||||
|
unsigned int& nBlockNonce = *(unsigned int*)(pdata + 64 + 12 + 4);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Search
|
||||||
|
//
|
||||||
|
uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();
|
||||||
|
uint256 hashbuf[2];
|
||||||
|
uint256& hash = *alignup<16>(hashbuf);
|
||||||
|
loop
|
||||||
|
{
|
||||||
|
unsigned int nHashesDone = 0;
|
||||||
|
unsigned int nNonceFound;
|
||||||
|
// Crypto++ SHA256
|
||||||
|
nNonceFound = ScanHash_CryptoPP(pmidstate, pdata + 64, phash1,
|
||||||
|
(char*)&hash, nHashesDone);
|
||||||
|
|
||||||
|
// Check if something found
|
||||||
|
if (nNonceFound != (unsigned int) -1)
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < sizeof(hash)/4; i++)
|
||||||
|
((unsigned int*)&hash)[i] = ByteReverse(((unsigned int*)&hash)[i]);
|
||||||
|
|
||||||
|
if (hash <= hashTarget)
|
||||||
|
{
|
||||||
|
// Found a solution
|
||||||
|
pblock->nNonce = ByteReverse(nNonceFound);
|
||||||
|
assert(hash == pblock->GetHash());
|
||||||
|
printf("genesishash: %s\n", pblock->GetHash().ToString().c_str());
|
||||||
|
printf("merkle: %s\n", pblock->hashMerkleRoot.ToString().c_str());
|
||||||
|
printf("nonce: %d\n", pblock->nNonce);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Meter hashes/sec
|
||||||
|
static int64 nHashCounter;
|
||||||
|
if (nHPSTimerStart == 0)
|
||||||
|
{
|
||||||
|
nHPSTimerStart = GetTimeMillis();
|
||||||
|
nHashCounter = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
nHashCounter += nHashesDone;
|
||||||
|
if (GetTimeMillis() - nHPSTimerStart > 4000)
|
||||||
|
{
|
||||||
|
static CCriticalSection cs;
|
||||||
|
{
|
||||||
|
LOCK(cs);
|
||||||
|
if (GetTimeMillis() - nHPSTimerStart > 4000)
|
||||||
|
{
|
||||||
|
dHashesPerSec = 1000.0 * nHashCounter / (GetTimeMillis() - nHPSTimerStart);
|
||||||
|
nHPSTimerStart = GetTimeMillis();
|
||||||
|
nHashCounter = 0;
|
||||||
|
static int64 nLogTime;
|
||||||
|
if (GetTime() - nLogTime > 30 * 60)
|
||||||
|
{
|
||||||
|
nLogTime = GetTime();
|
||||||
|
printf("hashmeter %6.0f khash/s\n", dHashesPerSec/1000.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for stop or if block needs to be rebuilt
|
||||||
|
boost::this_thread::interruption_point();
|
||||||
|
if (nBlockNonce >= 0xffff0000)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void static BitcoinMiner(CWallet *pwallet)
|
void static BitcoinMiner(CWallet *pwallet)
|
||||||
{
|
{
|
||||||
printf("BitcoinMiner started\n");
|
printf("BitcoinMiner started\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user