generated from dopt-python/py311-cython
added functionality for CLI app
This commit is contained in:
parent
3598519a78
commit
156f967a64
File diff suppressed because one or more lines are too long
@ -12,6 +12,7 @@ class PyBlock:
|
|||||||
def __init__(self) -> None: ...
|
def __init__(self) -> None: ...
|
||||||
def __repr__(self) -> str: ...
|
def __repr__(self) -> str: ...
|
||||||
def __str__(self) -> str: ...
|
def __str__(self) -> str: ...
|
||||||
|
def as_dataclass(self) -> t.PyBlockData: ...
|
||||||
def serialize_dict(self) -> t.SerializedPyBlock: ...
|
def serialize_dict(self) -> t.SerializedPyBlock: ...
|
||||||
@property
|
@property
|
||||||
def index(self) -> int: ...
|
def index(self) -> int: ...
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import dopt_basics.datetime
|
|||||||
import sqlalchemy as sql
|
import sqlalchemy as sql
|
||||||
from dopt_pollublock_blockchain import db
|
from dopt_pollublock_blockchain import db
|
||||||
|
|
||||||
|
from dopt_pollublock_blockchain import types
|
||||||
|
|
||||||
from dopt_pollublock_blockchain.block cimport Block
|
from dopt_pollublock_blockchain.block cimport Block
|
||||||
from libcpp.unordered_map cimport unordered_map
|
from libcpp.unordered_map cimport unordered_map
|
||||||
@ -135,13 +136,23 @@ cdef class PyBlock:
|
|||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return (
|
return (
|
||||||
f"PyBlock(\n\tIndex:\t\t{self.index}\n\ttimestamp:\t{self.timestamp}\n\tnonce:\t\t{self.nonce}\n\t"
|
f"PyBlock(\n\tIndex:\t\t{self.index}\n\tTimestamp:\t{self.timestamp}\n\tNonce:\t\t{self.nonce}\n\t"
|
||||||
f"Prev Hash:\t{self.prev_hash}\n\tHash:\t\t{self.hash}\n\tData:\t\t{self.data}\n)"
|
f"Prev Hash:\t{self.prev_hash}\n\tHash:\t\t{self.hash}\n\tData:\t\t{self.data}\n)"
|
||||||
)
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.__repr__()
|
return self.__repr__()
|
||||||
|
|
||||||
|
def as_dataclass(self):
|
||||||
|
return types.PyBlockData(
|
||||||
|
Index=self.index,
|
||||||
|
Timestamp=self.timestamp,
|
||||||
|
Nonce=self.nonce,
|
||||||
|
PrevHash=self.prev_hash,
|
||||||
|
Hash=self.hash,
|
||||||
|
Data=self.data,
|
||||||
|
)
|
||||||
|
|
||||||
def serialize_dict(self):
|
def serialize_dict(self):
|
||||||
contents = {}
|
contents = {}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,19 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import random
|
||||||
from typing import Final
|
from typing import Final
|
||||||
|
|
||||||
|
# ** blockchain
|
||||||
|
BLOCKCHAIN_LOADING_BATCH_SIZE: Final[int] = 256
|
||||||
BLOCKCHAIN_DIFFICULTY: Final[int] = 24
|
BLOCKCHAIN_DIFFICULTY: Final[int] = 24
|
||||||
|
|
||||||
|
# ** data sampling
|
||||||
|
RNG_SEED_RANGE: Final[frozenset[str]] = frozenset(str(seed) for seed in range(1, 101))
|
||||||
|
RNG_DEFAULT_SEED: Final[int | None] = 42
|
||||||
|
RNG: Final[random.Random] = random.Random(RNG_DEFAULT_SEED)
|
||||||
|
TEMPERATURE_MEAN: Final[float] = 344.224456
|
||||||
|
TEMPERATURE_STD: Final[float] = 46.478794
|
||||||
|
PRESSURE_MIN: Final[int] = 15587
|
||||||
|
PRESSURE_MAX: Final[int] = 15602
|
||||||
|
AIRQTY_MEAN: Final[float] = -22.958655
|
||||||
|
AIRQTY_STD: Final[float] = 2.101152
|
||||||
|
|||||||
@ -1,8 +1,28 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import dataclasses as dc
|
||||||
|
import datetime
|
||||||
|
import enum
|
||||||
from typing import TypeAlias, TypedDict
|
from typing import TypeAlias, TypedDict
|
||||||
|
|
||||||
BlockIndex: TypeAlias = int
|
BlockIndex: TypeAlias = int
|
||||||
|
|
||||||
|
|
||||||
|
class ApplicationScenarios(enum.IntEnum):
|
||||||
|
DATA_VALIDATION = 1
|
||||||
|
DATA_GENERATION = 2
|
||||||
|
|
||||||
|
|
||||||
|
@dc.dataclass(slots=True, kw_only=True, eq=False)
|
||||||
|
class PyBlockData:
|
||||||
|
Index: int
|
||||||
|
Timestamp: datetime.datetime
|
||||||
|
Nonce: int
|
||||||
|
PrevHash: str
|
||||||
|
Hash: str
|
||||||
|
Data: str
|
||||||
|
|
||||||
|
|
||||||
class SerializedPyBlock(TypedDict):
|
class SerializedPyBlock(TypedDict):
|
||||||
index: int
|
index: int
|
||||||
timestamp: int
|
timestamp: int
|
||||||
@ -10,3 +30,15 @@ class SerializedPyBlock(TypedDict):
|
|||||||
previous_hash: str
|
previous_hash: str
|
||||||
hash: str
|
hash: str
|
||||||
data: str
|
data: str
|
||||||
|
|
||||||
|
|
||||||
|
RandomSampleEntry = TypedDict(
|
||||||
|
"RandomSampleEntry",
|
||||||
|
{
|
||||||
|
"Datetime": datetime.datetime,
|
||||||
|
"Temperature_(Celsius)": float,
|
||||||
|
"Pressure_(Pa)": int,
|
||||||
|
"Air_Quantity_(Percent)": float,
|
||||||
|
"Blockchain_Block_Number": int | None,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user