Skip to content

Instantly share code, notes, and snippets.

@bitkevin
Forked from dooglus/bootstrap.cpp
Created June 13, 2014 04:21
Show Gist options
  • Save bitkevin/222100da143e10274467 to your computer and use it in GitHub Desktop.
Save bitkevin/222100da143e10274467 to your computer and use it in GitHub Desktop.
// g++ UniversalTimer.o BinaryData.o FileDataPtr.o BtcUtils.o BlockObj.o BlockUtils.o libcryptopp.a -o bootstrap.out -Icryptopp -DUSE_CRYPTOPP -D__STDC_LIMIT_MACROS -lpthread bootstrap.cpp
#include "BlockUtils.h"
int main(void)
{
string btcdir("/home/chris/.bitcoin");
string bootstrap(btcdir + "/" + "bootstrap.dat");
BlockDataManager_FileRefs::GetInstance().SelectNetwork("Main");
BlockDataManager_FileRefs & bdm = BlockDataManager_FileRefs::GetInstance();
BinaryData magic = bdm.getMagicBytes();
ofstream os;
// bdm.SetBlkFileLocation(btcdir, 4, 1); // 4 digit blk0001.dat from 0.7.x
bdm.SetBlkFileLocation(btcdir + "/blocks", 5, 0); // 5 digit blocks/blk00000.dat from 0.8.x
bdm.parseEntireBlockchain();
os.open(bootstrap.c_str(), ios::out | ios::binary);
for (uint32_t i=0; i<=216116; i++) {
BlockHeader * bhp = bdm.getHeaderByHeight(i);
os.write( bhp->serializeWholeBlock(magic, true).toBinStr().c_str(), bhp->getBlockSize()+8);
}
os.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment