Skip to content

Instantly share code, notes, and snippets.

@orphanate
orphanate / scrypt_ref.c
Last active August 29, 2015 14:06
scrypt_ref
/*-
* Copyright 2009 Colin Percival
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
unsigned int static KimotoGravityWell(const CBlockIndex * pindexLast, const CBlockHeader * pblock, uint64 TargetBlocksSpacingSeconds, uint64 PastBlocksMin, uin\
t64 PastBlocksMax)
{
/* current difficulty formula, megacoin - kimoto gravity well */
const CBlockIndex *BlockLastSolved = pindexLast;
const CBlockIndex *BlockReading = pindexLast;
const CBlockHeader *BlockCreating = pblock;
BlockCreating = BlockCreating;
uint64PastBlocksMass = 0;
int64PastRateActualSeconds = 0;
#include <stdio.h>
#include <string.h>
#include <assert.h>
struct float_ext80 {
unsigned long long int sign;
short exp; // top bit is signed bit of the significand
char dummy[6];
};
grep 'BOOST_AUTO_TEST_SUITE(' * -RI | sed -e "s|^.*(\(.*\)).*$|./test_bitcoin --run_test=\1|"
./test_bitcoin --run_test=accounting_tests
./test_bitcoin --run_test=allocator_tests
./test_bitcoin --run_test=base32_tests
./test_bitcoin --run_test=base58_tests
./test_bitcoin --run_test=base64_tests
./test_bitcoin --run_test=bignum_tests
./test_bitcoin --run_test=bip32_tests
./test_bitcoin --run_test=bloom_tests
/*
if (pcheckpoint && pblock->hashPrevBlock != hashBestChain && !Checkpoints::WantedByPendingSyncCheckpoint(hash))
{
// Extra checks to prevent "fill up memory by spamming with bogus blocks"
int64_t deltaTime = pblock->GetBlockTime() - pcheckpoint->nTime;
CBigNum bnNewBlock;
bnNewBlock.SetCompact(pblock->nBits);
CBigNum bnRequired;
if (pblock->IsProofOfStake())
// Extra checks to prevent "fill up memory by spamming with bogus blocks"
int64_t deltaTime = pblock->GetBlockTime() - pcheckpoint->nTime;
CBigNum bnNewBlock;
bnNewBlock.SetCompact(pblock->nBits);
CBigNum bnRequired;
if (pblock->IsProofOfStake())
bnRequired.SetCompact(ComputeMinStake(GetLastBlockIndex(pcheckpoint, true)->nBits, deltaTime, pblock->nTime));
else
bnRequired.SetCompact(ComputeMinWork(GetLastBlockIndex(pcheckpoint, false)->nBits, deltaTime));
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock)
{
unsigned int nProofOfWorkLimit = Params().ProofOfWorkLimit().GetCompact();
int nHeight = pindexLast->nHeight + 1;
int64_t retargetTimespan = nTargetTimespanRe;// 60
int64_t retargetSpacing = nTargetSpacingRe; // 60
int64_t retargetInterval = nIntervalRe; // 1