Bitcoin のブロックの構造
Bitcoin の Block は、以下の表のような構造になっている。
Magic number はデータ構造のタイプを即座に判断できるように設定された定数らしい。Bitcoin の Block においては、常に 0xD9B4BEF9 であるとのこと。
Blocksize はその名の通りBlock 全体のサイズ(数字)。Blockheader がこの中だと最も重要(?) で、いろいろなデータが含まれている(後述)。 Transaction counter はトランザクションの数、残りはトランザクションのリストが含まれている。
Size | Name | Description |
---|---|---|
4 bytes | Magic no | always 0xD9B4BEF9 |
4 bytes | Blocksize | the size of entire block |
80 bytes | Blockheader | consists of 6 items |
1-9 bytes | Tx counter | n > 0 |
Variable | Transactions | the list of transactions |
その中でもBlockheader は6つの要素から構成されている(https://en.bitcoin.it/wiki/Block_hashing_algorithmより)。
Field | Purpose | Updated when... | Size (Bytes) |
---|---|---|---|
Version | Block version number | You upgrade the software and it specifies a new version | 4 |
hashPrevBlock | 256-bit hash of the previous block header | A new block comes in | 32 |
hashMerkleRoot | 256-bit hash based on all of the transactions in the block | A transaction is accepted | 32 |
Time | Current timestamp as seconds since 1970-01-01T00:00 UTC | Every few seconds | 4 |
Bits | Current target in compact format | The difficulty is adjusted | 4 |
Nonce | 32-bit number (starts at 0) | A hash is tried (increments) | 4 |
それぞれの役割はPurpose を読めば分かるので省略する。ここの表には出てこなかったが Block Explorer を見てみると、これら以外にもBlock Height(ブロック高)があるが、これは hashPrevBlock(一つ前のBlockhash)をたどっていき、Genesis Block まで数えることで算出しているのだろう。