mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
Make nType and nVersion private and sometimes const
Make the various stream implementations' nType and nVersion private and const (except in CDataStream where we really need a setter).
This commit is contained in:
parent
c2c5d42f36
commit
fad9b66504
@ -132,9 +132,9 @@ class CHashWriter
|
|||||||
private:
|
private:
|
||||||
CHash256 ctx;
|
CHash256 ctx;
|
||||||
|
|
||||||
|
const int nType;
|
||||||
|
const int nVersion;
|
||||||
public:
|
public:
|
||||||
int nType;
|
|
||||||
int nVersion;
|
|
||||||
|
|
||||||
CHashWriter(int nTypeIn, int nVersionIn) : nType(nTypeIn), nVersion(nVersionIn) {}
|
CHashWriter(int nTypeIn, int nVersionIn) : nType(nTypeIn), nVersion(nVersionIn) {}
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ public:
|
|||||||
void PushMessageWithVersionAndFlag(CNode* pnode, int nVersion, int flag, const std::string& sCommand, Args&&... args)
|
void PushMessageWithVersionAndFlag(CNode* pnode, int nVersion, int flag, const std::string& sCommand, Args&&... args)
|
||||||
{
|
{
|
||||||
auto msg(BeginMessage(pnode, nVersion, flag, sCommand));
|
auto msg(BeginMessage(pnode, nVersion, flag, sCommand));
|
||||||
::SerializeMany(msg, msg.nType, msg.nVersion, std::forward<Args>(args)...);
|
::SerializeMany(msg, msg.GetType(), msg.GetVersion(), std::forward<Args>(args)...);
|
||||||
EndMessage(msg);
|
EndMessage(msg);
|
||||||
PushMessage(pnode, msg, sCommand);
|
PushMessage(pnode, msg, sCommand);
|
||||||
}
|
}
|
||||||
|
@ -937,9 +937,9 @@ class CSizeComputer
|
|||||||
protected:
|
protected:
|
||||||
size_t nSize;
|
size_t nSize;
|
||||||
|
|
||||||
|
const int nType;
|
||||||
|
const int nVersion;
|
||||||
public:
|
public:
|
||||||
int nType;
|
|
||||||
int nVersion;
|
|
||||||
|
|
||||||
CSizeComputer(int nTypeIn, int nVersionIn) : nSize(0), nType(nTypeIn), nVersion(nVersionIn) {}
|
CSizeComputer(int nTypeIn, int nVersionIn) : nSize(0), nType(nTypeIn), nVersion(nVersionIn) {}
|
||||||
|
|
||||||
|
@ -26,10 +26,11 @@ template<typename Stream>
|
|||||||
class OverrideStream
|
class OverrideStream
|
||||||
{
|
{
|
||||||
Stream* stream;
|
Stream* stream;
|
||||||
public:
|
|
||||||
const int nType;
|
const int nType;
|
||||||
const int nVersion;
|
const int nVersion;
|
||||||
|
|
||||||
|
public:
|
||||||
OverrideStream(Stream* stream_, int nType_, int nVersion_) : stream(stream_), nType(nType_), nVersion(nVersion_) {}
|
OverrideStream(Stream* stream_, int nType_, int nVersion_) : stream(stream_), nType(nType_), nVersion(nVersion_) {}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@ -66,9 +67,10 @@ protected:
|
|||||||
typedef CSerializeData vector_type;
|
typedef CSerializeData vector_type;
|
||||||
vector_type vch;
|
vector_type vch;
|
||||||
unsigned int nReadPos;
|
unsigned int nReadPos;
|
||||||
public:
|
|
||||||
int nType;
|
int nType;
|
||||||
int nVersion;
|
int nVersion;
|
||||||
|
public:
|
||||||
|
|
||||||
typedef vector_type::allocator_type allocator_type;
|
typedef vector_type::allocator_type allocator_type;
|
||||||
typedef vector_type::size_type size_type;
|
typedef vector_type::size_type size_type;
|
||||||
@ -251,9 +253,9 @@ public:
|
|||||||
int in_avail() { return size(); }
|
int in_avail() { return size(); }
|
||||||
|
|
||||||
void SetType(int n) { nType = n; }
|
void SetType(int n) { nType = n; }
|
||||||
int GetType() { return nType; }
|
int GetType() const { return nType; }
|
||||||
void SetVersion(int n) { nVersion = n; }
|
void SetVersion(int n) { nVersion = n; }
|
||||||
int GetVersion() { return nVersion; }
|
int GetVersion() const { return nVersion; }
|
||||||
|
|
||||||
void read(char* pch, size_t nSize)
|
void read(char* pch, size_t nSize)
|
||||||
{
|
{
|
||||||
@ -380,17 +382,15 @@ private:
|
|||||||
CAutoFile(const CAutoFile&);
|
CAutoFile(const CAutoFile&);
|
||||||
CAutoFile& operator=(const CAutoFile&);
|
CAutoFile& operator=(const CAutoFile&);
|
||||||
|
|
||||||
int nType;
|
const int nType;
|
||||||
int nVersion;
|
const int nVersion;
|
||||||
|
|
||||||
FILE* file;
|
FILE* file;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CAutoFile(FILE* filenew, int nTypeIn, int nVersionIn)
|
CAutoFile(FILE* filenew, int nTypeIn, int nVersionIn) : nType(nTypeIn), nVersion(nVersionIn)
|
||||||
{
|
{
|
||||||
file = filenew;
|
file = filenew;
|
||||||
nType = nTypeIn;
|
|
||||||
nVersion = nVersionIn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~CAutoFile()
|
~CAutoFile()
|
||||||
@ -425,10 +425,8 @@ public:
|
|||||||
//
|
//
|
||||||
// Stream subset
|
// Stream subset
|
||||||
//
|
//
|
||||||
void SetType(int n) { nType = n; }
|
int GetType() const { return nType; }
|
||||||
int GetType() { return nType; }
|
int GetVersion() const { return nVersion; }
|
||||||
void SetVersion(int n) { nVersion = n; }
|
|
||||||
int GetVersion() { return nVersion; }
|
|
||||||
|
|
||||||
void read(char* pch, size_t nSize)
|
void read(char* pch, size_t nSize)
|
||||||
{
|
{
|
||||||
@ -500,8 +498,8 @@ private:
|
|||||||
CBufferedFile(const CBufferedFile&);
|
CBufferedFile(const CBufferedFile&);
|
||||||
CBufferedFile& operator=(const CBufferedFile&);
|
CBufferedFile& operator=(const CBufferedFile&);
|
||||||
|
|
||||||
int nType;
|
const int nType;
|
||||||
int nVersion;
|
const int nVersion;
|
||||||
|
|
||||||
FILE *src; // source file
|
FILE *src; // source file
|
||||||
uint64_t nSrcPos; // how many bytes have been read from source
|
uint64_t nSrcPos; // how many bytes have been read from source
|
||||||
@ -531,11 +529,9 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
CBufferedFile(FILE *fileIn, uint64_t nBufSize, uint64_t nRewindIn, int nTypeIn, int nVersionIn) :
|
CBufferedFile(FILE *fileIn, uint64_t nBufSize, uint64_t nRewindIn, int nTypeIn, int nVersionIn) :
|
||||||
nSrcPos(0), nReadPos(0), nReadLimit((uint64_t)(-1)), nRewind(nRewindIn), vchBuf(nBufSize, 0)
|
nType(nTypeIn), nVersion(nVersionIn), nSrcPos(0), nReadPos(0), nReadLimit((uint64_t)(-1)), nRewind(nRewindIn), vchBuf(nBufSize, 0)
|
||||||
{
|
{
|
||||||
src = fileIn;
|
src = fileIn;
|
||||||
nType = nTypeIn;
|
|
||||||
nVersion = nVersionIn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~CBufferedFile()
|
~CBufferedFile()
|
||||||
|
Loading…
Reference in New Issue
Block a user