From 68356e06a5f6f9f690425b92c0a0895de18c7525 Mon Sep 17 00:00:00 2001 From: foefl Date: Thu, 11 Dec 2025 16:01:29 +0100 Subject: [PATCH] more core implementation in Cython --- src/polluck_blockchain/placeholder_native.cpp | 3971 ++++++++++++++--- src/polluck_blockchain/placeholder_native.pyx | 275 +- 2 files changed, 3509 insertions(+), 737 deletions(-) diff --git a/src/polluck_blockchain/placeholder_native.cpp b/src/polluck_blockchain/placeholder_native.cpp index b6f5418..ee34eed 100644 --- a/src/polluck_blockchain/placeholder_native.cpp +++ b/src/polluck_blockchain/placeholder_native.cpp @@ -1553,38 +1553,103 @@ static const char* const __pyx_f[] = { /* #### Code section: numeric_typedefs ### */ -/* "polluck_blockchain/placeholder_native.pyx":20 - * from libcpp.string cimport string +/* "polluck_blockchain/placeholder_native.pyx":21 + * from libc.stdint cimport uint64_t * * ctypedef unsigned long ULong # <<<<<<<<<<<<<< + * ctypedef unordered_map[uint64_t, Block*] BcHashmap * - * # cdef struct PyStringC: */ typedef unsigned long __pyx_t_18polluck_blockchain_18placeholder_native_ULong; /* #### Code section: complex_type_declarations ### */ /* #### Code section: type_declarations ### */ /*--- Type declarations ---*/ -struct __pyx_obj_18polluck_blockchain_18placeholder_native_BlockPy; +struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock; +struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain; +struct __pyx_opt_args_18polluck_blockchain_18placeholder_native_7PyBlock_from_ptr; -/* "polluck_blockchain/placeholder_native.pyx":88 +/* "polluck_blockchain/placeholder_native.pyx":22 * + * ctypedef unsigned long ULong + * ctypedef unordered_map[uint64_t, Block*] BcHashmap # <<<<<<<<<<<<<< * - * cdef class BlockPy: # <<<<<<<<<<<<<< - * cdef: - * ULong _index + * cdef timestamp_to_datetime(double ts): */ -struct __pyx_obj_18polluck_blockchain_18placeholder_native_BlockPy { - PyObject_HEAD - __pyx_t_18polluck_blockchain_18placeholder_native_ULong _index; - double _timestamp; - std::string _data; - std::string _prev_hash; - __pyx_t_18polluck_blockchain_18placeholder_native_ULong _nonce; - std::string _hash; - ::Block *Block; +typedef std::unordered_map __pyx_t_18polluck_blockchain_18placeholder_native_BcHashmap; + +/* "polluck_blockchain/placeholder_native.pyx":81 + * + * @staticmethod + * cdef PyBlock from_ptr(Block *block, bint owner=False): # <<<<<<<<<<<<<< + * cdef PyBlock py_block = PyBlock.__new__( + * PyBlock, +*/ +struct __pyx_opt_args_18polluck_blockchain_18placeholder_native_7PyBlock_from_ptr { + int __pyx_n; + int owner; }; +/* "polluck_blockchain/placeholder_native.pyx":32 + * + * + * cdef class PyBlock: # <<<<<<<<<<<<<< + * cdef: + * # ULong _index +*/ +struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock { + PyObject_HEAD + struct __pyx_vtabstruct_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_vtab; + ::Block *BlockC; + int ptr_owner; +}; + + +/* "polluck_blockchain/placeholder_native.pyx":150 + * + * + * cdef class Blockchain: # <<<<<<<<<<<<<< + * cdef int _difficulty + * cdef uint64_t _index +*/ +struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain { + PyObject_HEAD + struct __pyx_vtabstruct_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_vtab; + int _difficulty; + uint64_t _index; + __pyx_t_18polluck_blockchain_18placeholder_native_BcHashmap *_chain; + int _genesis_done; +}; + + + +/* "polluck_blockchain/placeholder_native.pyx":32 + * + * + * cdef class PyBlock: # <<<<<<<<<<<<<< + * cdef: + * # ULong _index +*/ + +struct __pyx_vtabstruct_18polluck_blockchain_18placeholder_native_PyBlock { + struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *(*from_ptr)(::Block *, struct __pyx_opt_args_18polluck_blockchain_18placeholder_native_7PyBlock_from_ptr *__pyx_optional_args); +}; +static struct __pyx_vtabstruct_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_vtabptr_18polluck_blockchain_18placeholder_native_PyBlock; + + +/* "polluck_blockchain/placeholder_native.pyx":150 + * + * + * cdef class Blockchain: # <<<<<<<<<<<<<< + * cdef int _difficulty + * cdef uint64_t _index +*/ + +struct __pyx_vtabstruct_18polluck_blockchain_18placeholder_native_Blockchain { + ::Block *(*get_block_c)(struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *, uint64_t); + void (*add_block)(struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *, ::Block *); +}; +static struct __pyx_vtabstruct_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_vtabptr_18polluck_blockchain_18placeholder_native_Blockchain; /* #### Code section: utility_code_proto ### */ /* --- Runtime support code (head) --- */ @@ -1972,19 +2037,14 @@ static CYTHON_INLINE int __Pyx_ParseKeywords( static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); -/* pyint_simplify.proto */ -static CYTHON_INLINE int __Pyx_PyInt_FromNumber(PyObject **number_var, const char *argname, int accept_none); +/* PyMemoryError_Check.proto */ +#define __Pyx_PyExc_MemoryError_Check(obj) __Pyx_TypeCheck(obj, PyExc_MemoryError) -/* ArgTypeTestFunc.export */ -static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); +/* RaiseException.export */ +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); -/* ArgTypeTest.proto */ -#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ - ((likely(__Pyx_IS_TYPE(obj, type) | (none_allowed && (obj == Py_None)))) ? 1 :\ - __Pyx__ArgTypeTest(obj, type, name, exact)) - -/* RejectKeywords.export */ -static void __Pyx_RejectKeywords(const char* function_name, PyObject *kwds); +/* KeywordStringCheck.proto */ +static CYTHON_INLINE int __Pyx_CheckKeywordStrings(const char* function_name, PyObject *kw); /* IncludeCppStringH.proto (used by decode_cpp_string) */ #include @@ -2018,22 +2078,29 @@ static CYTHON_INLINE PyObject* __Pyx_decode_cpp_string( cppstring.data(), (Py_ssize_t) cppstring.size(), start, stop, encoding, errors, decode_func); } +/* RejectKeywords.export */ +static void __Pyx_RejectKeywords(const char* function_name, PyObject *kwds); + /* PyTypeError_Check.proto */ #define __Pyx_PyExc_TypeError_Check(obj) __Pyx_TypeCheck(obj, PyExc_TypeError) -/* RaiseException.export */ -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); +/* PyIndexError_Check.proto */ +#define __Pyx_PyExc_IndexError_Check(obj) __Pyx_TypeCheck(obj, PyExc_IndexError) + +/* PyRuntimeError_Check.proto */ +#define __Pyx_PyExc_RuntimeError_Check(obj) __Pyx_TypeCheck(obj, PyExc_RuntimeError) + +/* MoveIfSupported.proto */ +#if CYTHON_USE_CPP_STD_MOVE + #include + #define __PYX_STD_MOVE_IF_SUPPORTED(x) std::move(x) +#else + #define __PYX_STD_MOVE_IF_SUPPORTED(x) x +#endif /* AllocateExtensionType.proto */ static PyObject *__Pyx_AllocateExtensionType(PyTypeObject *t, int is_final); -/* DefaultPlacementNew.proto */ -#include -template -void __Pyx_default_placement_construct(T* x) { - new (static_cast(x)) T(); -} - /* LimitedApiGetTypeDict.proto (used by SetItemOnTypeDict) */ #if CYTHON_COMPILING_IN_LIMITED_API static PyObject *__Pyx_GetTypeDict(PyTypeObject *tp); @@ -2065,6 +2132,15 @@ static int __Pyx_validate_bases_tuple(const char *type_name, Py_ssize_t dictoffs /* PyType_Ready.proto */ CYTHON_UNUSED static int __Pyx_PyType_Ready(PyTypeObject *t); +/* SetVTable.proto */ +static int __Pyx_SetVtable(PyTypeObject* typeptr , void* vtable); + +/* GetVTable.proto (used by MergeVTables) */ +static void* __Pyx_GetVtable(PyTypeObject *type); + +/* MergeVTables.proto */ +static int __Pyx_MergeVtables(PyTypeObject *type); + /* DelItemOnTypeDict.proto (used by SetupReduce) */ static int __Pyx__DelItemOnTypeDict(PyTypeObject *tp, PyObject *k); #define __Pyx_DelItemOnTypeDict(tp, k) __Pyx__DelItemOnTypeDict((PyTypeObject*)tp, k) @@ -2301,23 +2377,6 @@ static void __Pyx_CppExn2PyErr() { /* CIntFromPy.proto */ static CYTHON_INLINE uint64_t __Pyx_PyLong_As_uint64_t(PyObject *); -/* FormatTypeName.proto */ -#if CYTHON_COMPILING_IN_LIMITED_API -typedef PyObject *__Pyx_TypeName; -#define __Pyx_FMT_TYPENAME "%U" -#define __Pyx_DECREF_TypeName(obj) Py_XDECREF(obj) -#if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 -#define __Pyx_PyType_GetFullyQualifiedName PyType_GetFullyQualifiedName -#else -static __Pyx_TypeName __Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp); -#endif -#else // !LIMITED_API -typedef const char *__Pyx_TypeName; -#define __Pyx_FMT_TYPENAME "%.200s" -#define __Pyx_PyType_GetFullyQualifiedName(tp) ((tp)->tp_name) -#define __Pyx_DECREF_TypeName(obj) -#endif - /* PyObjectVectorCallKwBuilder.proto (used by CIntToPy) */ CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n); #if CYTHON_VECTORCALL @@ -2336,6 +2395,26 @@ static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, P #define __Pyx_VectorcallBuilder_AddArgStr(key, value, builder, args, n) PyDict_SetItemString(builder, key, value) #endif +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyLong_From_uint64_t(uint64_t value); + +/* FormatTypeName.proto */ +#if CYTHON_COMPILING_IN_LIMITED_API +typedef PyObject *__Pyx_TypeName; +#define __Pyx_FMT_TYPENAME "%U" +#define __Pyx_DECREF_TypeName(obj) Py_XDECREF(obj) +#if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 +#define __Pyx_PyType_GetFullyQualifiedName PyType_GetFullyQualifiedName +#else +static __Pyx_TypeName __Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp); +#endif +#else // !LIMITED_API +typedef const char *__Pyx_TypeName; +#define __Pyx_FMT_TYPENAME "%.200s" +#define __Pyx_PyType_GetFullyQualifiedName(tp) ((tp)->tp_name) +#define __Pyx_DECREF_TypeName(obj) +#endif + /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value); @@ -2431,6 +2510,9 @@ static int __Pyx_State_RemoveModule(void*); #define __PYX_ABI_MODULE_NAME "_cython_" CYTHON_ABI #define __PYX_TYPE_MODULE_PREFIX __PYX_ABI_MODULE_NAME "." +static struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_from_ptr(::Block *__pyx_v_block, struct __pyx_opt_args_18polluck_blockchain_18placeholder_native_7PyBlock_from_ptr *__pyx_optional_args); /* proto*/ +static ::Block *__pyx_f_18polluck_blockchain_18placeholder_native_10Blockchain_get_block_c(struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_v_self, uint64_t __pyx_v_idx); /* proto*/ +static void __pyx_f_18polluck_blockchain_18placeholder_native_10Blockchain_add_block(struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_v_self, ::Block *__pyx_v_block); /* proto*/ /* Module declarations from "cython" */ @@ -2451,6 +2533,7 @@ static int __Pyx_State_RemoveModule(void*); /* Module declarations from "libcpp.unordered_map" */ /* Module declarations from "polluck_blockchain.placeholder_native" */ +static PyObject *__pyx_f_18polluck_blockchain_18placeholder_native_timestamp_to_datetime(double); /*proto*/ static std::string __pyx_convert_string_from_py_6libcpp_6string_std__in_string(PyObject *); /*proto*/ static CYTHON_INLINE PyObject *__pyx_convert_PyObject_string_to_py_6libcpp_6string_std__in_string(std::string const &); /*proto*/ static CYTHON_INLINE PyObject *__pyx_convert_PyUnicode_string_to_py_6libcpp_6string_std__in_string(std::string const &); /*proto*/ @@ -2466,11 +2549,30 @@ int __pyx_module_is_main_polluck_blockchain__placeholder_native = 0; /* #### Code section: global_var ### */ /* #### Code section: string_decls ### */ /* #### Code section: decls ### */ -static int __pyx_pf_18polluck_blockchain_18placeholder_native_7BlockPy___cinit__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_BlockPy *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_data, PyObject *__pyx_v_previous_hash, PyObject *__pyx_v_nonce); /* proto */ -static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7BlockPy_2get_data(struct __pyx_obj_18polluck_blockchain_18placeholder_native_BlockPy *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7BlockPy_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_18polluck_blockchain_18placeholder_native_BlockPy *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7BlockPy_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_18polluck_blockchain_18placeholder_native_BlockPy *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ -static PyObject *__pyx_tp_new_18polluck_blockchain_18placeholder_native_BlockPy(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static int __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock___cinit__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_nonce, PyObject *__pyx_v_data, PyObject *__pyx_v_previous_hash, PyObject *__pyx_v_from_ptr); /* proto */ +static int __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_2__init__(CYTHON_UNUSED struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs); /* proto */ +static void __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_4__dealloc__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_5index___get__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_9timestamp___get__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_4data___get__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_9prev_hash___get__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_5nonce___get__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_4hash___get__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_6__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_8__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static int __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain___cinit__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_v_self); /* proto */ +static int __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_2__init__(CYTHON_UNUSED struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs); /* proto */ +static void __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_4__dealloc__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_v_self); /* proto */ +static Py_ssize_t __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_6__len__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_12genesis_done___get__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_5index___get__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_8get_block(struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_v_self, PyObject *__pyx_v_idx); /* proto */ +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_10create_genesis_block(struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_12new_block(struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_v_self, PyObject *__pyx_v_data); /* proto */ +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_14__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_16__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static PyObject *__pyx_tp_new_18polluck_blockchain_18placeholder_native_PyBlock(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_18polluck_blockchain_18placeholder_native_Blockchain(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ /* #### Code section: late_includes ### */ /* #### Code section: module_state ### */ /* SmallCodeConfig */ @@ -2491,14 +2593,16 @@ typedef struct { PyObject *__pyx_empty_tuple; PyObject *__pyx_empty_bytes; PyObject *__pyx_empty_unicode; - PyObject *__pyx_type_18polluck_blockchain_18placeholder_native_BlockPy; - PyTypeObject *__pyx_ptype_18polluck_blockchain_18placeholder_native_BlockPy; + PyObject *__pyx_type_18polluck_blockchain_18placeholder_native_PyBlock; + PyObject *__pyx_type_18polluck_blockchain_18placeholder_native_Blockchain; + PyTypeObject *__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock; + PyTypeObject *__pyx_ptype_18polluck_blockchain_18placeholder_native_Blockchain; __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_items; __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_pop; __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_values; PyObject *__pyx_tuple[1]; - PyObject *__pyx_codeobj_tab[3]; - PyObject *__pyx_string_tab[57]; + PyObject *__pyx_codeobj_tab[7]; + PyObject *__pyx_string_tab[80]; PyObject *__pyx_number_tab[4]; /* #### Code section: module_state_contents ### */ /* CommonTypesMetaclass.module_state_decls */ @@ -2540,63 +2644,86 @@ static __pyx_mstatetype __pyx_mstate_global_static = static __pyx_mstatetype * const __pyx_mstate_global = &__pyx_mstate_global_static; #endif /* #### Code section: constant_name_defines ### */ -#define __pyx_kp_u_Note_that_Cython_is_deliberately __pyx_string_tab[0] -#define __pyx_kp_u__2 __pyx_string_tab[1] -#define __pyx_kp_u_add_note __pyx_string_tab[2] -#define __pyx_kp_u_d __pyx_string_tab[3] -#define __pyx_kp_u_disable __pyx_string_tab[4] -#define __pyx_kp_u_enable __pyx_string_tab[5] -#define __pyx_kp_u_gc __pyx_string_tab[6] -#define __pyx_kp_u_isenabled __pyx_string_tab[7] -#define __pyx_kp_u_no_default___reduce___due_to_non __pyx_string_tab[8] -#define __pyx_kp_u_src_polluck_blockchain_placehold __pyx_string_tab[9] -#define __pyx_kp_u_stringsource __pyx_string_tab[10] -#define __pyx_n_u_BlockPy __pyx_string_tab[11] -#define __pyx_n_u_BlockPy___reduce_cython __pyx_string_tab[12] -#define __pyx_n_u_BlockPy___setstate_cython __pyx_string_tab[13] -#define __pyx_n_u_BlockPy_get_data __pyx_string_tab[14] -#define __pyx_n_u_Pyx_PyDict_NextRef __pyx_string_tab[15] -#define __pyx_n_u_TIMEZONE_UTC __pyx_string_tab[16] -#define __pyx_n_u_asyncio_coroutines __pyx_string_tab[17] -#define __pyx_n_u_cline_in_traceback __pyx_string_tab[18] -#define __pyx_n_u_data __pyx_string_tab[19] -#define __pyx_n_u_datetime __pyx_string_tab[20] -#define __pyx_n_u_dopt_basics __pyx_string_tab[21] -#define __pyx_n_u_dopt_basics_datetime __pyx_string_tab[22] -#define __pyx_n_u_fromtimestamp __pyx_string_tab[23] -#define __pyx_n_u_func __pyx_string_tab[24] -#define __pyx_n_u_get_data __pyx_string_tab[25] -#define __pyx_n_u_getstate __pyx_string_tab[26] -#define __pyx_n_u_hashlib __pyx_string_tab[27] -#define __pyx_n_u_index __pyx_string_tab[28] -#define __pyx_n_u_is_coroutine __pyx_string_tab[29] -#define __pyx_n_u_items __pyx_string_tab[30] -#define __pyx_n_u_main __pyx_string_tab[31] -#define __pyx_n_u_module __pyx_string_tab[32] -#define __pyx_n_u_name __pyx_string_tab[33] -#define __pyx_n_u_nonce __pyx_string_tab[34] -#define __pyx_n_u_pack __pyx_string_tab[35] -#define __pyx_n_u_polluck_blockchain_placeholder_n __pyx_string_tab[36] -#define __pyx_n_u_pop __pyx_string_tab[37] -#define __pyx_n_u_previous_hash __pyx_string_tab[38] -#define __pyx_n_u_pyx_state __pyx_string_tab[39] -#define __pyx_n_u_qualname __pyx_string_tab[40] -#define __pyx_n_u_reduce __pyx_string_tab[41] -#define __pyx_n_u_reduce_cython __pyx_string_tab[42] -#define __pyx_n_u_reduce_ex __pyx_string_tab[43] -#define __pyx_n_u_self __pyx_string_tab[44] -#define __pyx_n_u_set_name __pyx_string_tab[45] -#define __pyx_n_u_setdefault __pyx_string_tab[46] -#define __pyx_n_u_setstate __pyx_string_tab[47] -#define __pyx_n_u_setstate_cython __pyx_string_tab[48] -#define __pyx_n_u_struct __pyx_string_tab[49] -#define __pyx_n_u_test __pyx_string_tab[50] -#define __pyx_n_u_time __pyx_string_tab[51] -#define __pyx_n_u_timestamp __pyx_string_tab[52] -#define __pyx_n_u_values __pyx_string_tab[53] -#define __pyx_kp_b_ __pyx_string_tab[54] -#define __pyx_kp_b_iso88591_A_t6_gQa __pyx_string_tab[55] -#define __pyx_kp_b_iso88591_Q __pyx_string_tab[56] +#define __pyx_kp_u_Allocation_of_block_object_faile __pyx_string_tab[0] +#define __pyx_kp_u_Could_not_allocate_hasmap __pyx_string_tab[1] +#define __pyx_kp_u_Create_a_genesis_block_first __pyx_string_tab[2] +#define __pyx_kp_u_Index_value_is_out_of_bounds __pyx_string_tab[3] +#define __pyx_kp_u_UTF_8 __pyx_string_tab[4] +#define __pyx_kp_u__2 __pyx_string_tab[5] +#define __pyx_kp_u_d __pyx_string_tab[6] +#define __pyx_kp_u_disable __pyx_string_tab[7] +#define __pyx_kp_u_enable __pyx_string_tab[8] +#define __pyx_kp_u_gc __pyx_string_tab[9] +#define __pyx_kp_u_isenabled __pyx_string_tab[10] +#define __pyx_kp_u_no_default___reduce___due_to_non __pyx_string_tab[11] +#define __pyx_kp_u_src_polluck_blockchain_placehold __pyx_string_tab[12] +#define __pyx_kp_u_stringsource __pyx_string_tab[13] +#define __pyx_n_u_Blockchain __pyx_string_tab[14] +#define __pyx_n_u_Blockchain___reduce_cython __pyx_string_tab[15] +#define __pyx_n_u_Blockchain___setstate_cython __pyx_string_tab[16] +#define __pyx_n_u_Blockchain_create_genesis_block __pyx_string_tab[17] +#define __pyx_n_u_Blockchain_get_block __pyx_string_tab[18] +#define __pyx_n_u_Blockchain_new_block __pyx_string_tab[19] +#define __pyx_n_u_PyBlock __pyx_string_tab[20] +#define __pyx_n_u_PyBlock___reduce_cython __pyx_string_tab[21] +#define __pyx_n_u_PyBlock___setstate_cython __pyx_string_tab[22] +#define __pyx_n_u_Pyx_PyDict_NextRef __pyx_string_tab[23] +#define __pyx_n_u_TIMEZONE_UTC __pyx_string_tab[24] +#define __pyx_n_u_asyncio_coroutines __pyx_string_tab[25] +#define __pyx_n_u_block __pyx_string_tab[26] +#define __pyx_n_u_cline_in_traceback __pyx_string_tab[27] +#define __pyx_n_u_create_genesis_block __pyx_string_tab[28] +#define __pyx_n_u_data __pyx_string_tab[29] +#define __pyx_n_u_datetime __pyx_string_tab[30] +#define __pyx_n_u_dopt_basics __pyx_string_tab[31] +#define __pyx_n_u_dopt_basics_datetime __pyx_string_tab[32] +#define __pyx_n_u_encode __pyx_string_tab[33] +#define __pyx_n_u_from_ptr __pyx_string_tab[34] +#define __pyx_n_u_fromtimestamp __pyx_string_tab[35] +#define __pyx_n_u_func __pyx_string_tab[36] +#define __pyx_n_u_get_block __pyx_string_tab[37] +#define __pyx_n_u_getstate __pyx_string_tab[38] +#define __pyx_n_u_hashlib __pyx_string_tab[39] +#define __pyx_n_u_idx __pyx_string_tab[40] +#define __pyx_n_u_index __pyx_string_tab[41] +#define __pyx_n_u_is_coroutine __pyx_string_tab[42] +#define __pyx_n_u_items __pyx_string_tab[43] +#define __pyx_n_u_main __pyx_string_tab[44] +#define __pyx_n_u_module __pyx_string_tab[45] +#define __pyx_n_u_name __pyx_string_tab[46] +#define __pyx_n_u_new_block __pyx_string_tab[47] +#define __pyx_n_u_new_idx __pyx_string_tab[48] +#define __pyx_n_u_nonce __pyx_string_tab[49] +#define __pyx_n_u_pack __pyx_string_tab[50] +#define __pyx_n_u_polluck_blockchain_placeholder_n __pyx_string_tab[51] +#define __pyx_n_u_pop __pyx_string_tab[52] +#define __pyx_n_u_prev_block __pyx_string_tab[53] +#define __pyx_n_u_prev_hash __pyx_string_tab[54] +#define __pyx_n_u_previous_hash __pyx_string_tab[55] +#define __pyx_n_u_pyx_state __pyx_string_tab[56] +#define __pyx_n_u_pyx_vtable __pyx_string_tab[57] +#define __pyx_n_u_qualname __pyx_string_tab[58] +#define __pyx_n_u_reduce __pyx_string_tab[59] +#define __pyx_n_u_reduce_cython __pyx_string_tab[60] +#define __pyx_n_u_reduce_ex __pyx_string_tab[61] +#define __pyx_n_u_self __pyx_string_tab[62] +#define __pyx_n_u_set_name __pyx_string_tab[63] +#define __pyx_n_u_setdefault __pyx_string_tab[64] +#define __pyx_n_u_setstate __pyx_string_tab[65] +#define __pyx_n_u_setstate_cython __pyx_string_tab[66] +#define __pyx_n_u_struct __pyx_string_tab[67] +#define __pyx_n_u_test __pyx_string_tab[68] +#define __pyx_n_u_time __pyx_string_tab[69] +#define __pyx_n_u_timestamp __pyx_string_tab[70] +#define __pyx_n_u_values __pyx_string_tab[71] +#define __pyx_kp_b_ __pyx_string_tab[72] +#define __pyx_kp_b_0 __pyx_string_tab[73] +#define __pyx_kp_b_Genesis_Block __pyx_string_tab[74] +#define __pyx_kp_b_dummy_hash __pyx_string_tab[75] +#define __pyx_kp_b_iso88591_A_4r_3d_D_AQ_D_AQ_iq_Q __pyx_string_tab[76] +#define __pyx_kp_b_iso88591_A_4t1_aq_a_HBa_IQ_IQfD_4s_Ja_q_g __pyx_string_tab[77] +#define __pyx_kp_b_iso88591_A_IQ_IQfD_4s_Ja_7_1_waq_gQa_XX_J __pyx_string_tab[78] +#define __pyx_kp_b_iso88591_Q __pyx_string_tab[79] #define __pyx_int_0 __pyx_number_tab[0] #define __pyx_int_1 __pyx_number_tab[1] #define __pyx_int_12 __pyx_number_tab[2] @@ -2615,11 +2742,13 @@ static CYTHON_SMALL_CODE int __pyx_m_clear(PyObject *m) { #if CYTHON_PEP489_MULTI_PHASE_INIT __Pyx_State_RemoveModule(NULL); #endif - Py_CLEAR(clear_module_state->__pyx_ptype_18polluck_blockchain_18placeholder_native_BlockPy); - Py_CLEAR(clear_module_state->__pyx_type_18polluck_blockchain_18placeholder_native_BlockPy); + Py_CLEAR(clear_module_state->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock); + Py_CLEAR(clear_module_state->__pyx_type_18polluck_blockchain_18placeholder_native_PyBlock); + Py_CLEAR(clear_module_state->__pyx_ptype_18polluck_blockchain_18placeholder_native_Blockchain); + Py_CLEAR(clear_module_state->__pyx_type_18polluck_blockchain_18placeholder_native_Blockchain); for (int i=0; i<1; ++i) { Py_CLEAR(clear_module_state->__pyx_tuple[i]); } - for (int i=0; i<3; ++i) { Py_CLEAR(clear_module_state->__pyx_codeobj_tab[i]); } - for (int i=0; i<57; ++i) { Py_CLEAR(clear_module_state->__pyx_string_tab[i]); } + for (int i=0; i<7; ++i) { Py_CLEAR(clear_module_state->__pyx_codeobj_tab[i]); } + for (int i=0; i<80; ++i) { Py_CLEAR(clear_module_state->__pyx_string_tab[i]); } for (int i=0; i<4; ++i) { Py_CLEAR(clear_module_state->__pyx_number_tab[i]); } /* #### Code section: module_state_clear_contents ### */ /* CommonTypesMetaclass.module_state_clear */ @@ -2643,11 +2772,13 @@ static CYTHON_SMALL_CODE int __pyx_m_traverse(PyObject *m, visitproc visit, void __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_tuple); __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_bytes); __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_unicode); - Py_VISIT(traverse_module_state->__pyx_ptype_18polluck_blockchain_18placeholder_native_BlockPy); - Py_VISIT(traverse_module_state->__pyx_type_18polluck_blockchain_18placeholder_native_BlockPy); + Py_VISIT(traverse_module_state->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock); + Py_VISIT(traverse_module_state->__pyx_type_18polluck_blockchain_18placeholder_native_PyBlock); + Py_VISIT(traverse_module_state->__pyx_ptype_18polluck_blockchain_18placeholder_native_Blockchain); + Py_VISIT(traverse_module_state->__pyx_type_18polluck_blockchain_18placeholder_native_Blockchain); for (int i=0; i<1; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_tuple[i]); } - for (int i=0; i<3; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_codeobj_tab[i]); } - for (int i=0; i<57; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_string_tab[i]); } + for (int i=0; i<7; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_codeobj_tab[i]); } + for (int i=0; i<80; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_string_tab[i]); } for (int i=0; i<4; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_number_tab[i]); } /* #### Code section: module_state_traverse_contents ### */ /* CommonTypesMetaclass.module_state_traverse */ @@ -3043,8 +3174,8 @@ static CYTHON_INLINE PyObject *__pyx_convert_PyByteArray_string_to_py_6libcpp_6s return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":36 - * +/* "polluck_blockchain/placeholder_native.pyx":24 + * ctypedef unordered_map[uint64_t, Block*] BcHashmap * * cdef timestamp_to_datetime(double ts): # <<<<<<<<<<<<<< * return datetime.datetime.fromtimestamp(ts, dopt_basics.datetime.TIMEZONE_UTC) @@ -3066,7 +3197,7 @@ static PyObject *__pyx_f_18polluck_blockchain_18placeholder_native_timestamp_to_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("timestamp_to_datetime", 0); - /* "polluck_blockchain/placeholder_native.pyx":37 + /* "polluck_blockchain/placeholder_native.pyx":25 * * cdef timestamp_to_datetime(double ts): * return datetime.datetime.fromtimestamp(ts, dopt_basics.datetime.TIMEZONE_UTC) # <<<<<<<<<<<<<< @@ -3074,21 +3205,21 @@ static PyObject *__pyx_f_18polluck_blockchain_18placeholder_native_timestamp_to_ * */ __Pyx_XDECREF(__pyx_r); - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 37, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 37, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = __pyx_t_4; __Pyx_INCREF(__pyx_t_2); - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_ts); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 37, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_ts); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_dopt_basics); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 37, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_dopt_basics); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 37, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_TIMEZONE_UTC); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 37, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_TIMEZONE_UTC); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_7 = 0; @@ -3099,15 +3230,15 @@ static PyObject *__pyx_f_18polluck_blockchain_18placeholder_native_timestamp_to_ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error) + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "polluck_blockchain/placeholder_native.pyx":36 - * + /* "polluck_blockchain/placeholder_native.pyx":24 + * ctypedef unordered_map[uint64_t, Block*] BcHashmap * * cdef timestamp_to_datetime(double ts): # <<<<<<<<<<<<<< * return datetime.datetime.fromtimestamp(ts, dopt_basics.datetime.TIMEZONE_UTC) @@ -3130,7 +3261,7 @@ static PyObject *__pyx_f_18polluck_blockchain_18placeholder_native_timestamp_to_ return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":76 +/* "polluck_blockchain/placeholder_native.pyx":28 * * * cdef float_to_bytes(double num): # <<<<<<<<<<<<<< @@ -3151,21 +3282,21 @@ static PyObject *__pyx_f_18polluck_blockchain_18placeholder_native_float_to_byte int __pyx_clineno = 0; __Pyx_RefNannySetupContext("float_to_bytes", 0); - /* "polluck_blockchain/placeholder_native.pyx":77 + /* "polluck_blockchain/placeholder_native.pyx":29 * * cdef float_to_bytes(double num): * return struct.pack(">d", num) # <<<<<<<<<<<<<< * - * # cdef struct BlockC: + * */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = NULL; - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_struct); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 77, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_struct); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_pack); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 77, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_pack); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_num); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 77, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_num); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = 1; #if CYTHON_UNPACK_METHODS @@ -3185,14 +3316,14 @@ static PyObject *__pyx_f_18polluck_blockchain_18placeholder_native_float_to_byte __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 77, __pyx_L1_error) + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "polluck_blockchain/placeholder_native.pyx":76 + /* "polluck_blockchain/placeholder_native.pyx":28 * * * cdef float_to_bytes(double num): # <<<<<<<<<<<<<< @@ -3214,24 +3345,25 @@ static PyObject *__pyx_f_18polluck_blockchain_18placeholder_native_float_to_byte return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":98 - * Block* Block +/* "polluck_blockchain/placeholder_native.pyx":43 + * bint ptr_owner * * def __cinit__(self, # <<<<<<<<<<<<<< - * index: int, - * data: str, + * index, + * nonce, */ /* Python wrapper */ -static int __pyx_pw_18polluck_blockchain_18placeholder_native_7BlockPy_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pw_18polluck_blockchain_18placeholder_native_7BlockPy_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static int __pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_index = 0; + PyObject *__pyx_v_nonce = 0; PyObject *__pyx_v_data = 0; PyObject *__pyx_v_previous_hash = 0; - PyObject *__pyx_v_nonce = 0; + PyObject *__pyx_v_from_ptr = 0; CYTHON_UNUSED Py_ssize_t __pyx_nargs; CYTHON_UNUSED PyObject *const *__pyx_kwvalues; - PyObject* values[4] = {0,0,0,0}; + PyObject* values[5] = {0,0,0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -3245,313 +3377,1010 @@ static int __pyx_pw_18polluck_blockchain_18placeholder_native_7BlockPy_1__cinit_ #endif __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); { - PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_index,&__pyx_mstate_global->__pyx_n_u_data,&__pyx_mstate_global->__pyx_n_u_previous_hash,&__pyx_mstate_global->__pyx_n_u_nonce,0}; + PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_index,&__pyx_mstate_global->__pyx_n_u_nonce,&__pyx_mstate_global->__pyx_n_u_data,&__pyx_mstate_global->__pyx_n_u_previous_hash,&__pyx_mstate_global->__pyx_n_u_from_ptr,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_VARARGS(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 98, __pyx_L3_error) + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 43, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { + case 5: + values[4] = __Pyx_ArgRef_VARARGS(__pyx_args, 4); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 43, __pyx_L3_error) + CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_ArgRef_VARARGS(__pyx_args, 3); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 98, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 43, __pyx_L3_error) CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_ArgRef_VARARGS(__pyx_args, 2); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 98, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 43, __pyx_L3_error) CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_ArgRef_VARARGS(__pyx_args, 1); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 98, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 43, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_VARARGS(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 98, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 43, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; - if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "__cinit__", 0) < (0)) __PYX_ERR(0, 98, __pyx_L3_error) + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "__cinit__", 0) < (0)) __PYX_ERR(0, 43, __pyx_L3_error) + + /* "polluck_blockchain/placeholder_native.pyx":48 + * data, + * previous_hash, + * from_ptr=False, # <<<<<<<<<<<<<< + * ): + * self.ptr_owner = False +*/ + if (!values[4]) values[4] = __Pyx_NewRef(((PyObject *)Py_False)); for (Py_ssize_t i = __pyx_nargs; i < 4; i++) { - if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 4, 4, i); __PYX_ERR(0, 98, __pyx_L3_error) } + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, i); __PYX_ERR(0, 43, __pyx_L3_error) } } - } else if (unlikely(__pyx_nargs != 4)) { - goto __pyx_L5_argtuple_error; } else { - values[0] = __Pyx_ArgRef_VARARGS(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 98, __pyx_L3_error) - values[1] = __Pyx_ArgRef_VARARGS(__pyx_args, 1); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 98, __pyx_L3_error) - values[2] = __Pyx_ArgRef_VARARGS(__pyx_args, 2); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 98, __pyx_L3_error) - values[3] = __Pyx_ArgRef_VARARGS(__pyx_args, 3); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 98, __pyx_L3_error) + switch (__pyx_nargs) { + case 5: + values[4] = __Pyx_ArgRef_VARARGS(__pyx_args, 4); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 43, __pyx_L3_error) + CYTHON_FALLTHROUGH; + case 4: + values[3] = __Pyx_ArgRef_VARARGS(__pyx_args, 3); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 43, __pyx_L3_error) + values[2] = __Pyx_ArgRef_VARARGS(__pyx_args, 2); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 43, __pyx_L3_error) + values[1] = __Pyx_ArgRef_VARARGS(__pyx_args, 1); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 43, __pyx_L3_error) + values[0] = __Pyx_ArgRef_VARARGS(__pyx_args, 0); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 43, __pyx_L3_error) + break; + default: goto __pyx_L5_argtuple_error; + } + if (!values[4]) values[4] = __Pyx_NewRef(((PyObject *)Py_False)); } - if (__Pyx_PyInt_FromNumber(&values[0], "index", 0) < (0)) __PYX_ERR(0, 99, __pyx_L3_error) - __pyx_v_index = ((PyObject*)values[0]); - __pyx_v_data = ((PyObject*)values[1]); - __pyx_v_previous_hash = ((PyObject*)values[2]); - if (__Pyx_PyInt_FromNumber(&values[3], "nonce", 0) < (0)) __PYX_ERR(0, 102, __pyx_L3_error) - __pyx_v_nonce = ((PyObject*)values[3]); + __pyx_v_index = values[0]; + __pyx_v_nonce = values[1]; + __pyx_v_data = values[2]; + __pyx_v_previous_hash = values[3]; + __pyx_v_from_ptr = values[4]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 4, 4, __pyx_nargs); __PYX_ERR(0, 98, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, __pyx_nargs); __PYX_ERR(0, 43, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } - __Pyx_AddTraceback("polluck_blockchain.placeholder_native.BlockPy.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("polluck_blockchain.placeholder_native.PyBlock.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_index), (&PyLong_Type), 0, "index", 2))) __PYX_ERR(0, 99, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_data), (&PyUnicode_Type), 0, "data", 2))) __PYX_ERR(0, 100, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_previous_hash), (&PyUnicode_Type), 0, "previous_hash", 2))) __PYX_ERR(0, 101, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_nonce), (&PyLong_Type), 0, "nonce", 2))) __PYX_ERR(0, 102, __pyx_L1_error) - __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_7BlockPy___cinit__(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_BlockPy *)__pyx_v_self), __pyx_v_index, __pyx_v_data, __pyx_v_previous_hash, __pyx_v_nonce); + __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock___cinit__(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_v_self), __pyx_v_index, __pyx_v_nonce, __pyx_v_data, __pyx_v_previous_hash, __pyx_v_from_ptr); + + /* "polluck_blockchain/placeholder_native.pyx":43 + * bint ptr_owner + * + * def __cinit__(self, # <<<<<<<<<<<<<< + * index, + * nonce, +*/ /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = -1; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } - goto __pyx_L7_cleaned_up; - __pyx_L0:; - for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { - Py_XDECREF(values[__pyx_temp]); - } - __pyx_L7_cleaned_up:; __Pyx_RefNannyFinishContext(); return __pyx_r; } -static int __pyx_pf_18polluck_blockchain_18placeholder_native_7BlockPy___cinit__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_BlockPy *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_data, PyObject *__pyx_v_previous_hash, PyObject *__pyx_v_nonce) { +static int __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock___cinit__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_nonce, PyObject *__pyx_v_data, PyObject *__pyx_v_previous_hash, PyObject *__pyx_v_from_ptr) { int __pyx_r; __Pyx_RefNannyDeclarations - uint64_t __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; + int __pyx_t_1; + int __pyx_t_2; + uint64_t __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; - size_t __pyx_t_6; - double __pyx_t_7; - uint64_t __pyx_t_8; - std::string __pyx_t_9; - std::string __pyx_t_10; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + size_t __pyx_t_8; + double __pyx_t_9; + uint64_t __pyx_t_10; std::string __pyx_t_11; - ::Block *__pyx_t_12; + std::string __pyx_t_12; + std::string __pyx_t_13; + ::Block *__pyx_t_14; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "polluck_blockchain/placeholder_native.pyx":105 + /* "polluck_blockchain/placeholder_native.pyx":50 + * from_ptr=False, * ): - * self.Block = new Block( - * index, # <<<<<<<<<<<<<< - * datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp(), - * nonce, + * self.ptr_owner = False # <<<<<<<<<<<<<< + * if not from_ptr: + * self.BlockC = new Block( */ - __pyx_t_1 = __Pyx_PyLong_As_uint64_t(__pyx_v_index); if (unlikely((__pyx_t_1 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 105, __pyx_L1_error) + __pyx_v_self->ptr_owner = 0; - /* "polluck_blockchain/placeholder_native.pyx":106 - * self.Block = new Block( - * index, - * datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp(), # <<<<<<<<<<<<<< - * nonce, - * data.encode("UTF-8"), + /* "polluck_blockchain/placeholder_native.pyx":51 + * ): + * self.ptr_owner = False + * if not from_ptr: # <<<<<<<<<<<<<< + * self.BlockC = new Block( + * index, */ - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 106, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 106, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_mstate_global->__pyx_tuple[0], NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 106, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_3 = __pyx_t_4; - __Pyx_INCREF(__pyx_t_3); - __pyx_t_6 = 0; - { - PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; - __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_timestamp, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_from_ptr); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 51, __pyx_L1_error) + __pyx_t_2 = (!__pyx_t_1); + if (__pyx_t_2) { + + /* "polluck_blockchain/placeholder_native.pyx":53 + * if not from_ptr: + * self.BlockC = new Block( + * index, # <<<<<<<<<<<<<< + * datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp(), + * nonce, +*/ + __pyx_t_3 = __Pyx_PyLong_As_uint64_t(__pyx_v_index); if (unlikely((__pyx_t_3 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 53, __pyx_L1_error) + + /* "polluck_blockchain/placeholder_native.pyx":54 + * self.BlockC = new Block( + * index, + * datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp(), # <<<<<<<<<<<<<< + * nonce, + * data.encode("UTF-8"), +*/ + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 54, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 54, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_mstate_global->__pyx_tuple[0], NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 54, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_5 = __pyx_t_6; + __Pyx_INCREF(__pyx_t_5); + __pyx_t_8 = 0; + { + PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL}; + __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_timestamp, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 54, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + } + __pyx_t_9 = __Pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 106, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - } - __pyx_t_7 = __Pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 106, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "polluck_blockchain/placeholder_native.pyx":107 - * index, - * datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp(), - * nonce, # <<<<<<<<<<<<<< - * data.encode("UTF-8"), - * previous_hash.encode("UTF-8"), + /* "polluck_blockchain/placeholder_native.pyx":55 + * index, + * datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp(), + * nonce, # <<<<<<<<<<<<<< + * data.encode("UTF-8"), + * previous_hash.encode("UTF-8"), */ - __pyx_t_8 = __Pyx_PyLong_As_uint64_t(__pyx_v_nonce); if (unlikely((__pyx_t_8 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 107, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyLong_As_uint64_t(__pyx_v_nonce); if (unlikely((__pyx_t_10 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 55, __pyx_L1_error) - /* "polluck_blockchain/placeholder_native.pyx":108 - * datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp(), - * nonce, - * data.encode("UTF-8"), # <<<<<<<<<<<<<< - * previous_hash.encode("UTF-8"), - * "".encode("UTF-8"), + /* "polluck_blockchain/placeholder_native.pyx":56 + * datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp(), + * nonce, + * data.encode("UTF-8"), # <<<<<<<<<<<<<< + * previous_hash.encode("UTF-8"), + * "".encode("UTF-8"), */ - __pyx_t_2 = PyUnicode_AsUTF8String(__pyx_v_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 108, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_9 = __pyx_convert_string_from_py_6libcpp_6string_std__in_string(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 108, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_6 = __pyx_v_data; + __Pyx_INCREF(__pyx_t_6); + __pyx_t_8 = 0; + { + PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_UTF_8}; + __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_encode, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 56, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + } + __pyx_t_11 = __pyx_convert_string_from_py_6libcpp_6string_std__in_string(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 56, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "polluck_blockchain/placeholder_native.pyx":109 - * nonce, - * data.encode("UTF-8"), - * previous_hash.encode("UTF-8"), # <<<<<<<<<<<<<< - * "".encode("UTF-8"), - * ) + /* "polluck_blockchain/placeholder_native.pyx":57 + * nonce, + * data.encode("UTF-8"), + * previous_hash.encode("UTF-8"), # <<<<<<<<<<<<<< + * "".encode("UTF-8"), + * ) */ - __pyx_t_2 = PyUnicode_AsUTF8String(__pyx_v_previous_hash); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 109, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_10 = __pyx_convert_string_from_py_6libcpp_6string_std__in_string(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 109, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_6 = __pyx_v_previous_hash; + __Pyx_INCREF(__pyx_t_6); + __pyx_t_8 = 0; + { + PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_UTF_8}; + __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_encode, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 57, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + } + __pyx_t_12 = __pyx_convert_string_from_py_6libcpp_6string_std__in_string(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 57, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "polluck_blockchain/placeholder_native.pyx":110 - * data.encode("UTF-8"), - * previous_hash.encode("UTF-8"), - * "".encode("UTF-8"), # <<<<<<<<<<<<<< - * ) + /* "polluck_blockchain/placeholder_native.pyx":58 + * data.encode("UTF-8"), + * previous_hash.encode("UTF-8"), + * "".encode("UTF-8"), # <<<<<<<<<<<<<< + * ) + * if self.BlockC == NULL: +*/ + __pyx_t_13 = __pyx_convert_string_from_py_6libcpp_6string_std__in_string(__pyx_mstate_global->__pyx_kp_b_); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 58, __pyx_L1_error) + + /* "polluck_blockchain/placeholder_native.pyx":52 + * self.ptr_owner = False + * if not from_ptr: + * self.BlockC = new Block( # <<<<<<<<<<<<<< + * index, + * datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp(), +*/ + try { + __pyx_t_14 = new ::Block(__pyx_t_3, __pyx_t_9, __pyx_t_10, __pyx_t_11, __pyx_t_12, __pyx_t_13); + } catch(...) { + __Pyx_CppExn2PyErr(); + __PYX_ERR(0, 52, __pyx_L1_error) + } + __pyx_v_self->BlockC = __pyx_t_14; + + /* "polluck_blockchain/placeholder_native.pyx":60 + * "".encode("UTF-8"), + * ) + * if self.BlockC == NULL: # <<<<<<<<<<<<<< + * raise MemoryError("Allocation of block object failed") * */ - __pyx_t_11 = __pyx_convert_string_from_py_6libcpp_6string_std__in_string(__pyx_mstate_global->__pyx_kp_b_); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 110, __pyx_L1_error) + __pyx_t_2 = (__pyx_v_self->BlockC == NULL); + if (unlikely(__pyx_t_2)) { - /* "polluck_blockchain/placeholder_native.pyx":104 - * nonce: int, - * ): - * self.Block = new Block( # <<<<<<<<<<<<<< - * index, - * datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp(), + /* "polluck_blockchain/placeholder_native.pyx":61 + * ) + * if self.BlockC == NULL: + * raise MemoryError("Allocation of block object failed") # <<<<<<<<<<<<<< + * + * self.ptr_owner = True */ - try { - __pyx_t_12 = new ::Block(__pyx_t_1, __pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10, __pyx_t_11); - } catch(...) { - __Pyx_CppExn2PyErr(); - __PYX_ERR(0, 104, __pyx_L1_error) - } - __pyx_v_self->Block = __pyx_t_12; + __pyx_t_6 = NULL; + __pyx_t_8 = 1; + { + PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Allocation_of_block_object_faile}; + __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_MemoryError)), __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 61, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + } + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __PYX_ERR(0, 61, __pyx_L1_error) - /* "polluck_blockchain/placeholder_native.pyx":98 - * Block* Block + /* "polluck_blockchain/placeholder_native.pyx":60 + * "".encode("UTF-8"), + * ) + * if self.BlockC == NULL: # <<<<<<<<<<<<<< + * raise MemoryError("Allocation of block object failed") + * +*/ + } + + /* "polluck_blockchain/placeholder_native.pyx":63 + * raise MemoryError("Allocation of block object failed") + * + * self.ptr_owner = True # <<<<<<<<<<<<<< + * + * def __init__(self, *args, **kwargs): +*/ + __pyx_v_self->ptr_owner = 1; + + /* "polluck_blockchain/placeholder_native.pyx":51 + * ): + * self.ptr_owner = False + * if not from_ptr: # <<<<<<<<<<<<<< + * self.BlockC = new Block( + * index, +*/ + } + + /* "polluck_blockchain/placeholder_native.pyx":43 + * bint ptr_owner * * def __cinit__(self, # <<<<<<<<<<<<<< - * index: int, - * data: str, + * index, + * nonce, */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("polluck_blockchain.placeholder_native.BlockPy.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_AddTraceback("polluck_blockchain.placeholder_native.PyBlock.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":113 - * ) - * - * def get_data(self): # <<<<<<<<<<<<<< - * return self.Block.data.decode("UTF-8") +/* "polluck_blockchain/placeholder_native.pyx":65 + * self.ptr_owner = True * + * def __init__(self, *args, **kwargs): # <<<<<<<<<<<<<< + * pass + * # self._index = index */ /* Python wrapper */ -static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7BlockPy_3get_data(PyObject *__pyx_v_self, -#if CYTHON_METH_FASTCALL -PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds -#else -PyObject *__pyx_args, PyObject *__pyx_kwds -#endif -); /*proto*/ -static PyMethodDef __pyx_mdef_18polluck_blockchain_18placeholder_native_7BlockPy_3get_data = {"get_data", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_7BlockPy_3get_data, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7BlockPy_3get_data(PyObject *__pyx_v_self, -#if CYTHON_METH_FASTCALL -PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds -#else -PyObject *__pyx_args, PyObject *__pyx_kwds -#endif -) { - #if !CYTHON_METH_FASTCALL +static int __pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + CYTHON_UNUSED PyObject *__pyx_v_args = 0; + CYTHON_UNUSED PyObject *__pyx_v_kwargs = 0; CYTHON_UNUSED Py_ssize_t __pyx_nargs; - #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; - PyObject *__pyx_r = 0; + int __pyx_r; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("get_data (wrapper)", 0); - #if !CYTHON_METH_FASTCALL + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else - __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; + __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return -1; #endif - #endif - __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); - if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("get_data", 1, 0, 0, __pyx_nargs); return NULL; } - const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; - if (unlikely(__pyx_kwds_len < 0)) return NULL; - if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("get_data", __pyx_kwds); return NULL;} - __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_7BlockPy_2get_data(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_BlockPy *)__pyx_v_self)); + __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); + const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_VARARGS(__pyx_kwds) : 0; + if (unlikely(__pyx_kwds_len < 0)) return -1; + if (__pyx_kwds_len > 0) { + if (unlikely(__Pyx_CheckKeywordStrings("__init__", __pyx_kwds) == -1)) return -1; + } + __Pyx_INCREF(__pyx_args); + __pyx_v_args = __pyx_args; + __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_2__init__(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs); + + /* function exit code */ + __Pyx_DECREF(__pyx_v_args); + __Pyx_XDECREF(__pyx_v_kwargs); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_2__init__(CYTHON_UNUSED struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs) { + int __pyx_r; + + /* function exit code */ + __pyx_r = 0; + return __pyx_r; +} + +/* "polluck_blockchain/placeholder_native.pyx":75 + * # self._hash = "".encode("UTF-8") + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * if self.BlockC is not NULL and self.ptr_owner is True: + * del self.BlockC +*/ + +/* Python wrapper */ +static void __pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_5__dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_5__dealloc__(PyObject *__pyx_v_self) { + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); + __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); + __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_4__dealloc__(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +static void __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_4__dealloc__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self) { + int __pyx_t_1; + int __pyx_t_2; + + /* "polluck_blockchain/placeholder_native.pyx":76 + * + * def __dealloc__(self): + * if self.BlockC is not NULL and self.ptr_owner is True: # <<<<<<<<<<<<<< + * del self.BlockC + * self.BlockC = NULL +*/ + __pyx_t_2 = (__pyx_v_self->BlockC != NULL); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L4_bool_binop_done; + } + __pyx_t_2 = (__pyx_v_self->ptr_owner == 1); + __pyx_t_1 = __pyx_t_2; + __pyx_L4_bool_binop_done:; + if (__pyx_t_1) { + + /* "polluck_blockchain/placeholder_native.pyx":77 + * def __dealloc__(self): + * if self.BlockC is not NULL and self.ptr_owner is True: + * del self.BlockC # <<<<<<<<<<<<<< + * self.BlockC = NULL + * +*/ + delete __pyx_v_self->BlockC; + + /* "polluck_blockchain/placeholder_native.pyx":78 + * if self.BlockC is not NULL and self.ptr_owner is True: + * del self.BlockC + * self.BlockC = NULL # <<<<<<<<<<<<<< + * + * @staticmethod +*/ + __pyx_v_self->BlockC = NULL; + + /* "polluck_blockchain/placeholder_native.pyx":76 + * + * def __dealloc__(self): + * if self.BlockC is not NULL and self.ptr_owner is True: # <<<<<<<<<<<<<< + * del self.BlockC + * self.BlockC = NULL +*/ + } + + /* "polluck_blockchain/placeholder_native.pyx":75 + * # self._hash = "".encode("UTF-8") + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * if self.BlockC is not NULL and self.ptr_owner is True: + * del self.BlockC +*/ + + /* function exit code */ +} + +/* "polluck_blockchain/placeholder_native.pyx":80 + * self.BlockC = NULL + * + * @staticmethod # <<<<<<<<<<<<<< + * cdef PyBlock from_ptr(Block *block, bint owner=False): + * cdef PyBlock py_block = PyBlock.__new__( +*/ + +static struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_from_ptr(::Block *__pyx_v_block, struct __pyx_opt_args_18polluck_blockchain_18placeholder_native_7PyBlock_from_ptr *__pyx_optional_args) { + + /* "polluck_blockchain/placeholder_native.pyx":81 + * + * @staticmethod + * cdef PyBlock from_ptr(Block *block, bint owner=False): # <<<<<<<<<<<<<< + * cdef PyBlock py_block = PyBlock.__new__( + * PyBlock, +*/ + int __pyx_v_owner = ((int)0); + struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_py_block = 0; + struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("from_ptr", 0); + if (__pyx_optional_args) { + if (__pyx_optional_args->__pyx_n > 0) { + __pyx_v_owner = __pyx_optional_args->owner; + } + } + + /* "polluck_blockchain/placeholder_native.pyx":84 + * cdef PyBlock py_block = PyBlock.__new__( + * PyBlock, + * block.index, # <<<<<<<<<<<<<< + * block.nonce, + * block.data, +*/ + __pyx_t_1 = __Pyx_PyLong_From_uint64_t(__pyx_v_block->index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + + /* "polluck_blockchain/placeholder_native.pyx":85 + * PyBlock, + * block.index, + * block.nonce, # <<<<<<<<<<<<<< + * block.data, + * block.prev_hash, +*/ + __pyx_t_2 = __Pyx_PyLong_From_uint64_t(__pyx_v_block->nonce); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 85, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + + /* "polluck_blockchain/placeholder_native.pyx":86 + * block.index, + * block.nonce, + * block.data, # <<<<<<<<<<<<<< + * block.prev_hash, + * True, +*/ + __pyx_t_3 = __pyx_convert_PyBytes_string_to_py_6libcpp_6string_std__in_string(__pyx_v_block->data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 86, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + + /* "polluck_blockchain/placeholder_native.pyx":87 + * block.nonce, + * block.data, + * block.prev_hash, # <<<<<<<<<<<<<< + * True, + * ) +*/ + __pyx_t_4 = __pyx_convert_PyBytes_string_to_py_6libcpp_6string_std__in_string(__pyx_v_block->prev_hash); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 87, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + + /* "polluck_blockchain/placeholder_native.pyx":82 + * @staticmethod + * cdef PyBlock from_ptr(Block *block, bint owner=False): + * cdef PyBlock py_block = PyBlock.__new__( # <<<<<<<<<<<<<< + * PyBlock, + * block.index, +*/ + __pyx_t_5 = PyTuple_New(5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 82, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_1); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1) != (0)) __PYX_ERR(0, 82, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_2); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2) != (0)) __PYX_ERR(0, 82, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_3); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3) != (0)) __PYX_ERR(0, 82, __pyx_L1_error); + __Pyx_GIVEREF(__pyx_t_4); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4) != (0)) __PYX_ERR(0, 82, __pyx_L1_error); + __Pyx_INCREF(Py_True); + __Pyx_GIVEREF(Py_True); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 4, Py_True) != (0)) __PYX_ERR(0, 82, __pyx_L1_error); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_t_4 = ((PyObject *)__pyx_tp_new_18polluck_blockchain_18placeholder_native_PyBlock(((PyTypeObject *)__pyx_mstate_global->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock), __pyx_t_5, NULL)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 82, __pyx_L1_error) + __Pyx_GOTREF((PyObject *)__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_py_block = ((struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_t_4); + __pyx_t_4 = 0; + + /* "polluck_blockchain/placeholder_native.pyx":90 + * True, + * ) + * py_block.BlockC = block # <<<<<<<<<<<<<< + * py_block.ptr_owner = owner + * +*/ + __pyx_v_py_block->BlockC = __pyx_v_block; + + /* "polluck_blockchain/placeholder_native.pyx":91 + * ) + * py_block.BlockC = block + * py_block.ptr_owner = owner # <<<<<<<<<<<<<< + * + * return py_block +*/ + __pyx_v_py_block->ptr_owner = __pyx_v_owner; + + /* "polluck_blockchain/placeholder_native.pyx":93 + * py_block.ptr_owner = owner + * + * return py_block # <<<<<<<<<<<<<< + * + * # cpdef _perform_hash(self): +*/ + __Pyx_XDECREF((PyObject *)__pyx_r); + __Pyx_INCREF((PyObject *)__pyx_v_py_block); + __pyx_r = __pyx_v_py_block; + goto __pyx_L0; + + /* "polluck_blockchain/placeholder_native.pyx":80 + * self.BlockC = NULL + * + * @staticmethod # <<<<<<<<<<<<<< + * cdef PyBlock from_ptr(Block *block, bint owner=False): + * cdef PyBlock py_block = PyBlock.__new__( +*/ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("polluck_blockchain.placeholder_native.PyBlock.from_ptr", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_py_block); + __Pyx_XGIVEREF((PyObject *)__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "polluck_blockchain/placeholder_native.pyx":112 + * + * # Python public API + * @property # <<<<<<<<<<<<<< + * def index(self): + * return self.BlockC.index +*/ + +/* Python wrapper */ +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_5index_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_5index_1__get__(PyObject *__pyx_v_self) { + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); + __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_5index___get__(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7BlockPy_2get_data(struct __pyx_obj_18polluck_blockchain_18placeholder_native_BlockPy *__pyx_v_self) { +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_5index___get__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("get_data", 0); + __Pyx_RefNannySetupContext("__get__", 0); /* "polluck_blockchain/placeholder_native.pyx":114 + * @property + * def index(self): + * return self.BlockC.index # <<<<<<<<<<<<<< * - * def get_data(self): - * return self.Block.data.decode("UTF-8") # <<<<<<<<<<<<<< - * - * # def __init__( + * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_decode_cpp_string(__pyx_v_self->Block->data, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeUTF8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyLong_From_uint64_t(__pyx_v_self->BlockC->index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "polluck_blockchain/placeholder_native.pyx":113 - * ) - * - * def get_data(self): # <<<<<<<<<<<<<< - * return self.Block.data.decode("UTF-8") + /* "polluck_blockchain/placeholder_native.pyx":112 * + * # Python public API + * @property # <<<<<<<<<<<<<< + * def index(self): + * return self.BlockC.index */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("polluck_blockchain.placeholder_native.BlockPy.get_data", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("polluck_blockchain.placeholder_native.PyBlock.index.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "polluck_blockchain/placeholder_native.pyx":116 + * return self.BlockC.index + * + * @property # <<<<<<<<<<<<<< + * def timestamp(self): + * return timestamp_to_datetime(self.BlockC.timestamp) +*/ + +/* Python wrapper */ +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_9timestamp_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_9timestamp_1__get__(PyObject *__pyx_v_self) { + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); + __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_9timestamp___get__(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_9timestamp___get__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "polluck_blockchain/placeholder_native.pyx":118 + * @property + * def timestamp(self): + * return timestamp_to_datetime(self.BlockC.timestamp) # <<<<<<<<<<<<<< + * + * @property +*/ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_18polluck_blockchain_18placeholder_native_timestamp_to_datetime(__pyx_v_self->BlockC->timestamp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 118, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "polluck_blockchain/placeholder_native.pyx":116 + * return self.BlockC.index + * + * @property # <<<<<<<<<<<<<< + * def timestamp(self): + * return timestamp_to_datetime(self.BlockC.timestamp) +*/ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("polluck_blockchain.placeholder_native.PyBlock.timestamp.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "polluck_blockchain/placeholder_native.pyx":120 + * return timestamp_to_datetime(self.BlockC.timestamp) + * + * @property # <<<<<<<<<<<<<< + * def data(self): + * return self.BlockC.data.decode("UTF-8") +*/ + +/* Python wrapper */ +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_4data_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_4data_1__get__(PyObject *__pyx_v_self) { + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); + __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_4data___get__(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_4data___get__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "polluck_blockchain/placeholder_native.pyx":122 + * @property + * def data(self): + * return self.BlockC.data.decode("UTF-8") # <<<<<<<<<<<<<< + * + * @property +*/ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_decode_cpp_string(__pyx_v_self->BlockC->data, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeUTF8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 122, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "polluck_blockchain/placeholder_native.pyx":120 + * return timestamp_to_datetime(self.BlockC.timestamp) + * + * @property # <<<<<<<<<<<<<< + * def data(self): + * return self.BlockC.data.decode("UTF-8") +*/ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("polluck_blockchain.placeholder_native.PyBlock.data.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "polluck_blockchain/placeholder_native.pyx":124 + * return self.BlockC.data.decode("UTF-8") + * + * @property # <<<<<<<<<<<<<< + * def prev_hash(self): + * return self.BlockC.prev_hash.decode("UTF-8") +*/ + +/* Python wrapper */ +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_9prev_hash_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_9prev_hash_1__get__(PyObject *__pyx_v_self) { + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); + __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_9prev_hash___get__(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_9prev_hash___get__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "polluck_blockchain/placeholder_native.pyx":126 + * @property + * def prev_hash(self): + * return self.BlockC.prev_hash.decode("UTF-8") # <<<<<<<<<<<<<< + * + * @property +*/ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_decode_cpp_string(__pyx_v_self->BlockC->prev_hash, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeUTF8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "polluck_blockchain/placeholder_native.pyx":124 + * return self.BlockC.data.decode("UTF-8") + * + * @property # <<<<<<<<<<<<<< + * def prev_hash(self): + * return self.BlockC.prev_hash.decode("UTF-8") +*/ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("polluck_blockchain.placeholder_native.PyBlock.prev_hash.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "polluck_blockchain/placeholder_native.pyx":128 + * return self.BlockC.prev_hash.decode("UTF-8") + * + * @property # <<<<<<<<<<<<<< + * def nonce(self): + * return self.BlockC.nonce +*/ + +/* Python wrapper */ +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_5nonce_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_5nonce_1__get__(PyObject *__pyx_v_self) { + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); + __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_5nonce___get__(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_5nonce___get__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "polluck_blockchain/placeholder_native.pyx":130 + * @property + * def nonce(self): + * return self.BlockC.nonce # <<<<<<<<<<<<<< + * + * # @nonce.setter +*/ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyLong_From_uint64_t(__pyx_v_self->BlockC->nonce); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "polluck_blockchain/placeholder_native.pyx":128 + * return self.BlockC.prev_hash.decode("UTF-8") + * + * @property # <<<<<<<<<<<<<< + * def nonce(self): + * return self.BlockC.nonce +*/ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("polluck_blockchain.placeholder_native.PyBlock.nonce.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "polluck_blockchain/placeholder_native.pyx":136 + * # self._nonce = value + * + * @property # <<<<<<<<<<<<<< + * def hash(self): + * return self.BlockC.hash.decode("UTF-8") +*/ + +/* Python wrapper */ +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_4hash_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_4hash_1__get__(PyObject *__pyx_v_self) { + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); + __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_4hash___get__(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_4hash___get__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "polluck_blockchain/placeholder_native.pyx":138 + * @property + * def hash(self): + * return self.BlockC.hash.decode("UTF-8") # <<<<<<<<<<<<<< + * + * # @hash.setter +*/ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_decode_cpp_string(__pyx_v_self->BlockC->hash, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeUTF8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "polluck_blockchain/placeholder_native.pyx":136 + * # self._nonce = value + * + * @property # <<<<<<<<<<<<<< + * def hash(self): + * return self.BlockC.hash.decode("UTF-8") +*/ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("polluck_blockchain.placeholder_native.PyBlock.hash.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -3566,15 +4395,15 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7BlockPy_2ge */ /* Python wrapper */ -static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7BlockPy_5__reduce_cython__(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_7__reduce_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -static PyMethodDef __pyx_mdef_18polluck_blockchain_18placeholder_native_7BlockPy_5__reduce_cython__ = {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_7BlockPy_5__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7BlockPy_5__reduce_cython__(PyObject *__pyx_v_self, +static PyMethodDef __pyx_mdef_18polluck_blockchain_18placeholder_native_7PyBlock_7__reduce_cython__ = {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_7__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_7__reduce_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else @@ -3600,14 +4429,14 @@ PyObject *__pyx_args, PyObject *__pyx_kwds const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len < 0)) return NULL; if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("__reduce_cython__", __pyx_kwds); return NULL;} - __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_7BlockPy_4__reduce_cython__(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_BlockPy *)__pyx_v_self)); + __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_6__reduce_cython__(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7BlockPy_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_18polluck_blockchain_18placeholder_native_BlockPy *__pyx_v_self) { +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_6__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_lineno = 0; @@ -3632,7 +4461,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7BlockPy_4__ /* function exit code */ __pyx_L1_error:; - __Pyx_AddTraceback("polluck_blockchain.placeholder_native.BlockPy.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("polluck_blockchain.placeholder_native.PyBlock.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); @@ -3647,15 +4476,15 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7BlockPy_4__ */ /* Python wrapper */ -static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7BlockPy_7__setstate_cython__(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_9__setstate_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -static PyMethodDef __pyx_mdef_18polluck_blockchain_18placeholder_native_7BlockPy_7__setstate_cython__ = {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_7BlockPy_7__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7BlockPy_7__setstate_cython__(PyObject *__pyx_v_self, +static PyMethodDef __pyx_mdef_18polluck_blockchain_18placeholder_native_7PyBlock_9__setstate_cython__ = {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_9__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_9__setstate_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else @@ -3717,11 +4546,11 @@ PyObject *__pyx_args, PyObject *__pyx_kwds for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } - __Pyx_AddTraceback("polluck_blockchain.placeholder_native.BlockPy.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("polluck_blockchain.placeholder_native.PyBlock.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_7BlockPy_6__setstate_cython__(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_BlockPy *)__pyx_v_self), __pyx_v___pyx_state); + __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_8__setstate_cython__(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_v_self), __pyx_v___pyx_state); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { @@ -3731,7 +4560,7 @@ PyObject *__pyx_args, PyObject *__pyx_kwds return __pyx_r; } -static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7BlockPy_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_18polluck_blockchain_18placeholder_native_BlockPy *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_8__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_lineno = 0; @@ -3756,42 +4585,1479 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7BlockPy_6__ /* function exit code */ __pyx_L1_error:; - __Pyx_AddTraceback("polluck_blockchain.placeholder_native.BlockPy.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("polluck_blockchain.placeholder_native.PyBlock.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "polluck_blockchain/placeholder_native.pyx":156 + * cdef bint _genesis_done + * + * def __cinit__(self): # <<<<<<<<<<<<<< + * self._difficulty = 1 + * self._index = 0 +*/ + +/* Python wrapper */ +static int __pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + CYTHON_UNUSED Py_ssize_t __pyx_nargs; + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + #if CYTHON_ASSUME_SAFE_SIZE + __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); + #else + __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return -1; + #endif + __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); + if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, __pyx_nargs); return -1; } + const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_VARARGS(__pyx_kwds) : 0; + if (unlikely(__pyx_kwds_len < 0)) return -1; + if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("__cinit__", __pyx_kwds); return -1;} + __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain___cinit__(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain___cinit__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + std::unordered_map *__pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + size_t __pyx_t_5; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__cinit__", 0); + + /* "polluck_blockchain/placeholder_native.pyx":157 + * + * def __cinit__(self): + * self._difficulty = 1 # <<<<<<<<<<<<<< + * self._index = 0 + * self._genesis_done = 0 +*/ + __pyx_v_self->_difficulty = 1; + + /* "polluck_blockchain/placeholder_native.pyx":158 + * def __cinit__(self): + * self._difficulty = 1 + * self._index = 0 # <<<<<<<<<<<<<< + * self._genesis_done = 0 + * self._chain = new unordered_map[uint64_t, Block*]() +*/ + __pyx_v_self->_index = ((uint64_t)0); + + /* "polluck_blockchain/placeholder_native.pyx":159 + * self._difficulty = 1 + * self._index = 0 + * self._genesis_done = 0 # <<<<<<<<<<<<<< + * self._chain = new unordered_map[uint64_t, Block*]() + * if self._chain is NULL: +*/ + __pyx_v_self->_genesis_done = 0; + + /* "polluck_blockchain/placeholder_native.pyx":160 + * self._index = 0 + * self._genesis_done = 0 + * self._chain = new unordered_map[uint64_t, Block*]() # <<<<<<<<<<<<<< + * if self._chain is NULL: + * raise MemoryError("Could not allocate hasmap") +*/ + try { + __pyx_t_1 = new std::unordered_map (); + } catch(...) { + __Pyx_CppExn2PyErr(); + __PYX_ERR(0, 160, __pyx_L1_error) + } + __pyx_v_self->_chain = __pyx_t_1; + + /* "polluck_blockchain/placeholder_native.pyx":161 + * self._genesis_done = 0 + * self._chain = new unordered_map[uint64_t, Block*]() + * if self._chain is NULL: # <<<<<<<<<<<<<< + * raise MemoryError("Could not allocate hasmap") + * +*/ + __pyx_t_2 = (__pyx_v_self->_chain == NULL); + if (unlikely(__pyx_t_2)) { + + /* "polluck_blockchain/placeholder_native.pyx":162 + * self._chain = new unordered_map[uint64_t, Block*]() + * if self._chain is NULL: + * raise MemoryError("Could not allocate hasmap") # <<<<<<<<<<<<<< + * + * def __init__(self, *args, **kwargs): +*/ + __pyx_t_4 = NULL; + __pyx_t_5 = 1; + { + PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Could_not_allocate_hasmap}; + __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_MemoryError)), __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 162, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + } + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(0, 162, __pyx_L1_error) + + /* "polluck_blockchain/placeholder_native.pyx":161 + * self._genesis_done = 0 + * self._chain = new unordered_map[uint64_t, Block*]() + * if self._chain is NULL: # <<<<<<<<<<<<<< + * raise MemoryError("Could not allocate hasmap") + * +*/ + } + + /* "polluck_blockchain/placeholder_native.pyx":156 + * cdef bint _genesis_done + * + * def __cinit__(self): # <<<<<<<<<<<<<< + * self._difficulty = 1 + * self._index = 0 +*/ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("polluck_blockchain.placeholder_native.Blockchain.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "polluck_blockchain/placeholder_native.pyx":164 + * raise MemoryError("Could not allocate hasmap") + * + * def __init__(self, *args, **kwargs): # <<<<<<<<<<<<<< + * pass + * +*/ + +/* Python wrapper */ +static int __pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + CYTHON_UNUSED PyObject *__pyx_v_args = 0; + CYTHON_UNUSED PyObject *__pyx_v_kwargs = 0; + CYTHON_UNUSED Py_ssize_t __pyx_nargs; + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + #if CYTHON_ASSUME_SAFE_SIZE + __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); + #else + __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return -1; + #endif + __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); + const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_VARARGS(__pyx_kwds) : 0; + if (unlikely(__pyx_kwds_len < 0)) return -1; + if (__pyx_kwds_len > 0) { + if (unlikely(__Pyx_CheckKeywordStrings("__init__", __pyx_kwds) == -1)) return -1; + } + __Pyx_INCREF(__pyx_args); + __pyx_v_args = __pyx_args; + __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_2__init__(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs); + + /* function exit code */ + __Pyx_DECREF(__pyx_v_args); + __Pyx_XDECREF(__pyx_v_kwargs); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_2__init__(CYTHON_UNUSED struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kwargs) { + int __pyx_r; + + /* function exit code */ + __pyx_r = 0; + return __pyx_r; +} + +/* "polluck_blockchain/placeholder_native.pyx":167 + * pass + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * if self._chain is not NULL: + * del self._chain +*/ + +/* Python wrapper */ +static void __pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_5__dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_5__dealloc__(PyObject *__pyx_v_self) { + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); + __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); + __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_4__dealloc__(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +static void __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_4__dealloc__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_v_self) { + int __pyx_t_1; + + /* "polluck_blockchain/placeholder_native.pyx":168 + * + * def __dealloc__(self): + * if self._chain is not NULL: # <<<<<<<<<<<<<< + * del self._chain + * self._chain = NULL +*/ + __pyx_t_1 = (__pyx_v_self->_chain != NULL); + if (__pyx_t_1) { + + /* "polluck_blockchain/placeholder_native.pyx":169 + * def __dealloc__(self): + * if self._chain is not NULL: + * del self._chain # <<<<<<<<<<<<<< + * self._chain = NULL + * +*/ + delete __pyx_v_self->_chain; + + /* "polluck_blockchain/placeholder_native.pyx":170 + * if self._chain is not NULL: + * del self._chain + * self._chain = NULL # <<<<<<<<<<<<<< + * + * def __len__(self): +*/ + __pyx_v_self->_chain = NULL; + + /* "polluck_blockchain/placeholder_native.pyx":168 + * + * def __dealloc__(self): + * if self._chain is not NULL: # <<<<<<<<<<<<<< + * del self._chain + * self._chain = NULL +*/ + } + + /* "polluck_blockchain/placeholder_native.pyx":167 + * pass + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * if self._chain is not NULL: + * del self._chain +*/ + + /* function exit code */ +} + +/* "polluck_blockchain/placeholder_native.pyx":172 + * self._chain = NULL + * + * def __len__(self): # <<<<<<<<<<<<<< + * return self._index + 1 + * +*/ + +/* Python wrapper */ +static Py_ssize_t __pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_7__len__(PyObject *__pyx_v_self); /*proto*/ +static Py_ssize_t __pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_7__len__(PyObject *__pyx_v_self) { + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + Py_ssize_t __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__len__ (wrapper)", 0); + __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); + __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_6__len__(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static Py_ssize_t __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_6__len__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_v_self) { + Py_ssize_t __pyx_r; + + /* "polluck_blockchain/placeholder_native.pyx":173 + * + * def __len__(self): + * return self._index + 1 # <<<<<<<<<<<<<< + * + * @property +*/ + __pyx_r = (__pyx_v_self->_index + 1); + goto __pyx_L0; + + /* "polluck_blockchain/placeholder_native.pyx":172 + * self._chain = NULL + * + * def __len__(self): # <<<<<<<<<<<<<< + * return self._index + 1 + * +*/ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "polluck_blockchain/placeholder_native.pyx":175 + * return self._index + 1 + * + * @property # <<<<<<<<<<<<<< + * def genesis_done(self): + * return self._genesis_done +*/ + +/* Python wrapper */ +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_12genesis_done_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_12genesis_done_1__get__(PyObject *__pyx_v_self) { + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); + __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_12genesis_done___get__(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_12genesis_done___get__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "polluck_blockchain/placeholder_native.pyx":177 + * @property + * def genesis_done(self): + * return self._genesis_done # <<<<<<<<<<<<<< + * + * @property +*/ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_genesis_done); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "polluck_blockchain/placeholder_native.pyx":175 + * return self._index + 1 + * + * @property # <<<<<<<<<<<<<< + * def genesis_done(self): + * return self._genesis_done +*/ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("polluck_blockchain.placeholder_native.Blockchain.genesis_done.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "polluck_blockchain/placeholder_native.pyx":179 + * return self._genesis_done + * + * @property # <<<<<<<<<<<<<< + * def index(self): + * return self._index +*/ + +/* Python wrapper */ +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_5index_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_5index_1__get__(PyObject *__pyx_v_self) { + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); + __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_5index___get__(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_5index___get__(struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "polluck_blockchain/placeholder_native.pyx":181 + * @property + * def index(self): + * return self._index # <<<<<<<<<<<<<< + * + * # TODO error handling +*/ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyLong_From_uint64_t(__pyx_v_self->_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "polluck_blockchain/placeholder_native.pyx":179 + * return self._genesis_done + * + * @property # <<<<<<<<<<<<<< + * def index(self): + * return self._index +*/ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("polluck_blockchain.placeholder_native.Blockchain.index.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "polluck_blockchain/placeholder_native.pyx":184 + * + * # TODO error handling + * cdef Block* get_block_c(self, uint64_t idx): # <<<<<<<<<<<<<< + * return self._chain[0][idx] + * +*/ + +static ::Block *__pyx_f_18polluck_blockchain_18placeholder_native_10Blockchain_get_block_c(struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_v_self, uint64_t __pyx_v_idx) { + ::Block *__pyx_r; + + /* "polluck_blockchain/placeholder_native.pyx":185 + * # TODO error handling + * cdef Block* get_block_c(self, uint64_t idx): + * return self._chain[0][idx] # <<<<<<<<<<<<<< + * + * def get_block(self, idx): +*/ + __pyx_r = ((__pyx_v_self->_chain[0])[__pyx_v_idx]); + goto __pyx_L0; + + /* "polluck_blockchain/placeholder_native.pyx":184 + * + * # TODO error handling + * cdef Block* get_block_c(self, uint64_t idx): # <<<<<<<<<<<<<< + * return self._chain[0][idx] + * +*/ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "polluck_blockchain/placeholder_native.pyx":187 + * return self._chain[0][idx] + * + * def get_block(self, idx): # <<<<<<<<<<<<<< + * if idx < 0 or idx > self._index: + * raise IndexError("Index value is out of bounds") +*/ + +/* Python wrapper */ +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_9get_block(PyObject *__pyx_v_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +); /*proto*/ +static PyMethodDef __pyx_mdef_18polluck_blockchain_18placeholder_native_10Blockchain_9get_block = {"get_block", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_9get_block, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_9get_block(PyObject *__pyx_v_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +) { + PyObject *__pyx_v_idx = 0; + #if !CYTHON_METH_FASTCALL + CYTHON_UNUSED Py_ssize_t __pyx_nargs; + #endif + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject* values[1] = {0}; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_block (wrapper)", 0); + #if !CYTHON_METH_FASTCALL + #if CYTHON_ASSUME_SAFE_SIZE + __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); + #else + __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; + #endif + #endif + __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); + { + PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_idx,0}; + const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 187, __pyx_L3_error) + if (__pyx_kwds_len > 0) { + switch (__pyx_nargs) { + case 1: + values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 187, __pyx_L3_error) + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + const Py_ssize_t kwd_pos_args = __pyx_nargs; + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "get_block", 0) < (0)) __PYX_ERR(0, 187, __pyx_L3_error) + for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("get_block", 1, 1, 1, i); __PYX_ERR(0, 187, __pyx_L3_error) } + } + } else if (unlikely(__pyx_nargs != 1)) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 187, __pyx_L3_error) + } + __pyx_v_idx = values[0]; + } + goto __pyx_L6_skip; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("get_block", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 187, __pyx_L3_error) + __pyx_L6_skip:; + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + Py_XDECREF(values[__pyx_temp]); + } + __Pyx_AddTraceback("polluck_blockchain.placeholder_native.Blockchain.get_block", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_8get_block(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *)__pyx_v_self), __pyx_v_idx); + + /* function exit code */ + for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + Py_XDECREF(values[__pyx_temp]); + } + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_8get_block(struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_v_self, PyObject *__pyx_v_idx) { + ::Block *__pyx_v_block; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + size_t __pyx_t_5; + uint64_t __pyx_t_6; + ::Block *__pyx_t_7; + struct __pyx_opt_args_18polluck_blockchain_18placeholder_native_7PyBlock_from_ptr __pyx_t_8; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_block", 0); + + /* "polluck_blockchain/placeholder_native.pyx":188 + * + * def get_block(self, idx): + * if idx < 0 or idx > self._index: # <<<<<<<<<<<<<< + * raise IndexError("Index value is out of bounds") + * +*/ + __pyx_t_2 = PyObject_RichCompare(__pyx_v_idx, __pyx_mstate_global->__pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 188, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 188, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (!__pyx_t_3) { + } else { + __pyx_t_1 = __pyx_t_3; + goto __pyx_L4_bool_binop_done; + } + __pyx_t_2 = __Pyx_PyLong_From_uint64_t(__pyx_v_self->_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 188, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_idx, __pyx_t_2, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 188, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 188, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_1 = __pyx_t_3; + __pyx_L4_bool_binop_done:; + if (unlikely(__pyx_t_1)) { + + /* "polluck_blockchain/placeholder_native.pyx":189 + * def get_block(self, idx): + * if idx < 0 or idx > self._index: + * raise IndexError("Index value is out of bounds") # <<<<<<<<<<<<<< + * + * cdef Block *block = self.get_block_c(idx) +*/ + __pyx_t_2 = NULL; + __pyx_t_5 = 1; + { + PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Index_value_is_out_of_bounds}; + __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_IndexError)), __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 189, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + } + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __PYX_ERR(0, 189, __pyx_L1_error) + + /* "polluck_blockchain/placeholder_native.pyx":188 + * + * def get_block(self, idx): + * if idx < 0 or idx > self._index: # <<<<<<<<<<<<<< + * raise IndexError("Index value is out of bounds") + * +*/ + } + + /* "polluck_blockchain/placeholder_native.pyx":191 + * raise IndexError("Index value is out of bounds") + * + * cdef Block *block = self.get_block_c(idx) # <<<<<<<<<<<<<< + * return PyBlock.from_ptr(block, owner=False) + * +*/ + __pyx_t_6 = __Pyx_PyLong_As_uint64_t(__pyx_v_idx); if (unlikely((__pyx_t_6 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 191, __pyx_L1_error) + __pyx_t_7 = ((struct __pyx_vtabstruct_18polluck_blockchain_18placeholder_native_Blockchain *)__pyx_v_self->__pyx_vtab)->get_block_c(__pyx_v_self, __pyx_t_6); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 191, __pyx_L1_error) + __pyx_v_block = __pyx_t_7; + + /* "polluck_blockchain/placeholder_native.pyx":192 + * + * cdef Block *block = self.get_block_c(idx) + * return PyBlock.from_ptr(block, owner=False) # <<<<<<<<<<<<<< + * + * cdef void add_block(self, Block *block): +*/ + __Pyx_XDECREF(__pyx_r); + __pyx_t_8.__pyx_n = 1; + __pyx_t_8.owner = 0; + __pyx_t_4 = ((PyObject *)__pyx_vtabptr_18polluck_blockchain_18placeholder_native_PyBlock->from_ptr(__pyx_v_block, &__pyx_t_8)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 192, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_r = __pyx_t_4; + __pyx_t_4 = 0; + goto __pyx_L0; + + /* "polluck_blockchain/placeholder_native.pyx":187 + * return self._chain[0][idx] + * + * def get_block(self, idx): # <<<<<<<<<<<<<< + * if idx < 0 or idx > self._index: + * raise IndexError("Index value is out of bounds") +*/ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("polluck_blockchain.placeholder_native.Blockchain.get_block", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "polluck_blockchain/placeholder_native.pyx":194 + * return PyBlock.from_ptr(block, owner=False) + * + * cdef void add_block(self, Block *block): # <<<<<<<<<<<<<< + * self._chain[0][block.index] = block + * if self._genesis_done: +*/ + +static void __pyx_f_18polluck_blockchain_18placeholder_native_10Blockchain_add_block(struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_v_self, ::Block *__pyx_v_block) { + + /* "polluck_blockchain/placeholder_native.pyx":195 + * + * cdef void add_block(self, Block *block): + * self._chain[0][block.index] = block # <<<<<<<<<<<<<< + * if self._genesis_done: + * self._index += 1 +*/ + ((__pyx_v_self->_chain[0])[__pyx_v_block->index]) = __pyx_v_block; + + /* "polluck_blockchain/placeholder_native.pyx":196 + * cdef void add_block(self, Block *block): + * self._chain[0][block.index] = block + * if self._genesis_done: # <<<<<<<<<<<<<< + * self._index += 1 + * +*/ + if (__pyx_v_self->_genesis_done) { + + /* "polluck_blockchain/placeholder_native.pyx":197 + * self._chain[0][block.index] = block + * if self._genesis_done: + * self._index += 1 # <<<<<<<<<<<<<< + * + * def create_genesis_block(self): +*/ + __pyx_v_self->_index = (__pyx_v_self->_index + 1); + + /* "polluck_blockchain/placeholder_native.pyx":196 + * cdef void add_block(self, Block *block): + * self._chain[0][block.index] = block + * if self._genesis_done: # <<<<<<<<<<<<<< + * self._index += 1 + * +*/ + } + + /* "polluck_blockchain/placeholder_native.pyx":194 + * return PyBlock.from_ptr(block, owner=False) + * + * cdef void add_block(self, Block *block): # <<<<<<<<<<<<<< + * self._chain[0][block.index] = block + * if self._genesis_done: +*/ + + /* function exit code */ +} + +/* "polluck_blockchain/placeholder_native.pyx":199 + * self._index += 1 + * + * def create_genesis_block(self): # <<<<<<<<<<<<<< + * cdef Block *block = new Block( + * self._index, +*/ + +/* Python wrapper */ +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_11create_genesis_block(PyObject *__pyx_v_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +); /*proto*/ +static PyMethodDef __pyx_mdef_18polluck_blockchain_18placeholder_native_10Blockchain_11create_genesis_block = {"create_genesis_block", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_11create_genesis_block, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_11create_genesis_block(PyObject *__pyx_v_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +) { + #if !CYTHON_METH_FASTCALL + CYTHON_UNUSED Py_ssize_t __pyx_nargs; + #endif + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("create_genesis_block (wrapper)", 0); + #if !CYTHON_METH_FASTCALL + #if CYTHON_ASSUME_SAFE_SIZE + __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); + #else + __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; + #endif + #endif + __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); + if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("create_genesis_block", 1, 0, 0, __pyx_nargs); return NULL; } + const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; + if (unlikely(__pyx_kwds_len < 0)) return NULL; + if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("create_genesis_block", __pyx_kwds); return NULL;} + __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_10create_genesis_block(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_10create_genesis_block(struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_v_self) { + ::Block *__pyx_v_block; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + size_t __pyx_t_5; + double __pyx_t_6; + std::string __pyx_t_7; + std::string __pyx_t_8; + std::string __pyx_t_9; + ::Block *__pyx_t_10; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("create_genesis_block", 0); + + /* "polluck_blockchain/placeholder_native.pyx":202 + * cdef Block *block = new Block( + * self._index, + * datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp(), # <<<<<<<<<<<<<< + * 0, + * "Genesis Block".encode("UTF-8"), +*/ + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 202, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 202, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_mstate_global->__pyx_tuple[0], NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 202, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_2 = __pyx_t_3; + __Pyx_INCREF(__pyx_t_2); + __pyx_t_5 = 0; + { + PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; + __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_timestamp, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 202, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + } + __pyx_t_6 = __Pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 202, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "polluck_blockchain/placeholder_native.pyx":204 + * datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp(), + * 0, + * "Genesis Block".encode("UTF-8"), # <<<<<<<<<<<<<< + * "0".encode("UTF-8"), + * "".encode("UTF-8"), +*/ + __pyx_t_7 = __pyx_convert_string_from_py_6libcpp_6string_std__in_string(__pyx_mstate_global->__pyx_kp_b_Genesis_Block); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 204, __pyx_L1_error) + + /* "polluck_blockchain/placeholder_native.pyx":205 + * 0, + * "Genesis Block".encode("UTF-8"), + * "0".encode("UTF-8"), # <<<<<<<<<<<<<< + * "".encode("UTF-8"), + * ) +*/ + __pyx_t_8 = __pyx_convert_string_from_py_6libcpp_6string_std__in_string(__pyx_mstate_global->__pyx_kp_b_0); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 205, __pyx_L1_error) + + /* "polluck_blockchain/placeholder_native.pyx":206 + * "Genesis Block".encode("UTF-8"), + * "0".encode("UTF-8"), + * "".encode("UTF-8"), # <<<<<<<<<<<<<< + * ) + * block.hash = "dummy hash".encode("UTF-8") +*/ + __pyx_t_9 = __pyx_convert_string_from_py_6libcpp_6string_std__in_string(__pyx_mstate_global->__pyx_kp_b_); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 206, __pyx_L1_error) + + /* "polluck_blockchain/placeholder_native.pyx":200 + * + * def create_genesis_block(self): + * cdef Block *block = new Block( # <<<<<<<<<<<<<< + * self._index, + * datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp(), +*/ + try { + __pyx_t_10 = new ::Block(__pyx_v_self->_index, __pyx_t_6, 0, __pyx_t_7, __pyx_t_8, __pyx_t_9); + } catch(...) { + __Pyx_CppExn2PyErr(); + __PYX_ERR(0, 200, __pyx_L1_error) + } + __pyx_v_block = __pyx_t_10; + + /* "polluck_blockchain/placeholder_native.pyx":208 + * "".encode("UTF-8"), + * ) + * block.hash = "dummy hash".encode("UTF-8") # <<<<<<<<<<<<<< + * self.add_block(block) + * self._genesis_done = 1 +*/ + __pyx_t_9 = __pyx_convert_string_from_py_6libcpp_6string_std__in_string(__pyx_mstate_global->__pyx_kp_b_dummy_hash); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 208, __pyx_L1_error) + __pyx_v_block->hash = ((std::string)__pyx_t_9); + + /* "polluck_blockchain/placeholder_native.pyx":209 + * ) + * block.hash = "dummy hash".encode("UTF-8") + * self.add_block(block) # <<<<<<<<<<<<<< + * self._genesis_done = 1 + * +*/ + ((struct __pyx_vtabstruct_18polluck_blockchain_18placeholder_native_Blockchain *)__pyx_v_self->__pyx_vtab)->add_block(__pyx_v_self, __pyx_v_block); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 209, __pyx_L1_error) + + /* "polluck_blockchain/placeholder_native.pyx":210 + * block.hash = "dummy hash".encode("UTF-8") + * self.add_block(block) + * self._genesis_done = 1 # <<<<<<<<<<<<<< + * + * def new_block(self, data): +*/ + __pyx_v_self->_genesis_done = 1; + + /* "polluck_blockchain/placeholder_native.pyx":199 + * self._index += 1 + * + * def create_genesis_block(self): # <<<<<<<<<<<<<< + * cdef Block *block = new Block( + * self._index, +*/ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("polluck_blockchain.placeholder_native.Blockchain.create_genesis_block", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "polluck_blockchain/placeholder_native.pyx":212 + * self._genesis_done = 1 + * + * def new_block(self, data): # <<<<<<<<<<<<<< + * if not self._genesis_done: + * raise RuntimeError("Create a genesis block first.") +*/ + +/* Python wrapper */ +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_13new_block(PyObject *__pyx_v_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +); /*proto*/ +static PyMethodDef __pyx_mdef_18polluck_blockchain_18placeholder_native_10Blockchain_13new_block = {"new_block", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_13new_block, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_13new_block(PyObject *__pyx_v_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +) { + PyObject *__pyx_v_data = 0; + #if !CYTHON_METH_FASTCALL + CYTHON_UNUSED Py_ssize_t __pyx_nargs; + #endif + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject* values[1] = {0}; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("new_block (wrapper)", 0); + #if !CYTHON_METH_FASTCALL + #if CYTHON_ASSUME_SAFE_SIZE + __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); + #else + __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; + #endif + #endif + __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); + { + PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_data,0}; + const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 212, __pyx_L3_error) + if (__pyx_kwds_len > 0) { + switch (__pyx_nargs) { + case 1: + values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 212, __pyx_L3_error) + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + const Py_ssize_t kwd_pos_args = __pyx_nargs; + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "new_block", 0) < (0)) __PYX_ERR(0, 212, __pyx_L3_error) + for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("new_block", 1, 1, 1, i); __PYX_ERR(0, 212, __pyx_L3_error) } + } + } else if (unlikely(__pyx_nargs != 1)) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 212, __pyx_L3_error) + } + __pyx_v_data = values[0]; + } + goto __pyx_L6_skip; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("new_block", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 212, __pyx_L3_error) + __pyx_L6_skip:; + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + Py_XDECREF(values[__pyx_temp]); + } + __Pyx_AddTraceback("polluck_blockchain.placeholder_native.Blockchain.new_block", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_12new_block(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *)__pyx_v_self), __pyx_v_data); + + /* function exit code */ + for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + Py_XDECREF(values[__pyx_temp]); + } + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_12new_block(struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_v_self, PyObject *__pyx_v_data) { + ::Block *__pyx_v_prev_block; + std::string __pyx_v_prev_hash; + uint64_t __pyx_v_new_idx; + ::Block *__pyx_v_block; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + size_t __pyx_t_4; + ::Block *__pyx_t_5; + std::string __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + double __pyx_t_9; + std::string __pyx_t_10; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("new_block", 0); + + /* "polluck_blockchain/placeholder_native.pyx":213 + * + * def new_block(self, data): + * if not self._genesis_done: # <<<<<<<<<<<<<< + * raise RuntimeError("Create a genesis block first.") + * +*/ + __pyx_t_1 = (!__pyx_v_self->_genesis_done); + if (unlikely(__pyx_t_1)) { + + /* "polluck_blockchain/placeholder_native.pyx":214 + * def new_block(self, data): + * if not self._genesis_done: + * raise RuntimeError("Create a genesis block first.") # <<<<<<<<<<<<<< + * + * cdef Block *prev_block = self.get_block_c(self._index) +*/ + __pyx_t_3 = NULL; + __pyx_t_4 = 1; + { + PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Create_a_genesis_block_first}; + __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 214, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + } + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(0, 214, __pyx_L1_error) + + /* "polluck_blockchain/placeholder_native.pyx":213 + * + * def new_block(self, data): + * if not self._genesis_done: # <<<<<<<<<<<<<< + * raise RuntimeError("Create a genesis block first.") + * +*/ + } + + /* "polluck_blockchain/placeholder_native.pyx":216 + * raise RuntimeError("Create a genesis block first.") + * + * cdef Block *prev_block = self.get_block_c(self._index) # <<<<<<<<<<<<<< + * cdef string prev_hash = prev_block.prev_hash + * cdef uint64_t new_idx = self._index + 1 +*/ + __pyx_t_5 = ((struct __pyx_vtabstruct_18polluck_blockchain_18placeholder_native_Blockchain *)__pyx_v_self->__pyx_vtab)->get_block_c(__pyx_v_self, __pyx_v_self->_index); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 216, __pyx_L1_error) + __pyx_v_prev_block = __pyx_t_5; + + /* "polluck_blockchain/placeholder_native.pyx":217 + * + * cdef Block *prev_block = self.get_block_c(self._index) + * cdef string prev_hash = prev_block.prev_hash # <<<<<<<<<<<<<< + * cdef uint64_t new_idx = self._index + 1 + * +*/ + __pyx_t_6 = __pyx_v_prev_block->prev_hash; + __pyx_v_prev_hash = __PYX_STD_MOVE_IF_SUPPORTED(__pyx_t_6); + + /* "polluck_blockchain/placeholder_native.pyx":218 + * cdef Block *prev_block = self.get_block_c(self._index) + * cdef string prev_hash = prev_block.prev_hash + * cdef uint64_t new_idx = self._index + 1 # <<<<<<<<<<<<<< + * + * cdef Block *block = new Block( +*/ + __pyx_v_new_idx = (__pyx_v_self->_index + 1); + + /* "polluck_blockchain/placeholder_native.pyx":222 + * cdef Block *block = new Block( + * new_idx, + * datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp(), # <<<<<<<<<<<<<< + * 0, + * data.encode("UTF-8"), +*/ + __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 222, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 222, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_mstate_global->__pyx_tuple[0], NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 222, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_3 = __pyx_t_7; + __Pyx_INCREF(__pyx_t_3); + __pyx_t_4 = 0; + { + PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; + __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_timestamp, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 222, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + } + __pyx_t_9 = __Pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 222, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "polluck_blockchain/placeholder_native.pyx":224 + * datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp(), + * 0, + * data.encode("UTF-8"), # <<<<<<<<<<<<<< + * prev_hash, + * "".encode("UTF-8"), +*/ + __pyx_t_7 = __pyx_v_data; + __Pyx_INCREF(__pyx_t_7); + __pyx_t_4 = 0; + { + PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_UTF_8}; + __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_encode, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 224, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + } + __pyx_t_6 = __pyx_convert_string_from_py_6libcpp_6string_std__in_string(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 224, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "polluck_blockchain/placeholder_native.pyx":226 + * data.encode("UTF-8"), + * prev_hash, + * "".encode("UTF-8"), # <<<<<<<<<<<<<< + * ) + * self.add_block(block) +*/ + __pyx_t_10 = __pyx_convert_string_from_py_6libcpp_6string_std__in_string(__pyx_mstate_global->__pyx_kp_b_); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 226, __pyx_L1_error) + + /* "polluck_blockchain/placeholder_native.pyx":220 + * cdef uint64_t new_idx = self._index + 1 + * + * cdef Block *block = new Block( # <<<<<<<<<<<<<< + * new_idx, + * datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp(), +*/ + try { + __pyx_t_5 = new ::Block(__pyx_v_new_idx, __pyx_t_9, 0, __pyx_t_6, __pyx_v_prev_hash, __pyx_t_10); + } catch(...) { + __Pyx_CppExn2PyErr(); + __PYX_ERR(0, 220, __pyx_L1_error) + } + __pyx_v_block = __pyx_t_5; + + /* "polluck_blockchain/placeholder_native.pyx":228 + * "".encode("UTF-8"), + * ) + * self.add_block(block) # <<<<<<<<<<<<<< + * + * # def __init__( +*/ + ((struct __pyx_vtabstruct_18polluck_blockchain_18placeholder_native_Blockchain *)__pyx_v_self->__pyx_vtab)->add_block(__pyx_v_self, __pyx_v_block); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 228, __pyx_L1_error) + + /* "polluck_blockchain/placeholder_native.pyx":212 + * self._genesis_done = 1 + * + * def new_block(self, data): # <<<<<<<<<<<<<< + * if not self._genesis_done: + * raise RuntimeError("Create a genesis block first.") +*/ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("polluck_blockchain.placeholder_native.Blockchain.new_block", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" + * def __setstate_cython__(self, __pyx_state): +*/ + +/* Python wrapper */ +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_15__reduce_cython__(PyObject *__pyx_v_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +); /*proto*/ +static PyMethodDef __pyx_mdef_18polluck_blockchain_18placeholder_native_10Blockchain_15__reduce_cython__ = {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_15__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_15__reduce_cython__(PyObject *__pyx_v_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +) { + #if !CYTHON_METH_FASTCALL + CYTHON_UNUSED Py_ssize_t __pyx_nargs; + #endif + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); + #if !CYTHON_METH_FASTCALL + #if CYTHON_ASSUME_SAFE_SIZE + __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); + #else + __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; + #endif + #endif + __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); + if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("__reduce_cython__", 1, 0, 0, __pyx_nargs); return NULL; } + const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; + if (unlikely(__pyx_kwds_len < 0)) return NULL; + if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("__reduce_cython__", __pyx_kwds); return NULL;} + __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_14__reduce_cython__(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_14__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce_cython__", 0); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" +*/ + __Pyx_Raise(((PyObject *)(((PyTypeObject*)PyExc_TypeError))), __pyx_mstate_global->__pyx_kp_u_no_default___reduce___due_to_non, 0, 0); + __PYX_ERR(1, 2, __pyx_L1_error) + + /* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" + * def __setstate_cython__(self, __pyx_state): +*/ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_AddTraceback("polluck_blockchain.placeholder_native.Blockchain.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" +*/ + +/* Python wrapper */ +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_17__setstate_cython__(PyObject *__pyx_v_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +); /*proto*/ +static PyMethodDef __pyx_mdef_18polluck_blockchain_18placeholder_native_10Blockchain_17__setstate_cython__ = {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_17__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_17__setstate_cython__(PyObject *__pyx_v_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +) { + CYTHON_UNUSED PyObject *__pyx_v___pyx_state = 0; + #if !CYTHON_METH_FASTCALL + CYTHON_UNUSED Py_ssize_t __pyx_nargs; + #endif + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject* values[1] = {0}; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); + #if !CYTHON_METH_FASTCALL + #if CYTHON_ASSUME_SAFE_SIZE + __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); + #else + __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; + #endif + #endif + __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); + { + PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_pyx_state,0}; + const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(1, 3, __pyx_L3_error) + if (__pyx_kwds_len > 0) { + switch (__pyx_nargs) { + case 1: + values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(1, 3, __pyx_L3_error) + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + const Py_ssize_t kwd_pos_args = __pyx_nargs; + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "__setstate_cython__", 0) < (0)) __PYX_ERR(1, 3, __pyx_L3_error) + for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__setstate_cython__", 1, 1, 1, i); __PYX_ERR(1, 3, __pyx_L3_error) } + } + } else if (unlikely(__pyx_nargs != 1)) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(1, 3, __pyx_L3_error) + } + __pyx_v___pyx_state = values[0]; + } + goto __pyx_L6_skip; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__setstate_cython__", 1, 1, 1, __pyx_nargs); __PYX_ERR(1, 3, __pyx_L3_error) + __pyx_L6_skip:; + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + Py_XDECREF(values[__pyx_temp]); + } + __Pyx_AddTraceback("polluck_blockchain.placeholder_native.Blockchain.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_16__setstate_cython__(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *)__pyx_v_self), __pyx_v___pyx_state); + + /* function exit code */ + for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + Py_XDECREF(values[__pyx_temp]); + } + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_16__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate_cython__", 0); + + /* "(tree fragment)":4 + * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" + * def __setstate_cython__(self, __pyx_state): + * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" # <<<<<<<<<<<<<< +*/ + __Pyx_Raise(((PyObject *)(((PyTypeObject*)PyExc_TypeError))), __pyx_mstate_global->__pyx_kp_u_no_default___reduce___due_to_non, 0, 0); + __PYX_ERR(1, 4, __pyx_L1_error) + + /* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" +*/ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_AddTraceback("polluck_blockchain.placeholder_native.Blockchain.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* #### Code section: module_exttypes ### */ +static struct __pyx_vtabstruct_18polluck_blockchain_18placeholder_native_PyBlock __pyx_vtable_18polluck_blockchain_18placeholder_native_PyBlock; -static PyObject *__pyx_tp_new_18polluck_blockchain_18placeholder_native_BlockPy(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_18polluck_blockchain_18placeholder_native_BlockPy *p; +static PyObject *__pyx_tp_new_18polluck_blockchain_18placeholder_native_PyBlock(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *p; PyObject *o; o = __Pyx_AllocateExtensionType(t, 0); if (unlikely(!o)) return 0; - p = ((struct __pyx_obj_18polluck_blockchain_18placeholder_native_BlockPy *)o); - __Pyx_default_placement_construct(&(p->_data)); - __Pyx_default_placement_construct(&(p->_prev_hash)); - __Pyx_default_placement_construct(&(p->_hash)); - if (unlikely(__pyx_pw_18polluck_blockchain_18placeholder_native_7BlockPy_1__cinit__(o, a, k) < 0)) goto bad; + p = ((struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *)o); + p->__pyx_vtab = __pyx_vtabptr_18polluck_blockchain_18placeholder_native_PyBlock; + if (unlikely(__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_1__cinit__(o, a, k) < 0)) goto bad; return o; bad: Py_DECREF(o); o = 0; return NULL; } -static void __pyx_tp_dealloc_18polluck_blockchain_18placeholder_native_BlockPy(PyObject *o) { - struct __pyx_obj_18polluck_blockchain_18placeholder_native_BlockPy *p = (struct __pyx_obj_18polluck_blockchain_18placeholder_native_BlockPy *)o; +static void __pyx_tp_dealloc_18polluck_blockchain_18placeholder_native_PyBlock(PyObject *o) { #if CYTHON_USE_TP_FINALIZE if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && (!PyType_IS_GC(Py_TYPE(o)) || !__Pyx_PyObject_GC_IsFinalized(o))) { - if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_18polluck_blockchain_18placeholder_native_BlockPy) { + if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_18polluck_blockchain_18placeholder_native_PyBlock) { if (PyObject_CallFinalizerFromDealloc(o)) return; } } #endif - __Pyx_call_destructor(p->_data); - __Pyx_call_destructor(p->_prev_hash); - __Pyx_call_destructor(p->_hash); + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1); + __pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_5__dealloc__(o); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1); + PyErr_Restore(etype, eval, etb); + } PyTypeObject *tp = Py_TYPE(o); #if CYTHON_USE_TYPE_SLOTS (*tp->tp_free)(o); @@ -3806,34 +6072,69 @@ static void __pyx_tp_dealloc_18polluck_blockchain_18placeholder_native_BlockPy(P #endif } -static PyMethodDef __pyx_methods_18polluck_blockchain_18placeholder_native_BlockPy[] = { - {"get_data", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_7BlockPy_3get_data, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, - {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_7BlockPy_5__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, - {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_7BlockPy_7__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, +static PyObject *__pyx_getprop_18polluck_blockchain_18placeholder_native_7PyBlock_index(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_5index_1__get__(o); +} + +static PyObject *__pyx_getprop_18polluck_blockchain_18placeholder_native_7PyBlock_timestamp(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_9timestamp_1__get__(o); +} + +static PyObject *__pyx_getprop_18polluck_blockchain_18placeholder_native_7PyBlock_data(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_4data_1__get__(o); +} + +static PyObject *__pyx_getprop_18polluck_blockchain_18placeholder_native_7PyBlock_prev_hash(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_9prev_hash_1__get__(o); +} + +static PyObject *__pyx_getprop_18polluck_blockchain_18placeholder_native_7PyBlock_nonce(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_5nonce_1__get__(o); +} + +static PyObject *__pyx_getprop_18polluck_blockchain_18placeholder_native_7PyBlock_hash(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_4hash_1__get__(o); +} + +static PyMethodDef __pyx_methods_18polluck_blockchain_18placeholder_native_PyBlock[] = { + {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_7__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, + {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_9__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {0, 0, 0, 0} }; + +static struct PyGetSetDef __pyx_getsets_18polluck_blockchain_18placeholder_native_PyBlock[] = { + {"index", __pyx_getprop_18polluck_blockchain_18placeholder_native_7PyBlock_index, 0, 0, 0}, + {"timestamp", __pyx_getprop_18polluck_blockchain_18placeholder_native_7PyBlock_timestamp, 0, 0, 0}, + {"data", __pyx_getprop_18polluck_blockchain_18placeholder_native_7PyBlock_data, 0, 0, 0}, + {"prev_hash", __pyx_getprop_18polluck_blockchain_18placeholder_native_7PyBlock_prev_hash, 0, 0, 0}, + {"nonce", __pyx_getprop_18polluck_blockchain_18placeholder_native_7PyBlock_nonce, 0, 0, 0}, + {"hash", __pyx_getprop_18polluck_blockchain_18placeholder_native_7PyBlock_hash, 0, 0, 0}, + {0, 0, 0, 0, 0} +}; #if CYTHON_USE_TYPE_SPECS -static PyType_Slot __pyx_type_18polluck_blockchain_18placeholder_native_BlockPy_slots[] = { - {Py_tp_dealloc, (void *)__pyx_tp_dealloc_18polluck_blockchain_18placeholder_native_BlockPy}, - {Py_tp_methods, (void *)__pyx_methods_18polluck_blockchain_18placeholder_native_BlockPy}, - {Py_tp_new, (void *)__pyx_tp_new_18polluck_blockchain_18placeholder_native_BlockPy}, +static PyType_Slot __pyx_type_18polluck_blockchain_18placeholder_native_PyBlock_slots[] = { + {Py_tp_dealloc, (void *)__pyx_tp_dealloc_18polluck_blockchain_18placeholder_native_PyBlock}, + {Py_tp_methods, (void *)__pyx_methods_18polluck_blockchain_18placeholder_native_PyBlock}, + {Py_tp_getset, (void *)__pyx_getsets_18polluck_blockchain_18placeholder_native_PyBlock}, + {Py_tp_init, (void *)__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_3__init__}, + {Py_tp_new, (void *)__pyx_tp_new_18polluck_blockchain_18placeholder_native_PyBlock}, {0, 0}, }; -static PyType_Spec __pyx_type_18polluck_blockchain_18placeholder_native_BlockPy_spec = { - "polluck_blockchain.placeholder_native.BlockPy", - sizeof(struct __pyx_obj_18polluck_blockchain_18placeholder_native_BlockPy), +static PyType_Spec __pyx_type_18polluck_blockchain_18placeholder_native_PyBlock_spec = { + "polluck_blockchain.placeholder_native.PyBlock", + sizeof(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock), 0, Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, - __pyx_type_18polluck_blockchain_18placeholder_native_BlockPy_slots, + __pyx_type_18polluck_blockchain_18placeholder_native_PyBlock_slots, }; #else -static PyTypeObject __pyx_type_18polluck_blockchain_18placeholder_native_BlockPy = { +static PyTypeObject __pyx_type_18polluck_blockchain_18placeholder_native_PyBlock = { PyVarObject_HEAD_INIT(0, 0) - "polluck_blockchain.placeholder_native.""BlockPy", /*tp_name*/ - sizeof(struct __pyx_obj_18polluck_blockchain_18placeholder_native_BlockPy), /*tp_basicsize*/ + "polluck_blockchain.placeholder_native.""PyBlock", /*tp_name*/ + sizeof(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_18polluck_blockchain_18placeholder_native_BlockPy, /*tp_dealloc*/ + __pyx_tp_dealloc_18polluck_blockchain_18placeholder_native_PyBlock, /*tp_dealloc*/ 0, /*tp_vectorcall_offset*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -3856,9 +6157,9 @@ static PyTypeObject __pyx_type_18polluck_blockchain_18placeholder_native_BlockPy 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_18polluck_blockchain_18placeholder_native_BlockPy, /*tp_methods*/ + __pyx_methods_18polluck_blockchain_18placeholder_native_PyBlock, /*tp_methods*/ 0, /*tp_members*/ - 0, /*tp_getset*/ + __pyx_getsets_18polluck_blockchain_18placeholder_native_PyBlock, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ @@ -3866,9 +6167,188 @@ static PyTypeObject __pyx_type_18polluck_blockchain_18placeholder_native_BlockPy #if !CYTHON_USE_TYPE_SPECS 0, /*tp_dictoffset*/ #endif - 0, /*tp_init*/ + __pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_3__init__, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_18polluck_blockchain_18placeholder_native_BlockPy, /*tp_new*/ + __pyx_tp_new_18polluck_blockchain_18placeholder_native_PyBlock, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if CYTHON_USE_TP_FINALIZE + 0, /*tp_finalize*/ + #else + NULL, /*tp_finalize*/ + #endif + #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800 + 0, /*tp_vectorcall*/ + #endif + #if __PYX_NEED_TP_PRINT_SLOT == 1 + 0, /*tp_print*/ + #endif + #if PY_VERSION_HEX >= 0x030C0000 + 0, /*tp_watched*/ + #endif + #if PY_VERSION_HEX >= 0x030d00A4 + 0, /*tp_versions_used*/ + #endif + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000 + 0, /*tp_pypy_flags*/ + #endif +}; +#endif +static struct __pyx_vtabstruct_18polluck_blockchain_18placeholder_native_Blockchain __pyx_vtable_18polluck_blockchain_18placeholder_native_Blockchain; + +static PyObject *__pyx_tp_new_18polluck_blockchain_18placeholder_native_Blockchain(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *p; + PyObject *o; + o = __Pyx_AllocateExtensionType(t, 0); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *)o); + p->__pyx_vtab = __pyx_vtabptr_18polluck_blockchain_18placeholder_native_Blockchain; + if (unlikely(__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_1__cinit__(o, __pyx_mstate_global->__pyx_empty_tuple, NULL) < 0)) goto bad; + return o; + bad: + Py_DECREF(o); o = 0; + return NULL; +} + +static void __pyx_tp_dealloc_18polluck_blockchain_18placeholder_native_Blockchain(PyObject *o) { + #if CYTHON_USE_TP_FINALIZE + if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && (!PyType_IS_GC(Py_TYPE(o)) || !__Pyx_PyObject_GC_IsFinalized(o))) { + if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_18polluck_blockchain_18placeholder_native_Blockchain) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + } + #endif + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1); + __pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_5__dealloc__(o); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1); + PyErr_Restore(etype, eval, etb); + } + PyTypeObject *tp = Py_TYPE(o); + #if CYTHON_USE_TYPE_SLOTS + (*tp->tp_free)(o); + #else + { + freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free); + if (tp_free) tp_free(o); + } + #endif + #if CYTHON_USE_TYPE_SPECS + Py_DECREF(tp); + #endif +} + +static PyObject *__pyx_getprop_18polluck_blockchain_18placeholder_native_10Blockchain_genesis_done(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_12genesis_done_1__get__(o); +} + +static PyObject *__pyx_getprop_18polluck_blockchain_18placeholder_native_10Blockchain_index(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_5index_1__get__(o); +} + +static PyMethodDef __pyx_methods_18polluck_blockchain_18placeholder_native_Blockchain[] = { + {"get_block", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_9get_block, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, + {"create_genesis_block", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_11create_genesis_block, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, + {"new_block", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_13new_block, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, + {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_15__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, + {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_17__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_18polluck_blockchain_18placeholder_native_Blockchain[] = { + {"genesis_done", __pyx_getprop_18polluck_blockchain_18placeholder_native_10Blockchain_genesis_done, 0, 0, 0}, + {"index", __pyx_getprop_18polluck_blockchain_18placeholder_native_10Blockchain_index, 0, 0, 0}, + {0, 0, 0, 0, 0} +}; +#if CYTHON_USE_TYPE_SPECS +static PyType_Slot __pyx_type_18polluck_blockchain_18placeholder_native_Blockchain_slots[] = { + {Py_tp_dealloc, (void *)__pyx_tp_dealloc_18polluck_blockchain_18placeholder_native_Blockchain}, + {Py_sq_length, (void *)__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_7__len__}, + {Py_mp_length, (void *)__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_7__len__}, + {Py_tp_methods, (void *)__pyx_methods_18polluck_blockchain_18placeholder_native_Blockchain}, + {Py_tp_getset, (void *)__pyx_getsets_18polluck_blockchain_18placeholder_native_Blockchain}, + {Py_tp_init, (void *)__pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_3__init__}, + {Py_tp_new, (void *)__pyx_tp_new_18polluck_blockchain_18placeholder_native_Blockchain}, + {0, 0}, +}; +static PyType_Spec __pyx_type_18polluck_blockchain_18placeholder_native_Blockchain_spec = { + "polluck_blockchain.placeholder_native.Blockchain", + sizeof(struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain), + 0, + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, + __pyx_type_18polluck_blockchain_18placeholder_native_Blockchain_slots, +}; +#else + +static PySequenceMethods __pyx_tp_as_sequence_Blockchain = { + __pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_7__len__, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_Blockchain = { + __pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_7__len__, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyTypeObject __pyx_type_18polluck_blockchain_18placeholder_native_Blockchain = { + PyVarObject_HEAD_INIT(0, 0) + "polluck_blockchain.placeholder_native.""Blockchain", /*tp_name*/ + sizeof(struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_18polluck_blockchain_18placeholder_native_Blockchain, /*tp_dealloc*/ + 0, /*tp_vectorcall_offset*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_as_async*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + &__pyx_tp_as_sequence_Blockchain, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_Blockchain, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_18polluck_blockchain_18placeholder_native_Blockchain, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_18polluck_blockchain_18placeholder_native_Blockchain, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + #if !CYTHON_USE_TYPE_SPECS + 0, /*tp_dictoffset*/ + #endif + __pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchain_3__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_18polluck_blockchain_18placeholder_native_Blockchain, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -3954,27 +6434,57 @@ static int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate) { int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); /*--- Type init code ---*/ + __pyx_vtabptr_18polluck_blockchain_18placeholder_native_PyBlock = &__pyx_vtable_18polluck_blockchain_18placeholder_native_PyBlock; + __pyx_vtable_18polluck_blockchain_18placeholder_native_PyBlock.from_ptr = (struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *(*)(::Block *, struct __pyx_opt_args_18polluck_blockchain_18placeholder_native_7PyBlock_from_ptr *__pyx_optional_args))__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_from_ptr; #if CYTHON_USE_TYPE_SPECS - __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_BlockPy = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_18polluck_blockchain_18placeholder_native_BlockPy_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_BlockPy)) __PYX_ERR(0, 88, __pyx_L1_error) - if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_18polluck_blockchain_18placeholder_native_BlockPy_spec, __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_BlockPy) < (0)) __PYX_ERR(0, 88, __pyx_L1_error) + __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_18polluck_blockchain_18placeholder_native_PyBlock_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock)) __PYX_ERR(0, 32, __pyx_L1_error) + if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_18polluck_blockchain_18placeholder_native_PyBlock_spec, __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock) < (0)) __PYX_ERR(0, 32, __pyx_L1_error) #else - __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_BlockPy = &__pyx_type_18polluck_blockchain_18placeholder_native_BlockPy; + __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock = &__pyx_type_18polluck_blockchain_18placeholder_native_PyBlock; #endif #if !CYTHON_COMPILING_IN_LIMITED_API #endif #if !CYTHON_USE_TYPE_SPECS - if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_BlockPy) < (0)) __PYX_ERR(0, 88, __pyx_L1_error) + if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock) < (0)) __PYX_ERR(0, 32, __pyx_L1_error) #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 - PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_BlockPy); + PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock); #endif #if !CYTHON_COMPILING_IN_LIMITED_API - if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_BlockPy->tp_dictoffset && __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_BlockPy->tp_getattro == PyObject_GenericGetAttr)) { - __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_BlockPy->tp_getattro = PyObject_GenericGetAttr; + if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock->tp_dictoffset && __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock->tp_getattro == PyObject_GenericGetAttr)) { + __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock->tp_getattro = PyObject_GenericGetAttr; } #endif - if (PyObject_SetAttr(__pyx_m, __pyx_mstate_global->__pyx_n_u_BlockPy, (PyObject *) __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_BlockPy) < (0)) __PYX_ERR(0, 88, __pyx_L1_error) - if (__Pyx_setup_reduce((PyObject *) __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_BlockPy) < (0)) __PYX_ERR(0, 88, __pyx_L1_error) + if (__Pyx_SetVtable(__pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock, __pyx_vtabptr_18polluck_blockchain_18placeholder_native_PyBlock) < (0)) __PYX_ERR(0, 32, __pyx_L1_error) + if (__Pyx_MergeVtables(__pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock) < (0)) __PYX_ERR(0, 32, __pyx_L1_error) + if (PyObject_SetAttr(__pyx_m, __pyx_mstate_global->__pyx_n_u_PyBlock, (PyObject *) __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock) < (0)) __PYX_ERR(0, 32, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject *) __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock) < (0)) __PYX_ERR(0, 32, __pyx_L1_error) + __pyx_vtabptr_18polluck_blockchain_18placeholder_native_Blockchain = &__pyx_vtable_18polluck_blockchain_18placeholder_native_Blockchain; + __pyx_vtable_18polluck_blockchain_18placeholder_native_Blockchain.get_block_c = (::Block *(*)(struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *, uint64_t))__pyx_f_18polluck_blockchain_18placeholder_native_10Blockchain_get_block_c; + __pyx_vtable_18polluck_blockchain_18placeholder_native_Blockchain.add_block = (void (*)(struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain *, ::Block *))__pyx_f_18polluck_blockchain_18placeholder_native_10Blockchain_add_block; + #if CYTHON_USE_TYPE_SPECS + __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_Blockchain = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_18polluck_blockchain_18placeholder_native_Blockchain_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_Blockchain)) __PYX_ERR(0, 150, __pyx_L1_error) + if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_18polluck_blockchain_18placeholder_native_Blockchain_spec, __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_Blockchain) < (0)) __PYX_ERR(0, 150, __pyx_L1_error) + #else + __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_Blockchain = &__pyx_type_18polluck_blockchain_18placeholder_native_Blockchain; + #endif + #if !CYTHON_COMPILING_IN_LIMITED_API + #endif + #if !CYTHON_USE_TYPE_SPECS + if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_Blockchain) < (0)) __PYX_ERR(0, 150, __pyx_L1_error) + #endif + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 + PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_Blockchain); + #endif + #if !CYTHON_COMPILING_IN_LIMITED_API + if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_Blockchain->tp_dictoffset && __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_Blockchain->tp_getattro == PyObject_GenericGetAttr)) { + __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_Blockchain->tp_getattro = PyObject_GenericGetAttr; + } + #endif + if (__Pyx_SetVtable(__pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_Blockchain, __pyx_vtabptr_18polluck_blockchain_18placeholder_native_Blockchain) < (0)) __PYX_ERR(0, 150, __pyx_L1_error) + if (__Pyx_MergeVtables(__pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_Blockchain) < (0)) __PYX_ERR(0, 150, __pyx_L1_error) + if (PyObject_SetAttr(__pyx_m, __pyx_mstate_global->__pyx_n_u_Blockchain, (PyObject *) __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_Blockchain) < (0)) __PYX_ERR(0, 150, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject *) __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_Blockchain) < (0)) __PYX_ERR(0, 150, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -4340,27 +6850,12 @@ __Pyx_RefNannySetupContext("PyInit_placeholder_native", 0); if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_dopt_basics, __pyx_t_2) < (0)) __PYX_ERR(0, 13, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "polluck_blockchain/placeholder_native.pyx":113 - * ) - * - * def get_data(self): # <<<<<<<<<<<<<< - * return self.Block.data.decode("UTF-8") - * -*/ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_18placeholder_native_7BlockPy_3get_data, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_BlockPy_get_data, NULL, __pyx_mstate_global->__pyx_n_u_polluck_blockchain_placeholder_n, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 - PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); - #endif - if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_18polluck_blockchain_18placeholder_native_BlockPy, __pyx_mstate_global->__pyx_n_u_get_data, __pyx_t_2) < (0)) __PYX_ERR(0, 113, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" * def __setstate_cython__(self, __pyx_state): */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_18placeholder_native_7BlockPy_5__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_BlockPy___reduce_cython, NULL, __pyx_mstate_global->__pyx_n_u_polluck_blockchain_placeholder_n, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[1])); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_18placeholder_native_7PyBlock_7__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_PyBlock___reduce_cython, NULL, __pyx_mstate_global->__pyx_n_u_polluck_blockchain_placeholder_n, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); @@ -4374,7 +6869,79 @@ __Pyx_RefNannySetupContext("PyInit_placeholder_native", 0); * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_18placeholder_native_7BlockPy_7__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_BlockPy___setstate_cython, NULL, __pyx_mstate_global->__pyx_n_u_polluck_blockchain_placeholder_n, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[2])); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_18placeholder_native_7PyBlock_9__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_PyBlock___setstate_cython, NULL, __pyx_mstate_global->__pyx_n_u_polluck_blockchain_placeholder_n, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[1])); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 + PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); + #endif + if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_setstate_cython, __pyx_t_2) < (0)) __PYX_ERR(1, 3, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "polluck_blockchain/placeholder_native.pyx":187 + * return self._chain[0][idx] + * + * def get_block(self, idx): # <<<<<<<<<<<<<< + * if idx < 0 or idx > self._index: + * raise IndexError("Index value is out of bounds") +*/ + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_18placeholder_native_10Blockchain_9get_block, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Blockchain_get_block, NULL, __pyx_mstate_global->__pyx_n_u_polluck_blockchain_placeholder_n, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[2])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 187, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 + PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); + #endif + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_18polluck_blockchain_18placeholder_native_Blockchain, __pyx_mstate_global->__pyx_n_u_get_block, __pyx_t_2) < (0)) __PYX_ERR(0, 187, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "polluck_blockchain/placeholder_native.pyx":199 + * self._index += 1 + * + * def create_genesis_block(self): # <<<<<<<<<<<<<< + * cdef Block *block = new Block( + * self._index, +*/ + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_18placeholder_native_10Blockchain_11create_genesis_block, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Blockchain_create_genesis_block, NULL, __pyx_mstate_global->__pyx_n_u_polluck_blockchain_placeholder_n, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[3])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 + PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); + #endif + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_18polluck_blockchain_18placeholder_native_Blockchain, __pyx_mstate_global->__pyx_n_u_create_genesis_block, __pyx_t_2) < (0)) __PYX_ERR(0, 199, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "polluck_blockchain/placeholder_native.pyx":212 + * self._genesis_done = 1 + * + * def new_block(self, data): # <<<<<<<<<<<<<< + * if not self._genesis_done: + * raise RuntimeError("Create a genesis block first.") +*/ + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_18placeholder_native_10Blockchain_13new_block, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Blockchain_new_block, NULL, __pyx_mstate_global->__pyx_n_u_polluck_blockchain_placeholder_n, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[4])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 212, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 + PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); + #endif + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_18polluck_blockchain_18placeholder_native_Blockchain, __pyx_mstate_global->__pyx_n_u_new_block, __pyx_t_2) < (0)) __PYX_ERR(0, 212, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" + * def __setstate_cython__(self, __pyx_state): +*/ + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_18placeholder_native_10Blockchain_15__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Blockchain___reduce_cython, NULL, __pyx_mstate_global->__pyx_n_u_polluck_blockchain_placeholder_n, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[5])); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 + PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); + #endif + if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_reduce_cython, __pyx_t_2) < (0)) __PYX_ERR(1, 1, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" +*/ + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_18placeholder_native_10Blockchain_17__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Blockchain___setstate_cython, NULL, __pyx_mstate_global->__pyx_n_u_polluck_blockchain_placeholder_n, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[6])); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); @@ -4445,14 +7012,14 @@ static int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate) { CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "polluck_blockchain/placeholder_native.pyx":106 - * self.Block = new Block( - * index, - * datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp(), # <<<<<<<<<<<<<< - * nonce, - * data.encode("UTF-8"), + /* "polluck_blockchain/placeholder_native.pyx":54 + * self.BlockC = new Block( + * index, + * datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp(), # <<<<<<<<<<<<<< + * nonce, + * data.encode("UTF-8"), */ - __pyx_mstate_global->__pyx_tuple[0] = PyTuple_Pack(6, __pyx_mstate_global->__pyx_int_2025, __pyx_mstate_global->__pyx_int_12, __pyx_mstate_global->__pyx_int_1, __pyx_mstate_global->__pyx_int_12, __pyx_mstate_global->__pyx_int_0, __pyx_mstate_global->__pyx_int_0); if (unlikely(!__pyx_mstate_global->__pyx_tuple[0])) __PYX_ERR(0, 106, __pyx_L1_error) + __pyx_mstate_global->__pyx_tuple[0] = PyTuple_Pack(6, __pyx_mstate_global->__pyx_int_2025, __pyx_mstate_global->__pyx_int_12, __pyx_mstate_global->__pyx_int_1, __pyx_mstate_global->__pyx_int_12, __pyx_mstate_global->__pyx_int_0, __pyx_mstate_global->__pyx_int_0); if (unlikely(!__pyx_mstate_global->__pyx_tuple[0])) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[0]); __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[0]); #if CYTHON_IMMORTAL_CONSTANTS @@ -4478,34 +7045,34 @@ static int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate) { static int __Pyx_InitConstants(__pyx_mstatetype *__pyx_mstate) { CYTHON_UNUSED_VAR(__pyx_mstate); { - const struct { const unsigned int length: 8; } index[] = {{179},{1},{8},{2},{7},{6},{2},{9},{50},{45},{14},{7},{25},{27},{16},{20},{12},{18},{18},{4},{8},{11},{20},{13},{8},{8},{12},{7},{5},{13},{5},{8},{10},{8},{5},{4},{37},{3},{13},{11},{12},{10},{17},{13},{4},{12},{10},{12},{19},{6},{8},{4},{9},{6},{0},{17},{9}}; - #if (CYTHON_COMPRESS_STRINGS) == 2 /* compression: bz2 (583 bytes) */ -const char* const cstring = "BZh91AY&SY\301\315\211:\000\000*\377\362dP\202\000@\213\205E\277#\366\020\277\377\377`@@@@@\000\000@@\002\006\273\213\260\33454\236\211\250h\000\000\000\00016\240h\332A\240\230\224\364\312i\232\246\024\366\251\240\014\020\001\210d=@\324\364\247\251\244\323L\215\006\200\320\000\000\000\000\004\244\324L\311=#G\251\240\023\001\031\014\214\203F\214\006\220\211g\n[\270\373m\206\310w;/\335\272\254\370\245\024G\370\304\265 y!k\245&\t\272)\214\244 y&d\335\031\235i\317\213\270\250\334\033;\330:\375\2415\0241P\215\261\256P\024,\317\227\316U0\220\002\310\216\020\311,\216\316\006#\214&w\311Z\266\317\222\333PB\260\251\200\201\030\206k@PO!\342K\022z\202u\020@2C\002\201>K\332%\256\266\326\023~\341\366x\020\300\375\276i\036>s\224pF\241B\2131p\303n\222\301d\274\221\026*\271\222!Q\"\272H\276\333\000\340\303\213\217$iR\203\260\220\024L\224V\223>\274s=\242\211\252\2260K\2174\370l\204\347\221\341\242(C4C3\251\355\345h\211\020u\345\210e\230g\301\350,\264\212\263\215\3164\243Tb\334\001\211\t\"\230\266\372u_\247ffOd\340\241~\230\\b\300\311`T \3423\255{2\t}\035Kc)\225\344Uay\313R\212\362\243V1\007\314)\002(\230\321U\327C\337@hG\204\261\207\037\236\214V\016\210\025\364(\250A\004\202P;9C|\2471\231\220L\3263<\320\303\340\013G\310f.\2230!%Ap\274O^\370\3240\275\\~\370\372\021\271\26117\270b\271\333n\266\334f5\3412\365T$Q(\202\366j\234\245\272\322\201U\002\333\300\363*\026\242\250S\017\375T\014\307D\352\252\325+\220r\202R-\212aA;\321E\000\332B\006F\330d\"f&M\200\373\233L\006n\353v\224\302\203\313\352\270\226r\353B\020\n\320\0301\216\372A\364\\<\340\023H\311\345\343\311\2639\331\032\351\377\213\271\"\234(H`\346\304\235\000"; - PyObject *data = __Pyx_DecompressString(cstring, 583, 2); + const struct { const unsigned int length: 7; } index[] = {{33},{25},{29},{28},{5},{1},{2},{7},{6},{2},{9},{50},{45},{14},{10},{28},{30},{31},{20},{20},{7},{25},{27},{20},{12},{18},{5},{18},{20},{4},{8},{11},{20},{6},{8},{13},{8},{9},{12},{7},{3},{5},{13},{5},{8},{10},{8},{9},{7},{5},{4},{37},{3},{10},{9},{13},{11},{14},{12},{10},{17},{13},{4},{12},{10},{12},{19},{6},{8},{4},{9},{6},{0},{1},{13},{10},{52},{117},{101},{9}}; + #if (CYTHON_COMPRESS_STRINGS) == 2 /* compression: bz2 (809 bytes) */ +const char* const cstring = "BZh91AY&SY\240\321\327G\000\000I\377\373l\337\365\216t\037\354\305\277\363\367T\277\377\377\340@@@@@@@@@@@\000@\002\335k\000(HjhMM\244\312yM\244\317T\323M\032\006&\200\320\000\000\000zF\020\364\231<\220\211 z\231\036\210\001\240\000\000\006\200\003A\240\r\000\001\240\016\032\0322h\321\243M\014\214\206\020\006@\014\203M\000\0002\006@\022\232D\304ODi2b\217\324\325\037\251\224\014\232h\320\000\000\000\000\031\223G\245>@:\374]^O'Y\306\020s\261\t!2\254p\"3v9\004-,\031\204P\202\022\264\034\305\035\334\021\022-\217\271\311\277\024\215\205\\k\362c\212\223 \320AF\023C)v\272\351\210\233wdT\2514\207\300\006\241\222\201D0R\023\026\220bL\320\330E\2061\267\034\014v\033\363\341:\031\002q\201\256\224svG\004+\215\230\356\325\312[j\021\235\246\333\314\rp\340\355J\356\306-z\215\225\202b\272\306\260\027\253\207\303\301{\r\361\262\243U\034\021\266\263;=~\203\352\323k\311\320t\225D\350\037\237fF\033(\3756/)\232\202&-)\311\314\270;\314\314\331$\273(m\337\206\2733\313<\211\033\307\034\003\347\034\300\267\317\211AGl`\2763\377\270\371\345\340\347\327\243\003tr\274\207\365P\022\256\352DE0\n\016\344\3126\t\200\210Kd\"\350T\033\203\345\026\376\024\033\014\0373<`T\205P\001\326\234\350\031X\277v3I\024\314.R\001\nM\344Vg\005\256A\210\220\037K\202\320\264\005\005,\313@\240\250\256\340mN\007\334\t\007\301\325S\252\334\260@#\024@\257\\\241\201\242\261`\016I\034\300:m\237\003\220\000\004BX\010\245\314\013\242>/\210P\205a\304\372\345\241\0029*\016p\025\353b\203\020\210\006M\210:\3307N\246\216A/\306\242dq#\324\271\261M\rP\027LN\370\305\374&\354\001M\264>3Ut\313\204A\2641\314\026\031\350&\374\241\253\323\316\026\257L\277\3764y\206\205Hh\034\004C\367P\273\227\215\274zo\264=\212\354\252}ci\262\236\354\247\225\274\266j_$\215\244uU}\n\373Z\326\310Zy\365\221\345I/]\312Z\3271\306n\271\223\257\022\234\364\256\252k\351\303\364l\2742~>\306y\325K\027\2635\267,\244\237\263\335\014\273D\315\264\225\327\226\362\332C\333LZ\211\237\356gw\262\355L\217\327\307\207\277q\341Y\266wm/\251\024\370\376\250c[\026\002k\243C\213m\317]:\311\261l+\377\313\362$y\233\256\245@\355\301\350\302E\316\344Z\032\235\332\323\344,{<\256\214W\362\353\324\000""\376\324\236%?\322\255\313J\276\2608zi[\177\001\357N\367|"; + PyObject *data = __Pyx_DecompressString(cstring, 711, 1); if (unlikely(!data)) __PYX_ERR(0, 1, __pyx_L1_error) const char* const bytes = __Pyx_PyBytes_AsString(data); #if !CYTHON_ASSUME_SAFE_MACROS if (likely(bytes)); else { Py_DECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) } #endif - #else /* compression: none (847 bytes) */ -const char* const bytes = "Note that Cython is deliberately stricter than PEP-484 and rejects subclasses of builtin types. If you need to pass subclasses then set the 'annotation_typing' directive to False.?add_note>ddisableenablegcisenabledno default __reduce__ due to non-trivial __cinit__src/polluck_blockchain/placeholder_native.pyxBlockPyBlockPy.__reduce_cython__BlockPy.__setstate_cython__BlockPy.get_data__Pyx_PyDict_NextRefTIMEZONE_UTCasyncio.coroutinescline_in_tracebackdatadatetimedopt_basicsdopt_basics.datetimefromtimestamp__func__get_data__getstate__hashlibindex_is_coroutineitems__main____module____name__noncepackpolluck_blockchain.placeholder_nativepopprevious_hash__pyx_state__qualname____reduce____reduce_cython____reduce_ex__self__set_name__setdefault__setstate____setstate_cython__struct__test__timetimestampvalues\200A\330\010\017\210t\2206\230\025\230g\240Q\240a\200\001\330\004\n\210+\220Q"; + #else /* compression: none (1272 bytes) */ +const char* const bytes = "Allocation of block object failedCould not allocate hasmapCreate a genesis block first.Index value is out of boundsUTF-8?>ddisableenablegcisenabledno default __reduce__ due to non-trivial __cinit__src/polluck_blockchain/placeholder_native.pyxBlockchainBlockchain.__reduce_cython__Blockchain.__setstate_cython__Blockchain.create_genesis_blockBlockchain.get_blockBlockchain.new_blockPyBlockPyBlock.__reduce_cython__PyBlock.__setstate_cython____Pyx_PyDict_NextRefTIMEZONE_UTCasyncio.coroutinesblockcline_in_tracebackcreate_genesis_blockdatadatetimedopt_basicsdopt_basics.datetimeencodefrom_ptrfromtimestamp__func__get_block__getstate__hashlibidxindex_is_coroutineitems__main____module____name__new_blocknew_idxnoncepackpolluck_blockchain.placeholder_nativepopprev_blockprev_hashprevious_hash__pyx_state__pyx_vtable____qualname____reduce____reduce_cython____reduce_ex__self__set_name__setdefault__setstate____setstate_cython__struct__test__timetimestampvalues0Genesis Blockdummy hash\200A\330\010\013\2104\210r\220\022\2203\220d\230\"\230D\240\001\330\014\022\220*\230A\230Q\340\010\034\230D\240\014\250A\250Q\330\010\026\220i\230q\240\r\250Q\200A\330\010\013\2104\210t\2201\330\014\022\220,\230a\230q\340\010!\240\024\240\\\260\021\260$\260a\330\010 \240\n\250!\330\010 \240\004\240H\250B\250a\340\010\034\230I\240Q\330\014\r\330\014\024\220I\230Q\230f\240D\250\003\2504\250s\260\"\260J\270a\330\014\r\330\014\020\220\007\220q\230\001\330\014\r\330\014\016\210g\220Q\220a\340\010\014\210J\220a\220q\200A\330\010\034\230I\240Q\330\014\020\220\001\330\014\024\220I\230Q\230f\240D\250\003\2504\250s\260\"\260J\270a\330\014\r\330\014\033\2307\240!\2401\330\014\017\210w\220a\220q\330\014\016\210g\220Q\220a\340\010\r\210X\220X\230\\\250\027\260\001\260\021\330\010\014\210J\220a\220q\330\010\014\320\014\035\230V\2401\200\001\330\004\n\210+\220Q"; PyObject *data = NULL; CYTHON_UNUSED_VAR(__Pyx_DecompressString); #endif PyObject **stringtab = __pyx_mstate->__pyx_string_tab; Py_ssize_t pos = 0; - for (int i = 0; i < 54; i++) { + for (int i = 0; i < 72; i++) { Py_ssize_t bytes_length = index[i].length; PyObject *string = PyUnicode_DecodeUTF8(bytes + pos, bytes_length, NULL); - if (likely(string) && i >= 11) PyUnicode_InternInPlace(&string); + if (likely(string) && i >= 14) PyUnicode_InternInPlace(&string); if (unlikely(!string)) { Py_XDECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) @@ -4513,7 +7080,7 @@ const char* const bytes = "Note that Cython is deliberately stricter than PEP-48 stringtab[i] = string; pos += bytes_length; } - for (int i = 54; i < 57; i++) { + for (int i = 72; i < 80; i++) { Py_ssize_t bytes_length = index[i].length; PyObject *string = PyBytes_FromStringAndSize(bytes + pos, bytes_length); stringtab[i] = string; @@ -4524,15 +7091,15 @@ const char* const bytes = "Note that Cython is deliberately stricter than PEP-48 } } Py_XDECREF(data); - for (Py_ssize_t i = 0; i < 57; i++) { + for (Py_ssize_t i = 0; i < 80; i++) { if (unlikely(PyObject_Hash(stringtab[i]) == -1)) { __PYX_ERR(0, 1, __pyx_L1_error) } } #if CYTHON_IMMORTAL_CONSTANTS { - PyObject **table = stringtab + 54; - for (Py_ssize_t i=0; i<3; ++i) { + PyObject **table = stringtab + 72; + for (Py_ssize_t i=0; i<8; ++i) { #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL); #else @@ -4572,9 +7139,9 @@ typedef struct { unsigned int argcount : 2; unsigned int num_posonly_args : 1; unsigned int num_kwonly_args : 1; - unsigned int nlocals : 2; + unsigned int nlocals : 3; unsigned int flags : 10; - unsigned int first_line : 7; + unsigned int first_line : 8; } __Pyx_PyCode_New_function_description; /* NewCodeObj.proto */ static PyObject* __Pyx_PyCode_New( @@ -4590,20 +7157,40 @@ static PyObject* __Pyx_PyCode_New( static int __Pyx_CreateCodeObjects(__pyx_mstatetype *__pyx_mstate) { PyObject* tuple_dedup_map = PyDict_New(); if (unlikely(!tuple_dedup_map)) return -1; - { - const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 113}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; - __pyx_mstate_global->__pyx_codeobj_tab[0] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_src_polluck_blockchain_placehold, __pyx_mstate->__pyx_n_u_get_data, __pyx_mstate->__pyx_kp_b_iso88591_A_t6_gQa, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[0])) goto bad; - } { const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 1}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; - __pyx_mstate_global->__pyx_codeobj_tab[1] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_reduce_cython, __pyx_mstate->__pyx_kp_b_iso88591_Q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[1])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[0] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_reduce_cython, __pyx_mstate->__pyx_kp_b_iso88591_Q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[0])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 3}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_pyx_state}; - __pyx_mstate_global->__pyx_codeobj_tab[2] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_setstate_cython, __pyx_mstate->__pyx_kp_b_iso88591_Q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[2])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[1] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_setstate_cython, __pyx_mstate->__pyx_kp_b_iso88591_Q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[1])) goto bad; + } + { + const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 3, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 187}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_idx, __pyx_mstate->__pyx_n_u_block}; + __pyx_mstate_global->__pyx_codeobj_tab[2] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_src_polluck_blockchain_placehold, __pyx_mstate->__pyx_n_u_get_block, __pyx_mstate->__pyx_kp_b_iso88591_A_4r_3d_D_AQ_D_AQ_iq_Q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[2])) goto bad; + } + { + const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 199}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_block}; + __pyx_mstate_global->__pyx_codeobj_tab[3] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_src_polluck_blockchain_placehold, __pyx_mstate->__pyx_n_u_create_genesis_block, __pyx_mstate->__pyx_kp_b_iso88591_A_IQ_IQfD_4s_Ja_7_1_waq_gQa_XX_J, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[3])) goto bad; + } + { + const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 6, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 212}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_data, __pyx_mstate->__pyx_n_u_prev_block, __pyx_mstate->__pyx_n_u_prev_hash, __pyx_mstate->__pyx_n_u_new_idx, __pyx_mstate->__pyx_n_u_block}; + __pyx_mstate_global->__pyx_codeobj_tab[4] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_src_polluck_blockchain_placehold, __pyx_mstate->__pyx_n_u_new_block, __pyx_mstate->__pyx_kp_b_iso88591_A_4t1_aq_a_HBa_IQ_IQfD_4s_Ja_q_g, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[4])) goto bad; + } + { + const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 1}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; + __pyx_mstate_global->__pyx_codeobj_tab[5] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_reduce_cython, __pyx_mstate->__pyx_kp_b_iso88591_Q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[5])) goto bad; + } + { + const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 3}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_pyx_state}; + __pyx_mstate_global->__pyx_codeobj_tab[6] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_setstate_cython, __pyx_mstate->__pyx_kp_b_iso88591_Q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[6])) goto bad; } Py_DECREF(tuple_dedup_map); return 0; @@ -5935,148 +8522,6 @@ static void __Pyx_RaiseArgtupleInvalid( (num_expected == 1) ? "" : "s", num_found); } -/* pybuiltin_invalid (used by pyint_simplify) */ -static void __Pyx_PyBuiltin_Invalid(PyObject *obj, const char *type_name, const char *argname) { - __Pyx_TypeName obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj)); - if (argname) { - PyErr_Format(PyExc_TypeError, - "Argument '%.200s' has incorrect type (expected %.200s, got " __Pyx_FMT_TYPENAME ")", - argname, type_name, obj_type_name - ); - } else { - PyErr_Format(PyExc_TypeError, - "Expected %.200s, got " __Pyx_FMT_TYPENAME, - type_name, obj_type_name - ); - } - __Pyx_DECREF_TypeName(obj_type_name); -} - -/* pyint_simplify */ -static CYTHON_INLINE int __Pyx_PyInt_FromNumber(PyObject **number_var, const char *argname, int accept_none) { - PyObject *number = *number_var; - if (likely((accept_none && number == Py_None) || PyLong_CheckExact(number))) { - return 0; - } - PyObject *int_object; - if (likely(PyNumber_Check(number))) { - int_object = PyNumber_Long(number); - if (unlikely(!int_object)) goto bad; - } else { - __Pyx_PyBuiltin_Invalid(number, "int", argname); - goto bad; - } - *number_var = int_object; - Py_DECREF(number); - return 0; -bad: - *number_var = NULL; - Py_DECREF(number); - return -1; -} - -/* ArgTypeTestFunc (used by ArgTypeTest) */ -static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) -{ - __Pyx_TypeName type_name; - __Pyx_TypeName obj_type_name; - PyObject *extra_info = __pyx_mstate_global->__pyx_empty_unicode; - int from_annotation_subclass = 0; - if (unlikely(!type)) { - PyErr_SetString(PyExc_SystemError, "Missing type object"); - return 0; - } - else if (!exact) { - if (likely(__Pyx_TypeCheck(obj, type))) return 1; - } else if (exact == 2) { - if (__Pyx_TypeCheck(obj, type)) { - from_annotation_subclass = 1; - extra_info = __pyx_mstate_global->__pyx_kp_u_Note_that_Cython_is_deliberately; - } - } - type_name = __Pyx_PyType_GetFullyQualifiedName(type); - obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj)); - PyErr_Format(PyExc_TypeError, - "Argument '%.200s' has incorrect type (expected " __Pyx_FMT_TYPENAME - ", got " __Pyx_FMT_TYPENAME ")" -#if __PYX_LIMITED_VERSION_HEX < 0x030C0000 - "%s%U" -#endif - , name, type_name, obj_type_name -#if __PYX_LIMITED_VERSION_HEX < 0x030C0000 - , (from_annotation_subclass ? ". " : ""), extra_info -#endif - ); -#if __PYX_LIMITED_VERSION_HEX >= 0x030C0000 - if (exact == 2 && from_annotation_subclass) { - PyObject *res; - PyObject *vargs[2]; - vargs[0] = PyErr_GetRaisedException(); - vargs[1] = extra_info; - res = PyObject_VectorcallMethod(__pyx_mstate_global->__pyx_kp_u_add_note, vargs, 2, NULL); - Py_XDECREF(res); - PyErr_SetRaisedException(vargs[0]); - } -#endif - __Pyx_DECREF_TypeName(type_name); - __Pyx_DECREF_TypeName(obj_type_name); - return 0; -} - -/* RejectKeywords */ -static void __Pyx_RejectKeywords(const char* function_name, PyObject *kwds) { - PyObject *key = NULL; - if (CYTHON_METH_FASTCALL && likely(PyTuple_Check(kwds))) { - key = __Pyx_PySequence_ITEM(kwds, 0); - } else { -#if CYTHON_AVOID_BORROWED_REFS - PyObject *pos = NULL; -#else - Py_ssize_t pos = 0; -#endif -#if !CYTHON_COMPILING_IN_PYPY || defined(PyArg_ValidateKeywordArguments) - if (unlikely(!PyArg_ValidateKeywordArguments(kwds))) return; -#endif - __Pyx_PyDict_NextRef(kwds, &pos, &key, NULL); -#if CYTHON_AVOID_BORROWED_REFS - Py_XDECREF(pos); -#endif - } - if (likely(key)) { - PyErr_Format(PyExc_TypeError, - "%s() got an unexpected keyword argument '%U'", - function_name, key); - Py_DECREF(key); - } -} - -/* decode_c_bytes (used by decode_cpp_string) */ -static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes( - const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop, - const char* encoding, const char* errors, - PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { - if (unlikely((start < 0) | (stop < 0))) { - if (start < 0) { - start += length; - if (start < 0) - start = 0; - } - if (stop < 0) - stop += length; - } - if (stop > length) - stop = length; - if (unlikely(stop <= start)) - return __Pyx_NewRef(__pyx_mstate_global->__pyx_empty_unicode); - length = stop - start; - cstring += start; - if (decode_func) { - return decode_func(cstring, length, errors); - } else { - return PyUnicode_Decode(cstring, length, encoding, errors); - } -} - /* RaiseException */ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { PyObject* owned_instance = NULL; @@ -6185,6 +8630,103 @@ bad: return; } +/* KeywordStringCheck */ +static int __Pyx_CheckKeywordStrings( + const char* function_name, + PyObject *kw) +{ +#if CYTHON_COMPILING_IN_PYPY && !defined(PyArg_ValidateKeywordArguments) + CYTHON_UNUSED_VAR(function_name); + CYTHON_UNUSED_VAR(kw); + return 0; +#else + if (CYTHON_METH_FASTCALL && likely(PyTuple_Check(kw))) { +#if PY_VERSION_HEX >= 0x03090000 + CYTHON_UNUSED_VAR(function_name); +#else + Py_ssize_t kwsize; + #if CYTHON_ASSUME_SAFE_SIZE + kwsize = PyTuple_GET_SIZE(kw); + #else + kwsize = PyTuple_Size(kw); + if (unlikely(kwsize < 0)) return -1; + #endif + for (Py_ssize_t pos = 0; pos < kwsize; pos++) { + PyObject* key = NULL; + #if CYTHON_ASSUME_SAFE_MACROS + key = PyTuple_GET_ITEM(kw, pos); + #else + key = PyTuple_GetItem(kw, pos); + if (unlikely(!key)) return -1; + #endif + if (unlikely(!PyUnicode_Check(key))) { + PyErr_Format(PyExc_TypeError, + "%.200s() keywords must be strings", function_name); + return -1; + } + } +#endif + } else { + if (unlikely(!PyArg_ValidateKeywordArguments(kw))) return -1; + } + return 0; +#endif +} + +/* decode_c_bytes (used by decode_cpp_string) */ +static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes( + const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop, + const char* encoding, const char* errors, + PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { + if (unlikely((start < 0) | (stop < 0))) { + if (start < 0) { + start += length; + if (start < 0) + start = 0; + } + if (stop < 0) + stop += length; + } + if (stop > length) + stop = length; + if (unlikely(stop <= start)) + return __Pyx_NewRef(__pyx_mstate_global->__pyx_empty_unicode); + length = stop - start; + cstring += start; + if (decode_func) { + return decode_func(cstring, length, errors); + } else { + return PyUnicode_Decode(cstring, length, encoding, errors); + } +} + +/* RejectKeywords */ +static void __Pyx_RejectKeywords(const char* function_name, PyObject *kwds) { + PyObject *key = NULL; + if (CYTHON_METH_FASTCALL && likely(PyTuple_Check(kwds))) { + key = __Pyx_PySequence_ITEM(kwds, 0); + } else { +#if CYTHON_AVOID_BORROWED_REFS + PyObject *pos = NULL; +#else + Py_ssize_t pos = 0; +#endif +#if !CYTHON_COMPILING_IN_PYPY || defined(PyArg_ValidateKeywordArguments) + if (unlikely(!PyArg_ValidateKeywordArguments(kwds))) return; +#endif + __Pyx_PyDict_NextRef(kwds, &pos, &key, NULL); +#if CYTHON_AVOID_BORROWED_REFS + Py_XDECREF(pos); +#endif + } + if (likely(key)) { + PyErr_Format(PyExc_TypeError, + "%s() got an unexpected keyword argument '%U'", + function_name, key); + Py_DECREF(key); + } +} + /* AllocateExtensionType */ static PyObject *__Pyx_AllocateExtensionType(PyTypeObject *t, int is_final) { if (is_final || likely(!__Pyx_PyType_HasFeature(t, Py_TPFLAGS_IS_ABSTRACT))) { @@ -6657,6 +9199,138 @@ static int __Pyx_PyType_Ready(PyTypeObject *t) { #endif } +/* SetVTable */ +static int __Pyx_SetVtable(PyTypeObject *type, void *vtable) { + PyObject *ob = PyCapsule_New(vtable, 0, 0); + if (unlikely(!ob)) + goto bad; +#if CYTHON_COMPILING_IN_LIMITED_API + if (unlikely(PyObject_SetAttr((PyObject *) type, __pyx_mstate_global->__pyx_n_u_pyx_vtable, ob) < 0)) +#else + if (unlikely(PyDict_SetItem(type->tp_dict, __pyx_mstate_global->__pyx_n_u_pyx_vtable, ob) < 0)) +#endif + goto bad; + Py_DECREF(ob); + return 0; +bad: + Py_XDECREF(ob); + return -1; +} + +/* GetVTable (used by MergeVTables) */ +static void* __Pyx_GetVtable(PyTypeObject *type) { + void* ptr; +#if CYTHON_COMPILING_IN_LIMITED_API + PyObject *ob = PyObject_GetAttr((PyObject *)type, __pyx_mstate_global->__pyx_n_u_pyx_vtable); +#else + PyObject *ob = PyObject_GetItem(type->tp_dict, __pyx_mstate_global->__pyx_n_u_pyx_vtable); +#endif + if (!ob) + goto bad; + ptr = PyCapsule_GetPointer(ob, 0); + if (!ptr && !PyErr_Occurred()) + PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type"); + Py_DECREF(ob); + return ptr; +bad: + Py_XDECREF(ob); + return NULL; +} + +/* MergeVTables */ +static int __Pyx_MergeVtables(PyTypeObject *type) { + int i=0; + Py_ssize_t size; + void** base_vtables; + __Pyx_TypeName tp_base_name = NULL; + __Pyx_TypeName base_name = NULL; + void* unknown = (void*)-1; + PyObject* bases = __Pyx_PyType_GetSlot(type, tp_bases, PyObject*); + int base_depth = 0; + { + PyTypeObject* base = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*); + while (base) { + base_depth += 1; + base = __Pyx_PyType_GetSlot(base, tp_base, PyTypeObject*); + } + } + base_vtables = (void**) PyMem_Malloc(sizeof(void*) * (size_t)(base_depth + 1)); + base_vtables[0] = unknown; +#if CYTHON_COMPILING_IN_LIMITED_API + size = PyTuple_Size(bases); + if (size < 0) goto other_failure; +#else + size = PyTuple_GET_SIZE(bases); +#endif + for (i = 1; i < size; i++) { + PyObject *basei; + void* base_vtable; +#if CYTHON_AVOID_BORROWED_REFS + basei = PySequence_GetItem(bases, i); + if (unlikely(!basei)) goto other_failure; +#elif !CYTHON_ASSUME_SAFE_MACROS + basei = PyTuple_GetItem(bases, i); + if (unlikely(!basei)) goto other_failure; +#else + basei = PyTuple_GET_ITEM(bases, i); +#endif + base_vtable = __Pyx_GetVtable((PyTypeObject*)basei); +#if CYTHON_AVOID_BORROWED_REFS + Py_DECREF(basei); +#endif + if (base_vtable != NULL) { + int j; + PyTypeObject* base = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*); + for (j = 0; j < base_depth; j++) { + if (base_vtables[j] == unknown) { + base_vtables[j] = __Pyx_GetVtable(base); + base_vtables[j + 1] = unknown; + } + if (base_vtables[j] == base_vtable) { + break; + } else if (base_vtables[j] == NULL) { + goto bad; + } + base = __Pyx_PyType_GetSlot(base, tp_base, PyTypeObject*); + } + } + } + PyErr_Clear(); + PyMem_Free(base_vtables); + return 0; +bad: + { + PyTypeObject* basei = NULL; + PyTypeObject* tp_base = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*); + tp_base_name = __Pyx_PyType_GetFullyQualifiedName(tp_base); +#if CYTHON_AVOID_BORROWED_REFS + basei = (PyTypeObject*)PySequence_GetItem(bases, i); + if (unlikely(!basei)) goto really_bad; +#elif !CYTHON_ASSUME_SAFE_MACROS + basei = (PyTypeObject*)PyTuple_GetItem(bases, i); + if (unlikely(!basei)) goto really_bad; +#else + basei = (PyTypeObject*)PyTuple_GET_ITEM(bases, i); +#endif + base_name = __Pyx_PyType_GetFullyQualifiedName(basei); +#if CYTHON_AVOID_BORROWED_REFS + Py_DECREF(basei); +#endif + } + PyErr_Format(PyExc_TypeError, + "multiple bases have vtable conflict: '" __Pyx_FMT_TYPENAME "' and '" __Pyx_FMT_TYPENAME "'", tp_base_name, base_name); +#if CYTHON_AVOID_BORROWED_REFS || !CYTHON_ASSUME_SAFE_MACROS +really_bad: // bad has failed! +#endif + __Pyx_DECREF_TypeName(tp_base_name); + __Pyx_DECREF_TypeName(base_name); +#if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_AVOID_BORROWED_REFS || !CYTHON_ASSUME_SAFE_MACROS +other_failure: +#endif + PyMem_Free(base_vtables); + return -1; +} + /* DelItemOnTypeDict (used by SetupReduce) */ static int __Pyx__DelItemOnTypeDict(PyTypeObject *tp, PyObject *k) { int result; @@ -8865,6 +11539,107 @@ raise_neg_overflow: return (uint64_t) -1; } +/* PyObjectVectorCallKwBuilder (used by CIntToPy) */ +#if CYTHON_VECTORCALL +static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) { + (void)__Pyx_PyObject_FastCallDict; + if (__Pyx_PyTuple_SET_ITEM(builder, n, key) != (0)) return -1; + Py_INCREF(key); + args[n] = value; + return 0; +} +CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) { + (void)__Pyx_VectorcallBuilder_AddArgStr; + if (unlikely(!PyUnicode_Check(key))) { + PyErr_SetString(PyExc_TypeError, "keywords must be strings"); + return -1; + } + return __Pyx_VectorcallBuilder_AddArg(key, value, builder, args, n); +} +static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, PyObject *builder, PyObject **args, int n) { + PyObject *pyKey = PyUnicode_FromString(key); + if (!pyKey) return -1; + return __Pyx_VectorcallBuilder_AddArg(pyKey, value, builder, args, n); +} +#else // CYTHON_VECTORCALL +CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, CYTHON_UNUSED PyObject **args, CYTHON_UNUSED int n) { + if (unlikely(!PyUnicode_Check(key))) { + PyErr_SetString(PyExc_TypeError, "keywords must be strings"); + return -1; + } + return PyDict_SetItem(builder, key, value); +} +#endif + +/* CIntToPy */ +static CYTHON_INLINE PyObject* __Pyx_PyLong_From_uint64_t(uint64_t value) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const uint64_t neg_one = (uint64_t) -1, const_zero = (uint64_t) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(uint64_t) < sizeof(long)) { + return PyLong_FromLong((long) value); + } else if (sizeof(uint64_t) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#if !CYTHON_COMPILING_IN_PYPY + } else if (sizeof(uint64_t) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(uint64_t) <= sizeof(long)) { + return PyLong_FromLong((long) value); + } else if (sizeof(uint64_t) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); + } + } + { + unsigned char *bytes = (unsigned char *)&value; +#if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4 + if (is_unsigned) { + return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1); + } else { + return PyLong_FromNativeBytes(bytes, sizeof(value), -1); + } +#elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000 + int one = 1; int little = (int)*(unsigned char *)&one; + return _PyLong_FromByteArray(bytes, sizeof(uint64_t), + little, !is_unsigned); +#else + int one = 1; int little = (int)*(unsigned char *)&one; + PyObject *from_bytes, *result = NULL, *kwds = NULL; + PyObject *py_bytes = NULL, *order_str = NULL; + from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes"); + if (!from_bytes) return NULL; + py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(uint64_t)); + if (!py_bytes) goto limited_bad; + order_str = PyUnicode_FromString(little ? "little" : "big"); + if (!order_str) goto limited_bad; + { + PyObject *args[3+(CYTHON_VECTORCALL ? 1 : 0)] = { NULL, py_bytes, order_str }; + if (!is_unsigned) { + kwds = __Pyx_MakeVectorcallBuilderKwds(1); + if (!kwds) goto limited_bad; + if (__Pyx_VectorcallBuilder_AddArgStr("signed", __Pyx_NewRef(Py_True), kwds, args+3, 0) < 0) goto limited_bad; + } + result = __Pyx_Object_Vectorcall_CallFromBuilder(from_bytes, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, kwds); + } + limited_bad: + Py_XDECREF(kwds); + Py_XDECREF(order_str); + Py_XDECREF(py_bytes); + Py_XDECREF(from_bytes); + return result; +#endif + } +} + /* FormatTypeName */ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000 static __Pyx_TypeName @@ -8904,38 +11679,6 @@ __Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp) } #endif -/* PyObjectVectorCallKwBuilder (used by CIntToPy) */ -#if CYTHON_VECTORCALL -static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) { - (void)__Pyx_PyObject_FastCallDict; - if (__Pyx_PyTuple_SET_ITEM(builder, n, key) != (0)) return -1; - Py_INCREF(key); - args[n] = value; - return 0; -} -CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) { - (void)__Pyx_VectorcallBuilder_AddArgStr; - if (unlikely(!PyUnicode_Check(key))) { - PyErr_SetString(PyExc_TypeError, "keywords must be strings"); - return -1; - } - return __Pyx_VectorcallBuilder_AddArg(key, value, builder, args, n); -} -static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, PyObject *builder, PyObject **args, int n) { - PyObject *pyKey = PyUnicode_FromString(key); - if (!pyKey) return -1; - return __Pyx_VectorcallBuilder_AddArg(pyKey, value, builder, args, n); -} -#else // CYTHON_VECTORCALL -CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, CYTHON_UNUSED PyObject **args, CYTHON_UNUSED int n) { - if (unlikely(!PyUnicode_Check(key))) { - PyErr_SetString(PyExc_TypeError, "keywords must be strings"); - return -1; - } - return PyDict_SetItem(builder, key, value); -} -#endif - /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC diff --git a/src/polluck_blockchain/placeholder_native.pyx b/src/polluck_blockchain/placeholder_native.pyx index 4065c8b..d95a402 100644 --- a/src/polluck_blockchain/placeholder_native.pyx +++ b/src/polluck_blockchain/placeholder_native.pyx @@ -16,118 +16,54 @@ import dopt_basics.datetime from polluck_blockchain.block cimport Block from libcpp.unordered_map cimport unordered_map from libcpp.string cimport string +from libc.stdint cimport uint64_t ctypedef unsigned long ULong - -# cdef struct PyStringC: -# char* ptr -# Py_ssize_t length - - -# cdef PyStringC_to_unicode(PyStringC string): -# return string.ptr[: string.length].decode("UTF-8", "strict") - - -# cdef PyStringC_to_bytes(PyStringC string): -# return string.ptr[: string.length] - - +ctypedef unordered_map[uint64_t, Block*] BcHashmap cdef timestamp_to_datetime(double ts): return datetime.datetime.fromtimestamp(ts, dopt_basics.datetime.TIMEZONE_UTC) -# cdef class StringHolder: -# cdef readonly PyStringC c -# cdef object _py_data - -# def __cinit__(self, data: str): -# """accepting Python str - -# Parameters -# ---------- -# data : str -# _description_ -# """ -# if not isinstance(data, str): -# raise TypeError("Data not 'str'") - -# self._py_data = data.encode("UTF-8") -# self.c = PyStringC(self._py_data, len(self._py_data)) - -# @property -# def py_string(self): -# return PyStringC_to_unicode(self.c) - -# @property -# def py_bytes(self): -# return PyStringC_to_bytes(self.c) - - -# BlockC = cython.struct( -# index=cython.ulonglong, -# timestamp=cython.double, -# data=PyStringC, -# previous_hash=PyStringC, -# nonce=cython.ulonglong, -# ) - - cdef float_to_bytes(double num): return struct.pack(">d", num) -# cdef struct BlockC: -# ULong _index -# double _timestamp -# string _data -# string _prev_hash -# ULong _nonce -# string _hash - -cdef class BlockPy: +cdef class PyBlock: cdef: - ULong _index - double _timestamp - string _data - string _prev_hash - ULong _nonce - string _hash - Block* Block + # ULong _index + # double _timestamp + # string _data + # string _prev_hash + # ULong _nonce + # string _hash + Block *BlockC + bint ptr_owner def __cinit__(self, - index: int, - data: str, - previous_hash: str, - nonce: int, + index, + nonce, + data, + previous_hash, + from_ptr=False, ): - self.Block = new Block( - index, - datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp(), - nonce, - data.encode("UTF-8"), - previous_hash.encode("UTF-8"), - "".encode("UTF-8"), - ) + self.ptr_owner = False + if not from_ptr: + self.BlockC = new Block( + index, + datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp(), + nonce, + data.encode("UTF-8"), + previous_hash.encode("UTF-8"), + "".encode("UTF-8"), + ) + if self.BlockC == NULL: + raise MemoryError("Allocation of block object failed") - def get_data(self): - return self.Block.data.decode("UTF-8") + self.ptr_owner = True - # def __init__( - # self, - # index: int, - # data: str, - # previous_hash: str, - # nonce: int, - # ): - # self.C = new BlockC( - # index, - # datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp(), - # data.encode("UTF-8"), - # previous_hash.encode("UTF-8"), - # nonce, - # "".encode("UTF-8"), - # ) + def __init__(self, *args, **kwargs): + pass # self._index = index # # self._timestamp = dopt_basics.datetime.current_time_tz().timestamp() # self._timestamp = datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp() @@ -135,6 +71,26 @@ cdef class BlockPy: # self._prev_hash = previous_hash.encode("UTF-8") # self._nonce = nonce # self._hash = "".encode("UTF-8") + + def __dealloc__(self): + if self.BlockC is not NULL and self.ptr_owner is True: + del self.BlockC + self.BlockC = NULL + + @staticmethod + cdef PyBlock from_ptr(Block *block, bint owner=False): + cdef PyBlock py_block = PyBlock.__new__( + PyBlock, + block.index, + block.nonce, + block.data, + block.prev_hash, + True, + ) + py_block.BlockC = block + py_block.ptr_owner = owner + + return py_block # cpdef _perform_hash(self): # parts = bytearray() @@ -152,51 +108,124 @@ cdef class BlockPy: # def compute_hash(self): # return self._perform_hash().hexdigest() - # # Python public API - # @property - # def index(self): - # return self._index + # Python public API + @property + def index(self): + return self.BlockC.index - # @property - # def timestamp(self): - # return timestamp_to_datetime(self._timestamp) + @property + def timestamp(self): + return timestamp_to_datetime(self.BlockC.timestamp) - # @property - # def data(self): - # return self._data.decode("UTF-8") + @property + def data(self): + return self.BlockC.data.decode("UTF-8") - # @property - # def prev_hash(self): - # return self._prev_hash.decode("UTF-8") + @property + def prev_hash(self): + return self.BlockC.prev_hash.decode("UTF-8") - # @property - # def nonce(self): - # return self._nonce + @property + def nonce(self): + return self.BlockC.nonce # @nonce.setter # def nonce(self, value: int): # self._nonce = value - # @property - # def hash(self): - # return self._hash.decode("UTF-8") + @property + def hash(self): + return self.BlockC.hash.decode("UTF-8") # @hash.setter - # def hash(self, value: str): + # def hash(self, value): # if not isinstance(value, str): # raise TypeError("No string") # self._hash = value.encode("UTF-8") +# cdef void add_block(BcHashmap *map, Block *block): +# map[block.index] = block -# cdef class Blockchain: -# cdef int _difficulty -# cdef size_t _index -# cdef unordered_map[size_t, int] _chain -# def __cinit__(self): -# self._difficulty = 1 -# self._index = 0 -# # self._chain = new unordered_map[size_t, Block]() +cdef class Blockchain: + cdef int _difficulty + cdef uint64_t _index + cdef BcHashmap *_chain + cdef bint _genesis_done + + def __cinit__(self): + self._difficulty = 1 + self._index = 0 + self._genesis_done = 0 + self._chain = new unordered_map[uint64_t, Block*]() + if self._chain is NULL: + raise MemoryError("Could not allocate hasmap") + + def __init__(self, *args, **kwargs): + pass + + def __dealloc__(self): + if self._chain is not NULL: + del self._chain + self._chain = NULL + + def __len__(self): + return self._index + 1 + + @property + def genesis_done(self): + return self._genesis_done + + @property + def index(self): + return self._index + + # TODO error handling + cdef Block* get_block_c(self, uint64_t idx): + return self._chain[0][idx] + + def get_block(self, idx): + if idx < 0 or idx > self._index: + raise IndexError("Index value is out of bounds") + + cdef Block *block = self.get_block_c(idx) + return PyBlock.from_ptr(block, owner=False) + + cdef void add_block(self, Block *block): + self._chain[0][block.index] = block + if self._genesis_done: + self._index += 1 + + def create_genesis_block(self): + cdef Block *block = new Block( + self._index, + datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp(), + 0, + "Genesis Block".encode("UTF-8"), + "0".encode("UTF-8"), + "".encode("UTF-8"), + ) + block.hash = "dummy hash".encode("UTF-8") + self.add_block(block) + self._genesis_done = 1 + + def new_block(self, data): + if not self._genesis_done: + raise RuntimeError("Create a genesis block first.") + + cdef Block *prev_block = self.get_block_c(self._index) + cdef string prev_hash = prev_block.prev_hash + cdef uint64_t new_idx = self._index + 1 + + cdef Block *block = new Block( + new_idx, + datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp(), + 0, + data.encode("UTF-8"), + prev_hash, + "".encode("UTF-8"), + ) + self.add_block(block) # def __init__( # self,