mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-21 22:14:20 +01:00
bitcoin: Compute block hash while parsing
This avoids having to re-serialize the block header just to compute the hash. It also frees us from having to carry around all the details in the header and we can hand around a minimal version.
This commit is contained in:
@@ -60,7 +60,7 @@ bitcoin_block_from_hex(const tal_t *ctx, const struct chainparams *chainparams,
|
|||||||
b->hdr.nonce = pull_le32(&p, &len);
|
b->hdr.nonce = pull_le32(&p, &len);
|
||||||
sha256_le32(&shactx, b->hdr.nonce);
|
sha256_le32(&shactx, b->hdr.nonce);
|
||||||
}
|
}
|
||||||
sha256_double_done(&shactx, &b->hdr.hash);
|
sha256_double_done(&shactx, &b->hdr.hash.shad);
|
||||||
|
|
||||||
num = pull_varint(&p, &len);
|
num = pull_varint(&p, &len);
|
||||||
b->tx = tal_arr(b, struct bitcoin_tx *, num);
|
b->tx = tal_arr(b, struct bitcoin_tx *, num);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ struct bitcoin_block_hdr {
|
|||||||
le32 timestamp;
|
le32 timestamp;
|
||||||
le32 target;
|
le32 target;
|
||||||
le32 nonce;
|
le32 nonce;
|
||||||
struct sha256_double hash;
|
struct bitcoin_blkid hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct elements_block_proof {
|
struct elements_block_proof {
|
||||||
|
|||||||
Reference in New Issue
Block a user