美文网首页比特币源码学习笔记
比特币源码阅读(CDiskBlockPos)

比特币源码阅读(CDiskBlockPos)

作者: 坠叶飘香 | 来源:发表于2018-08-01 19:52 被阅读0次

    src/chain.h

    //Block在存储空间的位置?

    struct CDiskBlockPos
    {
        int nFile; //文件号
        unsigned int nPos; //偏移量
    
        ADD_SERIALIZE_METHODS;
    
        template <typename Stream, typename Operation>
        inline void SerializationOp(Stream& s, Operation ser_action) {
            READWRITE(VARINT(nFile, VarIntMode::NONNEGATIVE_SIGNED));
            READWRITE(VARINT(nPos));
        }
    
        CDiskBlockPos() {
            SetNull();
        }
    
        CDiskBlockPos(int nFileIn, unsigned int nPosIn) {
            nFile = nFileIn;
            nPos = nPosIn;
        }
    
        friend bool operator==(const CDiskBlockPos &a, const CDiskBlockPos &b) {
            return (a.nFile == b.nFile && a.nPos == b.nPos);
        }
    
        friend bool operator!=(const CDiskBlockPos &a, const CDiskBlockPos &b) {
            return !(a == b);
        }
    
        void SetNull() { nFile = -1; nPos = 0; }
        bool IsNull() const { return (nFile == -1); }
    
        std::string ToString() const
        {
            return strprintf("CBlockDiskPos(nFile=%i, nPos=%i)", nFile, nPos);
        }
    
    };
    

    相关文章

      网友评论

        本文标题:比特币源码阅读(CDiskBlockPos)

        本文链接:https://www.haomeiwen.com/subject/zdzrvftx.html