script: move CScriptID to standard.h and add a ctor for creating them from CScripts
This allows for a reversal of the current behavior. This: CScript foo; CScriptID bar(foo.GetID()); Becomes: CScript foo; CScriptID bar(foo); This way, CScript is no longer dependent on CScriptID or Hash();
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "compressor.h"
|
||||
#include "script/standard.h"
|
||||
|
||||
bool CScriptCompressor::IsToKeyID(CKeyID &hash) const
|
||||
{
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#include "script/script.h"
|
||||
|
||||
class CScriptID;
|
||||
|
||||
/** Compact serializer for scripts.
|
||||
*
|
||||
* It detects common cases and encodes them much more efficiently.
|
||||
|
||||
@@ -610,12 +610,6 @@ public:
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
CScriptID GetID() const
|
||||
{
|
||||
return CScriptID(Hash160(*this));
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
// The default std::vector::clear() does not release memory.
|
||||
|
||||
@@ -14,6 +14,8 @@ using namespace std;
|
||||
|
||||
typedef vector<unsigned char> valtype;
|
||||
|
||||
CScriptID::CScriptID(const CScript& in) : uint160(in.size() ? Hash160(in.begin(), in.end()) : 0) {}
|
||||
|
||||
const char* GetTxnOutputType(txnouttype t)
|
||||
{
|
||||
switch (t)
|
||||
|
||||
@@ -13,6 +13,15 @@
|
||||
|
||||
class CScript;
|
||||
|
||||
/** A reference to a CScript: the Hash160 of its serialization (see script.h) */
|
||||
class CScriptID : public uint160
|
||||
{
|
||||
public:
|
||||
CScriptID() : uint160(0) {}
|
||||
CScriptID(const CScript& in);
|
||||
CScriptID(const uint160& in) : uint160(in) {}
|
||||
};
|
||||
|
||||
static const unsigned int MAX_OP_RETURN_RELAY = 40; // bytes
|
||||
|
||||
// Mandatory script verification flags that all new blocks must comply with for
|
||||
|
||||
Reference in New Issue
Block a user