PRCYCoin  2.0.0.7rc1
P2P Digital Currency
Public Member Functions | Protected Member Functions | Private Attributes | Static Private Attributes | List of all members
CScriptCompressor Class Reference

Compact serializer for scripts. More...

#include <compressor.h>

Collaboration diagram for CScriptCompressor:
[legend]

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
 These check for scripts for which a special case with a shorter encoding is defined. More...
 
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
 make this static for now (there are only 6 special scripts defined) this can potentially be extended together with a new nVersion for transactions, in which case this value becomes dependent on nVersion and nHeight of the enclosing transaction. More...
 

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 28 of file compressor.h.

Constructor & Destructor Documentation

◆ CScriptCompressor()

CScriptCompressor::CScriptCompressor ( CScript scriptIn)
inline

Definition at line 58 of file compressor.h.

Member Function Documentation

◆ Compress()

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

Definition at line 43 of file compressor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Decompress()

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

Definition at line 83 of file compressor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSerializeSize()

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

Definition at line 60 of file compressor.h.

Here is the call graph for this function:

◆ GetSpecialSize()

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

Definition at line 74 of file compressor.cpp.

Here is the caller graph for this function:

◆ IsToKeyID()

bool CScriptCompressor::IsToKeyID ( CKeyID hash) const
protected

These check for scripts for which a special case with a shorter encoding is defined.

They are implemented separately from the CScript test, as these test for exact byte sequence correspondences, and are more strict. For example, IsToPubKey also verifies whether the public key is valid (as invalid ones cannot be represented in compressed form).

Definition at line 12 of file compressor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsToPubKey()

bool CScriptCompressor::IsToPubKey ( CPubKey pubkey) const
protected

Definition at line 30 of file compressor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsToScriptID()

bool CScriptCompressor::IsToScriptID ( CScriptID hash) const
protected

Definition at line 21 of file compressor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Serialize()

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

Definition at line 70 of file compressor.h.

Here is the call graph for this function:

◆ Unserialize()

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

Definition at line 83 of file compressor.h.

Here is the call graph for this function:

Member Data Documentation

◆ nSpecialScripts

const unsigned int CScriptCompressor::nSpecialScripts = 6
staticprivate

make this static for now (there are only 6 special scripts defined) this can potentially be extended together with a new nVersion for transactions, in which case this value becomes dependent on nVersion and nHeight of the enclosing transaction.

Definition at line 37 of file compressor.h.

◆ script

CScript& CScriptCompressor::script
private

Definition at line 39 of file compressor.h.


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