Skip to content

Commit

Permalink
Hirocoin: Automatic Checkpointing
Browse files Browse the repository at this point in the history
  • Loading branch information
HiroSatou committed Mar 13, 2014
1 parent 1688b00 commit dd5b8be
Show file tree
Hide file tree
Showing 20 changed files with 812 additions and 48 deletions.
1 change: 1 addition & 0 deletions COPYING
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Copyright (c) 2009-2013 Bitcoin Developers
Copyright (c) 2011-2013 Litecoin Developers
Copyright (c) 2012-2014 Peercoin Developers
Copyright (c) 2014 Hirocoin Developers

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
4 changes: 3 additions & 1 deletion hirocoin-qt.pro
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,9 @@ SOURCES += src/qt/bitcoin.cpp \
src/cubehash.c \
src/shavite.c \
src/echo.c \
src/simd.c
src/simd.c \
src/checkpointsync.cpp


RESOURCES += src/qt/bitcoin.qrc

Expand Down
8 changes: 6 additions & 2 deletions src/bitcoinrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,11 @@ static const CRPCCommand vRPCCommands[] =
{ "getwork", &getwork, true, false, true },
{ "getworkex", &getworkex, true, false, true },
{ "listaccounts", &listaccounts, false, false, true },
{ "makekeypair", &makekeypair, true, false, true },
{ "sendalert", &sendalert, true, false, true },
{ "makekeypair", &makekeypair, true, false, false },
{ "sendalert", &sendalert, true, false, false },
{ "getcheckpoint", &getcheckpoint, true, false, false },
{ "sendcheckpoint", &sendcheckpoint, true, false, false },
{ "enforcecheckpoint", &enforcecheckpoint, true, false, false },
{ "settxfee", &settxfee, false, false, true },
{ "getblocktemplate", &getblocktemplate, true, false, false },
{ "submitblock", &submitblock, false, false, false },
Expand Down Expand Up @@ -1191,6 +1194,7 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector<std::stri
if (strMethod == "importprivkey" && n > 2) ConvertTo<bool>(params[2]);
if (strMethod == "verifychain" && n > 0) ConvertTo<boost::int64_t>(params[0]);
if (strMethod == "verifychain" && n > 1) ConvertTo<boost::int64_t>(params[1]);
if (strMethod == "enforcecheckpoint" && n > 0) ConvertTo<bool>(params[0]);

return params;
}
Expand Down
3 changes: 3 additions & 0 deletions src/bitcoinrpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ extern json_spirit::Value listaddressgroupings(const json_spirit::Array& params,
extern json_spirit::Value listaccounts(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value makekeypair(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value sendalert(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getcheckpoint(const json_spirit::Array& params, bool fHelp); // in checkpointsync.cpp
extern json_spirit::Value sendcheckpoint(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value enforcecheckpoint(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value listsinceblock(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value gettransaction(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value backupwallet(const json_spirit::Array& params, bool fHelp);
Expand Down
12 changes: 9 additions & 3 deletions src/checkpoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ namespace Checkpoints
// + Contains no strange transactions
static MapCheckpoints mapCheckpoints =
boost::assign::map_list_of
( 0, uint256("0x12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2"))
( 0, uint256("0x0000079dbd0ea897d280a549dc6defcab1128982d75468927cdfe86e6b85883b"))
;
static const CCheckpointData data = {
&mapCheckpoints,
1394109961, // * UNIX timestamp of last checkpoint block
1394545186, // * UNIX timestamp of last checkpoint block
0, // * total number of transactions between genesis and last checkpoint
// (the tx=... number in the SetBestChain debug.log lines)
1000.0 // * estimated number of transactions per day after checkpoint
Expand All @@ -51,7 +51,7 @@ namespace Checkpoints
;
static const CCheckpointData dataTestnet = {
&mapCheckpointsTestnet,
1394110031,
1394545201,
0,
100
};
Expand Down Expand Up @@ -135,4 +135,10 @@ namespace Checkpoints
}
return NULL;
}

uint256 GetLatestHardenedCheckpoint()
{
const MapCheckpoints& checkpoints = *Checkpoints().mapCheckpoints;
return (checkpoints.rbegin()->second);
}
}
3 changes: 3 additions & 0 deletions src/checkpoints.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ namespace Checkpoints
// Returns last CBlockIndex* in mapBlockIndex that is a checkpoint
CBlockIndex* GetLastCheckpoint(const std::map<uint256, CBlockIndex*>& mapBlockIndex);

// Returns the block hash of latest hardened checkpoint
uint256 GetLatestHardenedCheckpoint();

double GuessVerificationProgress(CBlockIndex *pindex);
}

Expand Down

0 comments on commit dd5b8be

Please sign in to comment.