美文网首页
decred header

decred header

作者: 古则 | 来源:发表于2019-04-11 10:06 被阅读0次
// MaxBlockHeaderPayload is the maximum number of bytes a block header can be.
// Version 4 bytes + PrevBlock 32 bytes + MerkleRoot 32 bytes + StakeRoot 32
// bytes + VoteBits 2 bytes + FinalState 6 bytes + Voters 2 bytes + FreshStake 1
// byte + Revocations 1 bytes + PoolSize 4 bytes + Bits 4 bytes + SBits 8 bytes
// + Height 4 bytes + Size 4 bytes + Timestamp 4 bytes + Nonce 4 bytes +
// ExtraData 32 bytes + StakeVersion 4 bytes.
// --> Total 180 bytes.
// BlockHeader defines information about a block and is used in the decred
// block (MsgBlock) and headers (MsgHeaders) messages.
type BlockHeader struct {
    // Version of the block.  This is not the same as the protocol version.
    // hex [:8]
    Version int32
    // Hash of the previous block in the block chain.
    // hex [8:72]
    PrevBlock chainhash.Hash
    // Merkle tree reference to hash of all transactions for the block.
    // hex [72:136]
    MerkleRoot chainhash.Hash
    // Merkle tree reference to hash of all stake transactions for the block.
    // hex [136:200]
    StakeRoot chainhash.Hash
    // Votes on the previous merkleroot and yet undecided parameters.
    // hex [200:204]
    VoteBits uint16
    // Final state of the PRNG used for ticket selection in the lottery.
    // hex [204:216]
    FinalState [6]byte
    // Number of participating voters for this block.
    // hex [216:220]
    Voters uint16
    // Number of new sstx in this block.
    // hex [220:222]
    FreshStake uint8
    // Number of ssrtx present in this block.
    // hex [222:224]
    Revocations uint8
    // Size of the ticket pool.
    // hex [224:232]
    PoolSize uint32
    // Difficulty target for the block.
    // hex [232:240]
    Bits uint32
    // Stake difficulty target.
    // hex [240:256]
    SBits int64
    // Height is the block height in the block chain.
    // hex [256:264]
    Height uint32
    // Size is the size of the serialized block in its entirety.
    // hex [264:272]
    Size uint32
    // Time the block was created.  This is, unfortunately, encoded as a
    // uint32 on the wire and therefore is limited to 2106.
    // hex [272:280]
    Timestamp time.Time
    // Nonce is technically a part of ExtraData, but we use it as the
    // classical 4-byte nonce here.
    // hex [280:288]
    Nonce uint32
    // ExtraData is used to encode the nonce or any other extra data
    // that might be used later on in consensus.
    // hex [288:352]
    ExtraData [32]byte
    // StakeVersion used for voting.
    // hex [352:360]
    StakeVersion uint32
}

070000009999de88d93b264493a874833d7a126a3115add136bbfe293b8aae0000000000c181354dd560e2f9fdfc7838f0840d0a2673fa844e87baef553c935119920806026405050ceef4a949be23c772526fd83eec1be8c8550c2c152743607260f35c01003de7be51369b050006007d1600006c32071c2262a25e0100000039930200c71a000039b5ad5c000000000000000000000000000000000000000000000000000000000000000000000000070000008000000100000000000005a0

getwork

blockVersion := headerE[:8]
prevBlock := headerE[8:72]
genTx1 := headerE[72:288]
nBits := headerE[232:240]
nTime := headerE[272:280]
genTx2 := headerE[352:360]
HeaderHeight := binary.LittleEndian.Uint32(headerE[256:264])

相关文章

网友评论

      本文标题:decred header

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