<commit_before>// 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);
}

/* 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) ) {<commit_msg>adjusted to match frycoin's getvalue<commit_after>// 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);
}

/* 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);
				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) ) {
{'fraction_non_alphanumeric': 0.14244604316546763, 'fraction_numerical': 0.017266187050359712, 'mean_word_length': 3.6298763082778307, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6459228', 'n_tokens_mistral': 2069, 'n_tokens_neox': 1829, 'n_words': 463}