/*
* This file is part of the Flowee project
* Copyright (C) 2009-2010 Satoshi Nakamoto
* Copyright (C) 2009-2015 The Bitcoin Core developers
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifndef FLOWEE_SCRIPT_SIGCACHE_H
#define FLOWEE_SCRIPT_SIGCACHE_H
#include "script/interpreter.h"
#include
#include
#include
#include
class PublicKey;
/**
* We're hashing a nonce into the entries themselves, so we don't need extra
* blinding in the set hash computation.
*
* This may exhibit platform endian dependent behavior but because these are
* nonced hashes (random) and this state is only ever used locally it is safe.
* All that matters is local consistency.
*/
class SignatureCacheHasher
{
public:
template
uint32_t operator()(const uint256& key) const
{
static_assert(hash_select <8, "SignatureCacheHasher only has 8 hashes available.");
uint32_t u;
std::memcpy(&u, key.begin()+4*hash_select, 4);
return u;
}
};
class CachingTransactionSignatureChecker : public TransactionSignatureChecker
{
private:
bool store;
public:
CachingTransactionSignatureChecker(const CTransaction* oldTxToIn, const Tx &txIn, unsigned int nInIn, int64_t amount, bool storeIn=true,
const std::vector *spentOutputsIn = nullptr)
: TransactionSignatureChecker(oldTxToIn, txIn, nInIn, amount, spentOutputsIn), store(storeIn) {}
bool VerifySignature(const std::vector& vchSig, const PublicKey& vchPubKey, const uint256& sighash, uint32_t flags) const override;
};
void InitSignatureCache();
#endif