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

streamable: Simplify and force correct usage #10509

Merged
merged 10 commits into from
Apr 9, 2022
6 changes: 3 additions & 3 deletions benchmarks/streamable.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
_version = 1


@dataclass(frozen=True)
@streamable
@dataclass(frozen=True)
class BenchmarkInner(Streamable):
a: str


@dataclass(frozen=True)
@streamable
@dataclass(frozen=True)
class BenchmarkMiddle(Streamable):
a: uint64
b: List[bytes32]
Expand All @@ -33,8 +33,8 @@ class BenchmarkMiddle(Streamable):
e: BenchmarkInner


@dataclass(frozen=True)
@streamable
@dataclass(frozen=True)
class BenchmarkClass(Streamable):
a: Optional[BenchmarkMiddle]
b: Optional[BenchmarkMiddle]
Expand Down
6 changes: 3 additions & 3 deletions chia/clvm/spend_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@
"""


@dataclass(frozen=True)
@streamable
@dataclass(frozen=True)
class SimFullBlock(Streamable):
transactions_generator: Optional[BlockGenerator]
height: uint32 # Note that height is not on a regular FullBlock


@dataclass(frozen=True)
@streamable
@dataclass(frozen=True)
class SimBlockRecord(Streamable):
reward_claims_incorporated: List[Coin]
height: uint32
Expand All @@ -69,8 +69,8 @@ def create(cls, rci: List[Coin], height: uint32, timestamp: uint64):
)


@dataclass(frozen=True)
@streamable
@dataclass(frozen=True)
class SimStore(Streamable):
timestamp: uint64
block_height: uint32
Expand Down
2 changes: 1 addition & 1 deletion chia/consensus/block_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from chia.util.streamable import Streamable, streamable


@dataclass(frozen=True)
@streamable
@dataclass(frozen=True)
class BlockRecord(Streamable):
"""
This class is not included or hashed into the blockchain, but it is kept in memory as a more
Expand Down
2 changes: 1 addition & 1 deletion chia/consensus/cost_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from chia.util.streamable import Streamable, streamable


@dataclass(frozen=True)
@streamable
@dataclass(frozen=True)
class NPCResult(Streamable):
error: Optional[uint16]
conds: Optional[SpendBundleConditions]
Expand Down
2 changes: 1 addition & 1 deletion chia/consensus/multiprocess_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
log = logging.getLogger(__name__)


@dataclass(frozen=True)
@streamable
@dataclass(frozen=True)
class PreValidationResult(Streamable):
error: Optional[uint16]
required_iters: Optional[uint64] # Iff error is None
Expand Down
2 changes: 1 addition & 1 deletion chia/full_node/block_height_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
log = logging.getLogger(__name__)


@dataclass(frozen=True)
@streamable
@dataclass(frozen=True)
class SesCache(Streamable):
content: List[Tuple[uint32, bytes]]

Expand Down
2 changes: 1 addition & 1 deletion chia/full_node/full_node_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
log = logging.getLogger(__name__)


@dataclasses.dataclass(frozen=True)
@streamable
@dataclasses.dataclass(frozen=True)
class FullNodeStorePeakResult(Streamable):
added_eos: Optional[EndOfSubSlotBundle]
new_signage_points: List[Tuple[uint8, SignagePoint]]
Expand Down
2 changes: 1 addition & 1 deletion chia/full_node/signage_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from chia.util.streamable import Streamable, streamable


@dataclass(frozen=True)
@streamable
@dataclass(frozen=True)
class SignagePoint(Streamable):
cc_vdf: Optional[VDFInfo]
cc_proof: Optional[VDFProof]
Expand Down
4 changes: 2 additions & 2 deletions chia/plotting/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@
CURRENT_VERSION: uint16 = uint16(0)


@dataclass(frozen=True)
@streamable
@dataclass(frozen=True)
class CacheEntry(Streamable):
pool_public_key: Optional[G1Element]
pool_contract_puzzle_hash: Optional[bytes32]
plot_public_key: G1Element


@dataclass(frozen=True)
@streamable
@dataclass(frozen=True)
class DiskCache(Streamable):
version: uint16
data: List[Tuple[bytes32, CacheEntry]]
Expand Down
2 changes: 1 addition & 1 deletion chia/pools/pool_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
log = logging.getLogger(__name__)


@dataclass(frozen=True)
@streamable
@dataclass(frozen=True)
class PoolWalletConfig(Streamable):
launcher_id: bytes32
pool_url: str
Expand Down
4 changes: 2 additions & 2 deletions chia/pools/pool_wallet_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class PoolSingletonState(IntEnum):
FARMING_TO_POOL = PoolSingletonState.FARMING_TO_POOL


@dataclass(frozen=True)
@streamable
@dataclass(frozen=True)
class PoolState(Streamable):
"""
`PoolState` is a type that is serialized to the blockchain to track the state of the user's pool singleton
Expand Down Expand Up @@ -97,8 +97,8 @@ def create_pool_state(
return ps


@dataclass(frozen=True)
@streamable
@dataclass(frozen=True)
class PoolWalletInfo(Streamable):
"""
Internal Pool Wallet state, not destined for the blockchain. This can be completely derived with
Expand Down
10 changes: 5 additions & 5 deletions chia/protocols/farmer_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"""


@dataclass(frozen=True)
@streamable
@dataclass(frozen=True)
class NewSignagePoint(Streamable):
challenge_hash: bytes32
challenge_chain_sp: bytes32
Expand All @@ -26,8 +26,8 @@ class NewSignagePoint(Streamable):
signage_point_index: uint8


@dataclass(frozen=True)
@streamable
@dataclass(frozen=True)
class DeclareProofOfSpace(Streamable):
challenge_hash: bytes32
challenge_chain_sp: bytes32
Expand All @@ -41,16 +41,16 @@ class DeclareProofOfSpace(Streamable):
pool_signature: Optional[G2Element]


@dataclass(frozen=True)
@streamable
@dataclass(frozen=True)
class RequestSignedValues(Streamable):
quality_string: bytes32
foliage_block_data_hash: bytes32
foliage_transaction_block_hash: bytes32


@dataclass(frozen=True)
@streamable
@dataclass(frozen=True)
class FarmingInfo(Streamable):
challenge_hash: bytes32
sp_hash: bytes32
Expand All @@ -60,8 +60,8 @@ class FarmingInfo(Streamable):
total_plots: uint32


@dataclass(frozen=True)
@streamable
@dataclass(frozen=True)
class SignedValues(Streamable):
quality_string: bytes32
foliage_block_data_signature: G2Element
Expand Down
Loading