Skip to content

Commit

Permalink
Save coinbase, not just extraNonce
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-jr committed Sep 6, 2011
1 parent b760e25 commit 49c8e53
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,8 @@ Value getwork(const Array& params, bool fHelp)
if (IsInitialBlockDownload())
throw JSONRPCError(-10, "Bitcoin is downloading blocks...");

static map<uint256, pair<CBlock*, unsigned int> > mapNewBlock;
typedef map<uint256, pair<CBlock*, CScript> > mapNewBlock_t;
static mapNewBlock_t mapNewBlock;
static vector<CBlock*> vNewBlock;
static CReserveKey reservekey(pwalletMain);

Expand Down Expand Up @@ -1624,7 +1625,7 @@ Value getwork(const Array& params, bool fHelp)
pblock->nNonce = 0;

// Save
mapNewBlock[pblock->hashMerkleRoot] = make_pair(pblock, nExtraNonce);
mapNewBlock[pblock->hashMerkleRoot] = make_pair(pblock, pblock->vtx[0].vin[0].scriptSig);

// Prebuild hash buffers
char pmidstate[32];
Expand Down Expand Up @@ -1657,11 +1658,10 @@ Value getwork(const Array& params, bool fHelp)
if (!mapNewBlock.count(pdata->hashMerkleRoot))
return false;
CBlock* pblock = mapNewBlock[pdata->hashMerkleRoot].first;
unsigned int nExtraNonce = mapNewBlock[pdata->hashMerkleRoot].second;

pblock->nTime = pdata->nTime;
pblock->nNonce = pdata->nNonce;
pblock->vtx[0].vin[0].scriptSig = CScript() << pblock->nBits << CBigNum(nExtraNonce);
pblock->vtx[0].vin[0].scriptSig = mapNewBlock[pdata->hashMerkleRoot].second;
pblock->hashMerkleRoot = pblock->BuildMerkleTree();

return CheckWork(pblock, *pwalletMain, reservekey);
Expand Down

0 comments on commit 49c8e53

Please sign in to comment.