<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ## 1、一切從數據開始。 我們對比下etherum和pe: 下面是ethereum的block header: ~~~ type Header struct { ParentHash common.Hash `json:"parentHash" gencodec:"required"` UncleHash common.Hash `json:"sha3Uncles" gencodec:"required"` Coinbase common.Address `json:"miner"` Root common.Hash `json:"stateRoot" gencodec:"required"` TxHash common.Hash `json:"transactionsRoot" gencodec:"required"` ReceiptHash common.Hash `json:"receiptsRoot" gencodec:"required"` Bloom Bloom `json:"logsBloom" gencodec:"required"` Difficulty *big.Int `json:"difficulty" gencodec:"required"` Number *big.Int `json:"number" gencodec:"required"` GasLimit uint64 `json:"gasLimit" gencodec:"required"` GasUsed uint64 `json:"gasUsed" gencodec:"required"` Time uint64 `json:"timestamp" gencodec:"required"` Extra []byte `json:"extraData" gencodec:"required"` MixDigest common.Hash `json:"mixHash"` Nonce BlockNonce `json:"nonce"` // BaseFee was added by EIP-1559 and is ignored in legacy headers. BaseFee *big.Int `json:"baseFeePerGas" rlp:"optional"` /* TODO (MariusVanDerWijden) Add this field once needed // Random was added during the merge and contains the BeaconState randomness Random common.Hash `json:"random" rlp:"optional"` */ } ~~~ 下面是ep的block header: ~~~ type Header struct { ParentHash Hash `json:"parentHash"` Sha3Uncles Hash `json:"sha3Uncles"` Miner Address `json:"miner"` StateRoot Hash `json:"stateRoot"` TxRoot Hash `json:"transactionsRoot"` ReceiptsRoot Hash `json:"receiptsRoot"` LogsBloom Bloom `json:"logsBloom"` Difficulty uint64 `json:"difficulty"` Number uint64 `json:"number"` GasLimit uint64 `json:"gasLimit"` GasUsed uint64 `json:"gasUsed"` Timestamp uint64 `json:"timestamp"` ExtraData []byte `json:"extraData"` MixHash Hash `json:"mixHash"` Nonce Nonce `json:"nonce"` Hash Hash `json:"hash"` } ~~~ ep 目前不支持以太坊最新的EIP-1599協議,其它部分和ethereum玩去一致(雖然變量名稱有些有區別,但數據類型完全一致,甚至映射的json名稱也完全一致)。 我們再看看block的結構比較: 下面是ep的block結構: ~~~ type Block struct { Header *Header Transactions []*Transaction Uncles []*Header // Cache size atomic.Value // *uint64 } ~~~ 下面是ethereum的block結構: ~~~ type Block struct { header *Header uncles []*Header transactions Transactions // caches hash atomic.Value size atomic.Value // These fields are used by package eth to track // inter-peer block relay. ReceivedAt time.Time ReceivedFrom interface{} } ~~~ 其中Transactions類型結構定義如下: ~~~ type Transactions []*Transaction ~~~ 可以看出,ep的block結構相比,少了hash(cache字段,可以計算出來)、ReceviedAt、ReceivedFrom字段(后兩個字段用于eth進行跟蹤)。ep少了這幾個字段,對于跨鏈數據交換影響不大(跨鏈交換當然需要對源鏈的block數據進行數據抽取,然后按照目標鏈的結構進行重構)。 block的真正content是body,我們看看兩者的結構: ethereum的body結構: ~~~ // Body is a simple (mutable, non-safe) data container for storing and moving // a block's data contents (transactions and uncles) together. type Body struct { Transactions []*Transaction Uncles []*Header } ~~~ 下面是ep的body結構: ~~~ type Body struct { Transactions []*Transaction Uncles []*Header } ~~~ 兩者的body結構完全相同。 以下是對block結構字段的闡述: 1. **parentHash:**The block header hash of the previous block. Each block contains the hash of the previous block, all the way back to the genesis block on the chain. This is the structural design that maintains the data from being tampered with (any tampering to the previous block will affect the hash value of all subsequent blocks). 2. **ommersHash:**The uncle block header and the hash value of part of the block body. 3. **beneficiary:**The Ethereum account that gets paid for mining this block. 4. **stateRoot:**The hash of the root node of the world state tree (after all transactions have been executed). 5. **transactionsRoot:**The hash value of the root node of the transaction tree. This tree contains all transactions in the block body. 6. **receiptsRoot:**Every time a transaction is executed, Ethereum generates a transaction receipt corresponding to the result. Here is the root node hash of this transaction receipt tree. 7. **logsBloom:**It is used to judge whether the transaction of a certain block generates a certain log. This avoids storing log information in chunks (saves a lot of space). 8. **difficulty:**The difficulty value of this block. This is a measure of the mining difficulty of the current block 9. **number:**The total number of preorder blocks. This indicates the height of the blockchain (i.e. how many blocks are on the blockchain). The number of the genesis block is 0 . 10. **gasLimit:**Every transaction requires gas. The gas limit indicates the total amount of gas that can be used by all transactions recorded in this block. This is a means of limiting the number of transactions in a block. 11. **gasUsed:**The total amount of gas actually consumed by each exchange in the block. 12. **timestamp:**The Unix timestamp when the block was created. 13. **extraData:**A variable-length byte array that can enter anything. When miners create blocks, anything can be added to this area. 14. **mixHash:**The hash value used to verify that a block was actually recorded on the chain. 15. **nonce:**Like**mixHash**, the value used to verify that the block was actually recorded on-chain. 簡要翻譯如下: * Prev Hash - 父區塊的Keccak哈希值 * Nonce - 用于工作證明的計算 * Timestamp - 時間戳 * Uncles Hash - 叔塊的Keccak哈希值 * Benficiary - 受益人地址,礦工地址 * Logs Bloom - 事件地址和事件topic的布隆濾波器 * Difficult - 前一個區塊的難度 * Extra Data - 與該區塊相關的32字節數據 * Block Num - 祖先塊數 * Gas Limit -當前每個區塊的gas使用限制值 * Gas Used - 該區塊中用于交易的gas消耗值 * Mix Hash - 與nonce一起用來證明工作證明計算的256位值 * State Root - 狀態樹的根哈希值 * Transaction Root - 交易樹的根哈希值 * Receipt Root - 收據樹的根哈希值 ## 2、數據存儲結構 我們先看看bitcoin的鏈結構: ![](https://img.kancloud.cn/91/9d/919d05cc142e506cb4b234d50d70b68f_1048x582.png) 圖描述很清楚,不做贅述。 我們再看看以太坊的鏈結構: ![](https://img.kancloud.cn/53/3e/533e9c911dc25c0a45cfffe15010cc8d_1048x728.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看