mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-11 07:17:53 +00:00
block creation
This commit is contained in:
parent
97ba3b787c
commit
3cc155526a
19
src/main.cpp
19
src/main.cpp
@ -3929,25 +3929,17 @@ CBlockTemplate* CreateNewBlock(CReserveKey& reservekey)
|
|||||||
|
|
||||||
// Create coinbase tx
|
// Create coinbase tx
|
||||||
CTransaction txNew;
|
CTransaction txNew;
|
||||||
/* [MF]
|
|
||||||
txNew.vin.resize(1);
|
|
||||||
txNew.vin[0].prevout.SetNull();
|
|
||||||
txNew.vout.resize(1);
|
|
||||||
*/
|
|
||||||
txNew.message.clear();
|
txNew.message.clear();
|
||||||
|
|
||||||
/* [MF] Check! add spam */
|
/* [MF] Check! add spam */
|
||||||
CPubKey pubkey;
|
CPubKey pubkey;
|
||||||
if (!reservekey.GetReservedKey(pubkey))
|
if (!reservekey.GetReservedKey(pubkey))
|
||||||
return NULL;
|
return NULL;
|
||||||
txNew.pubKey << pubkey << OP_CHECKSIG;
|
txNew.pubKey << pubkey << OP_CHECKSIG;
|
||||||
|
txNew.nNonce = 0;
|
||||||
// [MF] TODO: fix nNonce
|
// [MF] TODO: fix nNonce
|
||||||
|
|
||||||
// Add our coinbase tx as first transaction
|
// Add our coinbase tx as first transaction
|
||||||
pblock->vtx.push_back(txNew);
|
pblock->vtx.push_back(txNew);
|
||||||
pblocktemplate->vTxFees.push_back(-1); // updated at end
|
|
||||||
pblocktemplate->vTxSigOps.push_back(-1); // updated at end
|
|
||||||
|
|
||||||
// Largest block you're willing to create:
|
// Largest block you're willing to create:
|
||||||
unsigned int nBlockMaxSize = GetArg("-blockmaxsize", MAX_BLOCK_SIZE_GEN/2);
|
unsigned int nBlockMaxSize = GetArg("-blockmaxsize", MAX_BLOCK_SIZE_GEN/2);
|
||||||
@ -4040,11 +4032,10 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int&
|
|||||||
hashPrevBlock = pblock->hashPrevBlock;
|
hashPrevBlock = pblock->hashPrevBlock;
|
||||||
}
|
}
|
||||||
++nExtraNonce;
|
++nExtraNonce;
|
||||||
unsigned int nHeight = pindexPrev->nHeight+1; // Height first in coinbase required for block.version=2
|
pblock->nHeight = pindexPrev->nHeight+1;
|
||||||
/* [MF] Check!
|
/* extra nonce added to spamMessage.pubKey */
|
||||||
pblock->vtx[0].vin[0].scriptSig = (CScript() << nHeight << CBigNum(nExtraNonce)) + COINBASE_FLAGS;
|
pblock->vtx[0].pubKey = (CScript() << CBigNum(nExtraNonce)) + COINBASE_FLAGS;
|
||||||
assert(pblock->vtx[0].vin[0].scriptSig.size() <= 100);
|
assert(pblock->vtx[0].pubKey.size() <= 100);
|
||||||
*/
|
|
||||||
pblock->hashMerkleRoot = pblock->BuildMerkleTree();
|
pblock->hashMerkleRoot = pblock->BuildMerkleTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1236,8 +1236,6 @@ extern CBlockTreeDB *pblocktree;
|
|||||||
struct CBlockTemplate
|
struct CBlockTemplate
|
||||||
{
|
{
|
||||||
CBlock block;
|
CBlock block;
|
||||||
std::vector<int64_t> vTxFees;
|
|
||||||
std::vector<int64_t> vTxSigOps;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ Value getwork(const Array& params, bool fHelp)
|
|||||||
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
|
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
|
||||||
|
|
||||||
// Save
|
// Save
|
||||||
/* [MF]
|
/* [MF] Check!
|
||||||
mapNewBlock[pblock->hashMerkleRoot] = make_pair(pblock, pblock->vtx[0].vin[0].scriptSig);
|
mapNewBlock[pblock->hashMerkleRoot] = make_pair(pblock, pblock->vtx[0].vin[0].scriptSig);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -326,8 +326,6 @@ Value getblocktemplate(const Array& params, bool fHelp)
|
|||||||
entry.push_back(Pair("depends", deps));
|
entry.push_back(Pair("depends", deps));
|
||||||
|
|
||||||
int index_in_template = i - 1;
|
int index_in_template = i - 1;
|
||||||
entry.push_back(Pair("fee", pblocktemplate->vTxFees[index_in_template]));
|
|
||||||
entry.push_back(Pair("sigops", pblocktemplate->vTxSigOps[index_in_template]));
|
|
||||||
|
|
||||||
transactions.push_back(entry);
|
transactions.push_back(entry);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user