generated from dopt-python/py311-cython
prepare initialisation of blockchain
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -431,7 +431,10 @@ cdef class Blockchain:
|
||||
|
||||
# // Python public API
|
||||
def __len__(self):
|
||||
return self._index + 1
|
||||
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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user