Skip to content

Commit 4b2f9f0

Browse files
authored
Revert "use rust types for RecentChainData, ProofBlockHeader and WeightProof" #17738 (#18231)
Revert "use rust types for RecentChainData, ProofBlockHeader and WeightProof …" This reverts commit 3f0d5c0.
1 parent 7c54e60 commit 4b2f9f0

File tree

1 file changed

+43
-4
lines changed

1 file changed

+43
-4
lines changed

chia/types/weight_proof.py

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,50 @@
11
from __future__ import annotations
22

3+
from dataclasses import dataclass
4+
from typing import List
5+
36
import chia_rs
47

5-
ProofBlockHeader = chia_rs.ProofBlockHeader
6-
RecentChainData = chia_rs.RecentChainData
7-
SubEpochChallengeSegment = chia_rs.SubEpochChallengeSegment
8+
from chia.types.blockchain_format.reward_chain_block import RewardChainBlock
9+
from chia.types.end_of_slot_bundle import EndOfSubSlotBundle
10+
from chia.types.header_block import HeaderBlock
11+
from chia.util.streamable import Streamable, streamable
12+
813
SubEpochData = chia_rs.SubEpochData
14+
15+
# number of challenge blocks
16+
# Average iters for challenge blocks
17+
# |--A-R----R-------R--------R------R----R----------R-----R--R---| Honest difficulty 1000
18+
# 0.16
19+
20+
# compute total reward chain blocks
21+
# |----------------------------A---------------------------------| Attackers chain 1000
22+
# 0.48
23+
# total number of challenge blocks == total number of reward chain blocks
24+
25+
26+
SubEpochChallengeSegment = chia_rs.SubEpochChallengeSegment
927
SubEpochSegments = chia_rs.SubEpochSegments
1028
SubSlotData = chia_rs.SubSlotData
11-
WeightProof = chia_rs.WeightProof
29+
30+
31+
@streamable
32+
@dataclass(frozen=True)
33+
# this is used only for serialization to database
34+
class RecentChainData(Streamable):
35+
recent_chain_data: List[HeaderBlock]
36+
37+
38+
@streamable
39+
@dataclass(frozen=True)
40+
class ProofBlockHeader(Streamable):
41+
finished_sub_slots: List[EndOfSubSlotBundle]
42+
reward_chain_block: RewardChainBlock
43+
44+
45+
@streamable
46+
@dataclass(frozen=True)
47+
class WeightProof(Streamable):
48+
sub_epochs: List[SubEpochData]
49+
sub_epoch_segments: List[SubEpochChallengeSegment] # sampled sub epoch
50+
recent_chain_data: List[HeaderBlock]

0 commit comments

Comments
 (0)