Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
13 changed files
with
217 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -142,7 +142,9 @@ OBJS= \ | ||
obj/bloom.o \ | ||
obj/noui.o \ | ||
obj/leveldb.o \ | ||
obj/txdb.o | ||
obj/txdb.o \ | ||
obj/pulse.o \ | ||
obj/rpcpulse.o | ||
|
||
|
||
ifdef USE_SSE2 | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// Copyright (c) 2014-.... f0o / The Cryptocoin Revival Foundation | ||
// Distributed under the MIT/X11 software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#include "main.h" | ||
#include "pulse.h" | ||
|
||
/* Pulse(int64 value, int64 fee, int nHeight, unsigned int nBits) : int64 >= 0 | ||
Returns value of proposed Block using algoritmic aproaches */ | ||
static int64 Pulse(int64 value, int64 fee, int nHeight, unsigned int nBits) { | ||
return value - GetBlockValue(nHeight, fee, nBits); | ||
} | ||
|
||
/* Pulse(int nHeight) ? true : false | ||
Returns true if nHeight is higher or equal to PULSE_HEIGHT */ | ||
static bool Pulse(int nHeight) { | ||
printf("Checking for Pulse on %u: ",nHeight); | ||
if( PulseI(nHeight) >= 0 ) { | ||
printf("True\n"); | ||
return true; | ||
} | ||
printf("False\n"); | ||
return false; | ||
} | ||
|
||
/* Pulse(CBlockIndex* prevBlock, CBlock* block) ? true : false | ||
Goes close to the top of CBlock::AcceptBlock | ||
Returns true if proposed Block matches constrains */ | ||
static bool Pulse(CBlockIndex* prevBlock, CBlock* block) { | ||
CBlockHeader blockHead = block->GetBlockHeader(); | ||
CBlockIndex blockIndex = CBlockIndex(blockHead); | ||
CCoinsViewCache view(*pcoinsTip, true); | ||
int nHeight = prevBlock->nHeight+1; | ||
int rate = block->GetBlockTime() - prevBlock->GetBlockTime(); | ||
int score = 0; | ||
int i = PulseI(nHeight); | ||
if( PULSE_RATE[i] > 0 && rate > PULSE_RATE[i] ) { | ||
return true; | ||
} else if( PULSE_MIN_RATE[i] > 0 && rate < PULSE_MIN_RATE[i] ) { | ||
return false; | ||
} else { | ||
if( PULSE_MIN_TX[i] > 0 && block->vtx.size() > PULSE_MIN_TX[i] ) { | ||
score++; | ||
} | ||
if( PULSE_MIN_VALUE[i] > 0 || PULSE_MIN_FEE[i] > 0 ) { | ||
int64 value = 0; | ||
int64 fee = 0; | ||
BOOST_FOREACH(const CTransaction& tx, block->vtx) { | ||
if( PULSE_MIN_FEE[i] > 0 && value > 0 ) { | ||
BOOST_FOREACH(const CTxIn txin, tx.vin) | ||
if( !view.HaveCoins(txin.prevout.hash) ) { | ||
return false; | ||
} | ||
fee += tx.GetValueIn(view) - tx.GetValueOut(); | ||
} | ||
value += tx.GetValueOut(); | ||
} | ||
value = Pulse(value, fee, nHeight, blockIndex.nBits); | ||
if( PULSE_FACTOR[i] == true ) { | ||
int64 bvalue = GetBlockValue(nHeight, 0, blockIndex.nBits); | ||
if( PULSE_MIN_VALUE[i] > 0 && value >= (PULSE_MIN_VALUE[i] * bvalue) ) { | ||
score++; | ||
} | ||
if( PULSE_MIN_FEE[i] > 0 && fee >= (PULSE_MIN_FEE[i] * bvalue) ) { | ||
score++; | ||
} | ||
} else { | ||
if( PULSE_MIN_VALUE[i] > 0 && value >= (PULSE_MIN_VALUE[i] * COIN) ) { | ||
score++; | ||
} | ||
if( PULSE_MIN_FEE[i] > 0 && fee >= (PULSE_MIN_FEE[i] * COIN) ) { | ||
score++; | ||
} | ||
} | ||
} | ||
} | ||
if( PULSE_EXPLICIT[i] ) { | ||
score++; | ||
if( PULSE_MIN_TX[i] > 0 ) | ||
score--; | ||
if( PULSE_MIN_VALUE[i] > 0 ) | ||
score--; | ||
if( PULSE_MIN_FEE[i] > 0 ) | ||
score--; | ||
} | ||
if( score > 0 ) | ||
return true; | ||
else | ||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (c) 2014-.... f0o / The Cryptocoin Revival Foundation | ||
// Distributed under the MIT/X11 software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#ifndef PULSE_H | ||
#define PULSE_H 1 | ||
|
||
class CBlock; | ||
class CBlockIndex; | ||
class CCoinsView; | ||
class CCoinsViewCache; | ||
static int64 GetBlockValue(int nHeight, int64 nFees, unsigned int nBits); | ||
extern CCoinsViewCache *pcoinsTip; | ||
|
||
static const int PULSE_HEIGHT[] = { 265000 }; /** Height to start Pulse */ | ||
static const int PULSE_RATE[] = { 120 }; /** Rate to Pulse in seconds */ | ||
static const int PULSE_MIN_RATE[] = { 30 }; /** Rate to Pulse in seconds */ | ||
static const unsigned int PULSE_MIN_TX[] = { 0 }; /** Minimum amount (not value of!) of TX in a block to bypass Pulse-Rate */ | ||
static const int PULSE_MIN_VALUE[] = { 50000 }; /** Minimum value of the TX in a block to bypass Pulse-Rate (without COIN base) */ | ||
static const int PULSE_MIN_FEE[] = { 25 }; /** Minimum value of accumulated fees of the TX in a block to bypass Pulse-Rate (without COIN base) */ | ||
static const bool PULSE_FACTOR[] = { false }; /** Treat Switches as factors of BlockReward */ | ||
static const bool PULSE_EXPLICIT[] = { false }; /** Require all switches to trigger a block */ | ||
|
||
static bool Pulse(int nHeight); | ||
static bool Pulse(CBlockIndex* prevBlock, CBlock* block); | ||
|
||
/* PulseI(int nHeight) ? i : -1 | ||
Returns i or -1 if not found */ | ||
static int PulseI(int nHeight) { | ||
int i = -1; | ||
BOOST_FOREACH(int h, PULSE_HEIGHT) | ||
if( nHeight >= h ) | ||
i++; | ||
return i; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) 2014-.... f0o / The Cryptocoin Revival Foundation | ||
// Distributed under the MIT/X11 software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#include "main.h" | ||
#include "rpcpulse.h" | ||
#include <boost/assign/list_of.hpp> | ||
|
||
using namespace std; | ||
using namespace boost; | ||
using namespace boost::assign; | ||
using namespace json_spirit; | ||
|
||
/* Patches | ||
- bitcoinrpc.cpp: | ||
#include "rpcpulse.h" | ||
CRPCCommand: | ||
{ "getpulseinfo", &getpulseinfo, true, false }, | ||
*/ | ||
|
||
/* getpulseinfo(const Array& params, bool fHelp) : Object | ||
Expose Pulse-Settings via RPC */ | ||
json_spirit::Value getpulseinfo(const Array& params, bool fHelp) { | ||
if (fHelp || params.size() != 0) | ||
throw std::runtime_error("getpulseinfo\nReturns an object containing various pulse info."); | ||
int i = PulseI(nBestHeight); | ||
json_spirit::Object obj; | ||
obj.push_back(json_spirit::Pair("height", (int)PULSE_HEIGHT[i])); | ||
obj.push_back(json_spirit::Pair("rate", (int)PULSE_RATE[i])); | ||
if( PULSE_MIN_RATE[i] > 0 ) | ||
obj.push_back(json_spirit::Pair("min-rate", (int)PULSE_MIN_RATE[i])); | ||
if( PULSE_MIN_TX[i] > 0 ) | ||
obj.push_back(json_spirit::Pair("min-tx", (int)PULSE_MIN_TX[i])); | ||
if( PULSE_MIN_VALUE[i] > 0 ) | ||
obj.push_back(json_spirit::Pair("min-value", (int)PULSE_MIN_VALUE[i])); | ||
if( PULSE_MIN_FEE[i] > 0 ) | ||
obj.push_back(json_spirit::Pair("min-fee", (int)PULSE_MIN_FEE[i])); | ||
if( PULSE_MIN_TX[i] > 0 ) | ||
obj.push_back(json_spirit::Pair("min-tx", (int)PULSE_MIN_TX[i])); | ||
obj.push_back(json_spirit::Pair("factor", PULSE_FACTOR[i])); | ||
obj.push_back(json_spirit::Pair("explicit", PULSE_EXPLICIT[i])); | ||
return obj; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) 2014-.... f0o / The Cryptocoin Revival Foundation | ||
// Distributed under the MIT/X11 software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#ifndef RPCPULSE_H | ||
#define RPCPULSE_H 1 | ||
|
||
#include "json/json_spirit_reader_template.h" | ||
#include "json/json_spirit_writer_template.h" | ||
#include "json/json_spirit_utils.h" | ||
#include "pulse.h" | ||
|
||
extern json_spirit::Value getpulseinfo(const json_spirit::Array& params, bool fHelp); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters