generated from dopt-python/py311-cython
prepare initialisation of blockchain
This commit is contained in:
parent
d3a808c0fe
commit
92dcb90070
18
pdm.lock
generated
18
pdm.lock
generated
@ -5,7 +5,7 @@
|
||||
groups = ["default", "data", "dev", "lint", "nb", "tests"]
|
||||
strategy = ["inherit_metadata"]
|
||||
lock_version = "4.5.0"
|
||||
content_hash = "sha256:a28bc9f6ac4aaed3d77e740ba7da7c420623e4edfba18854357238e4f95e759f"
|
||||
content_hash = "sha256:35fffc1c0ac0b0ad9c178fb759b2ea6f6db4c118739a667064025b9734c24eb0"
|
||||
|
||||
[[metadata.targets]]
|
||||
requires_python = ">=3.11"
|
||||
@ -433,7 +433,7 @@ name = "colorama"
|
||||
version = "0.4.6"
|
||||
requires_python = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7"
|
||||
summary = "Cross-platform colored terminal text."
|
||||
groups = ["dev", "nb", "tests"]
|
||||
groups = ["data", "dev", "nb", "tests"]
|
||||
marker = "sys_platform == \"win32\" or platform_system == \"Windows\""
|
||||
files = [
|
||||
{file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"},
|
||||
@ -2832,6 +2832,20 @@ files = [
|
||||
{file = "tornado-6.5.2.tar.gz", hash = "sha256:ab53c8f9a0fa351e2c0741284e06c7a45da86afb544133201c5cc8578eb076a0"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tqdm"
|
||||
version = "4.67.1"
|
||||
requires_python = ">=3.7"
|
||||
summary = "Fast, Extensible Progress Meter"
|
||||
groups = ["data"]
|
||||
dependencies = [
|
||||
"colorama; platform_system == \"Windows\"",
|
||||
]
|
||||
files = [
|
||||
{file = "tqdm-4.67.1-py3-none-any.whl", hash = "sha256:26445eca388f82e72884e0d580d5464cd801a3ea01e63e5601bdff9ba6a48de2"},
|
||||
{file = "tqdm-4.67.1.tar.gz", hash = "sha256:f8aef9c52c08c13a65f30ea34f4e5aac3fd1a34959879d7e59e63027286627f2"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "traitlets"
|
||||
version = "5.14.3"
|
||||
|
||||
@ -156,4 +156,5 @@ data = [
|
||||
"polars>=1.36.1",
|
||||
"pyarrow>=22.0.0",
|
||||
"pandas>=2.3.3",
|
||||
"tqdm>=4.67.1",
|
||||
]
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -431,7 +431,10 @@ cdef class Blockchain:
|
||||
|
||||
# // Python public API
|
||||
def __len__(self):
|
||||
if self.genesis_done:
|
||||
return self._index + 1
|
||||
else:
|
||||
return 0
|
||||
|
||||
@property
|
||||
def difficulty(self):
|
||||
|
||||
5
src/dopt_pollublock_blockchain/constants.py
Normal file
5
src/dopt_pollublock_blockchain/constants.py
Normal file
@ -0,0 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Final
|
||||
|
||||
BLOCKCHAIN_DIFFICULTY: Final[int] = 24
|
||||
@ -1,8 +1,10 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import polars as pl
|
||||
import sqlalchemy as sql
|
||||
|
||||
metadata_blockchain: sql.MetaData = sql.MetaData()
|
||||
metadata_sensor_data: sql.MetaData = sql.MetaData()
|
||||
|
||||
blocks = sql.Table(
|
||||
"blocks",
|
||||
@ -14,3 +16,23 @@ blocks = sql.Table(
|
||||
sql.Column("hash", sql.String(64), nullable=False),
|
||||
sql.Column("data", sql.String(64), nullable=False),
|
||||
)
|
||||
|
||||
sensor_data = sql.Table(
|
||||
"sensor_data",
|
||||
metadata_sensor_data,
|
||||
sql.Column("Index", sql.Integer, primary_key=True, autoincrement=True),
|
||||
sql.Column("Datetime", sql.DateTime, nullable=False),
|
||||
sql.Column("Temperature_(Celsius)", sql.Float, nullable=False),
|
||||
sql.Column("Pressure_(Pa)", sql.Integer, nullable=False),
|
||||
sql.Column("Air_Quantity_(Percent)", sql.Float, nullable=False),
|
||||
sql.Column("Blockchain_Block_Number", sql.BigInteger, nullable=True),
|
||||
)
|
||||
|
||||
sensor_data_query_schema: dict[str, type[pl.DataType]] = {
|
||||
"Index": pl.UInt64,
|
||||
"Datetime": pl.Datetime,
|
||||
"Temperature_(Celsius)": pl.Float32,
|
||||
"Pressure_(Pa)": pl.Int32,
|
||||
"Air_Quantity_(Percent)": pl.Float64,
|
||||
"Blockchain_Block_Number": pl.UInt64,
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user