Master Core  v0.0.9 - 2abfd2849db8ba7a83957c64eb976b406713c123
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Protected Member Functions | Private Attributes | Static Private Attributes | List of all members
CScriptCompressor Class Reference

Compact serializer for scripts. More...

#include <script.h>

+ Collaboration diagram for CScriptCompressor:

Public Member Functions

 CScriptCompressor (CScript &scriptIn)
 
unsigned int GetSerializeSize (int nType, int nVersion) const
 
template<typename Stream >
void Serialize (Stream &s, int nType, int nVersion) const
 
template<typename Stream >
void Unserialize (Stream &s, int nType, int nVersion)
 

Protected Member Functions

bool IsToKeyID (CKeyID &hash) const
 
bool IsToScriptID (CScriptID &hash) const
 
bool IsToPubKey (CPubKey &pubkey) const
 
bool Compress (std::vector< unsigned char > &out) const
 
unsigned int GetSpecialSize (unsigned int nSize) const
 
bool Decompress (unsigned int nSize, const std::vector< unsigned char > &out)
 

Private Attributes

CScriptscript
 

Static Private Attributes

static const unsigned int nSpecialScripts = 6
 

Detailed Description

Compact serializer for scripts.

It detects common cases and encodes them much more efficiently. 3 special cases are defined:

Other scripts up to 121 bytes require 1 byte + script length. Above that, scripts up to 16505 bytes require 2 bytes + script length.

Definition at line 728 of file script.h.

Constructor & Destructor Documentation

CScriptCompressor::CScriptCompressor ( CScript scriptIn)
inline

Definition at line 752 of file script.h.

Member Function Documentation

bool CScriptCompressor::Compress ( std::vector< unsigned char > &  out) const
protected

Definition at line 1976 of file script.cpp.

References memcpy().

Referenced by GetSerializeSize(), and Serialize().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool CScriptCompressor::Decompress ( unsigned int  nSize,
const std::vector< unsigned char > &  out 
)
protected

Definition at line 2016 of file script.cpp.

References CPubKey::begin(), CPubKey::Decompress(), memcpy(), OP_CHECKSIG, OP_DUP, OP_EQUAL, OP_EQUALVERIFY, OP_HASH160, and CPubKey::size().

Referenced by Unserialize().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

unsigned int CScriptCompressor::GetSerializeSize ( int  nType,
int  nVersion 
) const
inline

Definition at line 754 of file script.h.

References Compress(), nSpecialScripts, and VARINT.

+ Here is the call graph for this function:

unsigned int CScriptCompressor::GetSpecialSize ( unsigned int  nSize) const
protected

Definition at line 2007 of file script.cpp.

Referenced by Unserialize().

+ Here is the caller graph for this function:

bool CScriptCompressor::IsToKeyID ( CKeyID hash) const
protected

Definition at line 1940 of file script.cpp.

References memcpy(), OP_CHECKSIG, OP_DUP, OP_EQUALVERIFY, and OP_HASH160.

+ Here is the call graph for this function:

bool CScriptCompressor::IsToPubKey ( CPubKey pubkey) const
protected

Definition at line 1961 of file script.cpp.

References CPubKey::IsFullyValid(), OP_CHECKSIG, and CPubKey::Set().

+ Here is the call graph for this function:

bool CScriptCompressor::IsToScriptID ( CScriptID hash) const
protected

Definition at line 1951 of file script.cpp.

References memcpy(), OP_EQUAL, and OP_HASH160.

+ Here is the call graph for this function:

template<typename Stream >
void CScriptCompressor::Serialize ( Stream &  s,
int  nType,
int  nVersion 
) const
inline

Definition at line 763 of file script.h.

References Compress(), nSpecialScripts, and VARINT.

+ Here is the call graph for this function:

template<typename Stream >
void CScriptCompressor::Unserialize ( Stream &  s,
int  nType,
int  nVersion 
)
inline

Definition at line 775 of file script.h.

References Decompress(), GetSpecialSize(), nSpecialScripts, REF(), and VARINT.

+ Here is the call graph for this function:

Member Data Documentation

const unsigned int CScriptCompressor::nSpecialScripts = 6
staticprivate

Definition at line 735 of file script.h.

Referenced by GetSerializeSize(), Serialize(), and Unserialize().

CScript& CScriptCompressor::script
private

Definition at line 737 of file script.h.


The documentation for this class was generated from the following files: