Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add xfield to block header #43

Merged
merged 6 commits into from
Jun 10, 2024

Conversation

Yamaguchi
Copy link
Contributor

@Yamaguchi Yamaguchi commented Jun 10, 2024

see #39

  • Add xfield to block header
  • Fix/Improve test cases.

@Yamaguchi Yamaguchi changed the title Modify block header(Remove nonce and bits, add immutable merkle root, proof and xfield) Add xfield to block header Jun 10, 2024
* Define new enum ExtraField to hold data in BlockHeader(b0cb001)
* Add extra field to BlockHeader(d6131bb)
* Add field_type method to ExtraField(81b32ef)
* Serde support for ExtraField(0c3a1da)
* Allow unknown xfield type(32b7ff1)
* Rename ExtraField to XField(b15ff3e)
* Fix test(ca94746)
@Yamaguchi Yamaguchi force-pushed the merge_pull_for_modify_block_header branch from f6c691a to 012f1fc Compare June 10, 2024 06:01
@Yamaguchi
Copy link
Contributor Author

std クレート(std::str::FromStrなど)を使用するとCIが失敗する(no_std featureのビルド/テスト)ため、代わりにcoreクレートを使用してます。

@rantan
Copy link
Contributor

rantan commented Jun 10, 2024

std クレート(std::str::FromStrなど)を使用するとCIが失敗する(no_std featureのビルド/テスト)ため、代わりにcoreクレートを使用してます。

rust-bitcoin が基本的に std なしで動くことを保つ方針なので、それを踏襲できればと思っています。

@@ -33,7 +37,7 @@ use crate::{io, merkle_tree, VarInt};
/// ### Bitcoin Core References
///
/// * [CBlockHeader definition](https://github.com/bitcoin/bitcoin/blob/345457b542b6a980ccfbc868af0970a6f91d1b82/src/primitives/block.h#L20)
#[derive(Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)]
#[derive(PartialEq, Eq, Clone, PartialOrd, Ord, Hash)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XField に Copy trait が実装されいていないので Copy を消しているんだと思いますが、 Copy Trait を実装できないんですっけ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XFieldのUnknown型に含まれるVec<u8>がCopy traitを実装していないため、それを利用するHeader等にも実装できないです。
今後Tapyrus-Core側でXFieldのタイプが増えた場合でもrust-tapyrus側でブロックを解釈(serialize/deserialize等)できるように、可変長のVec<u8>を使っています。

tapyrus/src/blockdata/block.rs Outdated Show resolved Hide resolved
@rantan rantan merged commit dfa0955 into update_on_bitcoin_0.31.x Jun 10, 2024
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants