diff --git a/setup.py b/setup.py index 2d17f78..3770cec 100644 --- a/setup.py +++ b/setup.py @@ -60,8 +60,8 @@ linker_args: list[str] = [] if sys.platform.startswith("win") and not DEBUG: - c_args = ("/O2", "/GL", "/Gy") - l_args = ("/LTCG", "/OPT:REF", "/OPT:ICF") + c_args = ("/O2", "/GL", "/Gy", "/openmp:llvm") + l_args = ("/LTCG", "/OPT:REF", "/OPT:ICF", "/openmp:llvm") else: c_args = tuple() l_args = tuple() diff --git a/src/polluck_blockchain/openssl_evp.pxd b/src/polluck_blockchain/openssl_evp.pxd index ca4016c..417d1b8 100644 --- a/src/polluck_blockchain/openssl_evp.pxd +++ b/src/polluck_blockchain/openssl_evp.pxd @@ -4,12 +4,11 @@ cdef extern from "openssl/evp.h": pass ctypedef struct EVP_MD: pass - EVP_MD_CTX *EVP_MD_CTX_new() - void EVP_MD_CTX_free(EVP_MD_CTX *) - const EVP_MD *EVP_sha256() - int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, void *impl) - int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, size_t cnt) - int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, - unsigned int *s) - int EVP_MD_size(const EVP_MD *md) - int EVP_MD_CTX_reset(EVP_MD_CTX *ctx) + EVP_MD_CTX *EVP_MD_CTX_new() nogil + void EVP_MD_CTX_free(EVP_MD_CTX *) nogil + const EVP_MD *EVP_sha256() nogil + int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, void *impl) nogil + int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, size_t cnt) nogil + int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s) nogil + int EVP_MD_size(const EVP_MD *md) nogil + int EVP_MD_CTX_reset(EVP_MD_CTX *ctx) nogil diff --git a/src/polluck_blockchain/placeholder_native.cpp b/src/polluck_blockchain/placeholder_native.cpp index 6e0e66c..f3e51b3 100644 --- a/src/polluck_blockchain/placeholder_native.cpp +++ b/src/polluck_blockchain/placeholder_native.cpp @@ -1568,12 +1568,24 @@ static const char* const __pyx_f[] = { #define __Pyx_END_CRITICAL_SECTION Py_END_CRITICAL_SECTION #endif +/* ForceInitThreads.proto */ +#ifndef __PYX_FORCE_INIT_THREADS + #define __PYX_FORCE_INIT_THREADS 0 +#endif + +/* NoFastGil.proto */ +#define __Pyx_PyGILState_Ensure PyGILState_Ensure +#define __Pyx_PyGILState_Release PyGILState_Release +#define __Pyx_FastGIL_Remember() +#define __Pyx_FastGIL_Forget() +#define __Pyx_FastGilFuncInit() + /* IncludeStructmemberH.proto (used by FixUpExtensionType) */ #include /* #### Code section: numeric_typedefs ### */ -/* "polluck_blockchain/placeholder_native.pyx":26 +/* "polluck_blockchain/placeholder_native.pyx":27 * * * ctypedef unsigned long ULong # <<<<<<<<<<<<<< @@ -1588,8 +1600,9 @@ typedef unsigned long __pyx_t_18polluck_blockchain_18placeholder_native_ULong; 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; +struct __pyx_opt_args_18polluck_blockchain_18placeholder_native_7PyBlock_mine; -/* "polluck_blockchain/placeholder_native.pyx":27 +/* "polluck_blockchain/placeholder_native.pyx":28 * * ctypedef unsigned long ULong * ctypedef unordered_map[uint64_t, Block*] BcHashmap # <<<<<<<<<<<<<< @@ -1598,7 +1611,7 @@ struct __pyx_opt_args_18polluck_blockchain_18placeholder_native_7PyBlock_from_pt */ typedef std::unordered_map __pyx_t_18polluck_blockchain_18placeholder_native_BcHashmap; -/* "polluck_blockchain/placeholder_native.pyx":102 +/* "polluck_blockchain/placeholder_native.pyx":124 * * @staticmethod * cdef PyBlock from_ptr(Block *block, bint owner=False): # <<<<<<<<<<<<<< @@ -1610,12 +1623,24 @@ struct __pyx_opt_args_18polluck_blockchain_18placeholder_native_7PyBlock_from_pt int owner; }; -/* "polluck_blockchain/placeholder_native.pyx":60 - * # size_t size +/* "polluck_blockchain/placeholder_native.pyx":264 + * free(serialize_res) + * + * cpdef mine(self, unsigned int difficulty, unsigned int max_nonce=0xFFFFFFFF): # <<<<<<<<<<<<<< + * cdef: + * unsigned char *serial_buf +*/ +struct __pyx_opt_args_18polluck_blockchain_18placeholder_native_7PyBlock_mine { + int __pyx_n; + unsigned int max_nonce; +}; + +/* "polluck_blockchain/placeholder_native.pyx":88 + * * * cdef class PyBlock: # <<<<<<<<<<<<<< * cdef: - * # ULong _index + * Block *BlockC */ struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock { PyObject_HEAD @@ -1625,7 +1650,7 @@ struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock { }; -/* "polluck_blockchain/placeholder_native.pyx":279 +/* "polluck_blockchain/placeholder_native.pyx":355 * * * cdef class Blockchain: # <<<<<<<<<<<<<< @@ -1643,25 +1668,26 @@ struct __pyx_obj_18polluck_blockchain_18placeholder_native_Blockchain { -/* "polluck_blockchain/placeholder_native.pyx":60 - * # size_t size +/* "polluck_blockchain/placeholder_native.pyx":88 + * * * cdef class PyBlock: # <<<<<<<<<<<<<< * cdef: - * # ULong _index + * Block *BlockC */ 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); unsigned char *(*bytes_serialize_c)(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *, size_t *); unsigned char *(*digest)(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *, unsigned char *, size_t, size_t *); + PyObject *(*mine)(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *, unsigned int, int __pyx_skip_dispatch, struct __pyx_opt_args_18polluck_blockchain_18placeholder_native_7PyBlock_mine *__pyx_optional_args); unsigned char *(*perform_hash_c)(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *, size_t *); PyObject *(*perform_hash)(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *, int __pyx_skip_dispatch); }; static struct __pyx_vtabstruct_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_vtabptr_18polluck_blockchain_18placeholder_native_PyBlock; -/* "polluck_blockchain/placeholder_native.pyx":279 +/* "polluck_blockchain/placeholder_native.pyx":355 * * * cdef class Blockchain: # <<<<<<<<<<<<<< @@ -1884,6 +1910,12 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObj static PyObject *__Pyx_PyObject_FastCallMethod(PyObject *name, PyObject *const *args, size_t nargsf); #endif +/* DivInt[long].proto */ +static CYTHON_INLINE long __Pyx_div_long(long, long, int b_is_constant); + +/* ModInt[long].proto */ +static CYTHON_INLINE long __Pyx_mod_long(long, long, int b_is_constant); + /* TupleAndListFromArray.proto (used by fastcall) */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n); @@ -2152,6 +2184,25 @@ static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) #endif +/* IncludeStdlibH.proto */ +#include + +/* ErrOccurredWithGIL.proto */ +static CYTHON_INLINE int __Pyx_ErrOccurredWithGIL(void); + +/* SharedInFreeThreading.proto */ +#if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING +#define __Pyx_shared_in_cpython_freethreading(x) shared(x) +#else +#define __Pyx_shared_in_cpython_freethreading(x) +#endif + +/* PyRuntimeError_Check.proto */ +#define __Pyx_PyExc_RuntimeError_Check(obj) __Pyx_TypeCheck(obj, PyExc_RuntimeError) + +/* RaiseException.export */ +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); + /* MoveIfSupported.proto */ #if CYTHON_USE_CPP_STD_MOVE #include @@ -2163,18 +2214,12 @@ static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject /* 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); - /* PyMemoryError_Check.proto */ #define __Pyx_PyExc_MemoryError_Check(obj) __Pyx_TypeCheck(obj, PyExc_MemoryError) /* 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) - /* AllocateExtensionType.proto */ static PyObject *__Pyx_AllocateExtensionType(PyTypeObject *t, int is_final); @@ -2451,6 +2496,9 @@ static void __Pyx_CppExn2PyErr() { } #endif +/* CIntFromPy.proto */ +static CYTHON_INLINE unsigned int __Pyx_PyLong_As_unsigned_int(PyObject *); + /* 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 @@ -2472,9 +2520,18 @@ static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, P /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_uint64_t(uint64_t value); +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyLong_From_int(int value); + +/* CIntFromPy.proto */ +static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *); + /* CIntFromPy.proto */ static CYTHON_INLINE uint64_t __Pyx_PyLong_As_uint64_t(PyObject *); +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyLong_From_unsigned_int(unsigned int value); + /* FormatTypeName.proto */ #if CYTHON_COMPILING_IN_LIMITED_API typedef PyObject *__Pyx_TypeName; @@ -2498,9 +2555,6 @@ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value); /* CIntFromPy.proto */ static CYTHON_INLINE long __Pyx_PyLong_As_long(PyObject *); -/* CIntFromPy.proto */ -static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *); - /* FastTypeChecks.proto */ #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) @@ -2590,6 +2644,7 @@ static int __Pyx_State_RemoveModule(void*); 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 unsigned char *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_bytes_serialize_c(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self, size_t *__pyx_v_size); /* proto*/ static unsigned char *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_digest(CYTHON_UNUSED struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self, unsigned char *__pyx_v_data, size_t __pyx_v_data_size, size_t *__pyx_v_digest_size); /* proto*/ +static PyObject *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_mine(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self, unsigned int __pyx_v_difficulty, int __pyx_skip_dispatch, struct __pyx_opt_args_18polluck_blockchain_18placeholder_native_7PyBlock_mine *__pyx_optional_args); /* proto*/ static unsigned char *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_perform_hash_c(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self, size_t *__pyx_v_digest_size); /* proto*/ static PyObject *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_perform_hash(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self, int __pyx_skip_dispatch); /* 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*/ @@ -2618,8 +2673,10 @@ static void __pyx_f_18polluck_blockchain_18placeholder_native_10Blockchain_add_b /* Module declarations from "polluck_blockchain.openssl_evp" */ /* Module declarations from "polluck_blockchain.placeholder_native" */ +static size_t const __pyx_v_18polluck_blockchain_18placeholder_native_NONCE_OFFSET = ((size_t)16); static PyObject *__pyx_f_18polluck_blockchain_18placeholder_native_timestamp_to_datetime(uint64_t); /*proto*/ static int __pyx_f_18polluck_blockchain_18placeholder_native_serialize_uint64(unsigned char *, unsigned PY_LONG_LONG); /*proto*/ +static CYTHON_INLINE int __pyx_f_18polluck_blockchain_18placeholder_native_has_leading_zero_bits(unsigned char const *, int); /*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*/ @@ -2648,9 +2705,10 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_9pr 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_10bytes_serialize(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_12perform_hash(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_14__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_16__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_12mine(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self, unsigned int __pyx_v_difficulty, unsigned int __pyx_v_max_nonce); /* proto */ +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_14perform_hash(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_16__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_18__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 */ @@ -2692,10 +2750,10 @@ typedef struct { __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[10]; - PyObject *__pyx_string_tab[96]; - PyObject *__pyx_number_tab[4]; + PyObject *__pyx_tuple[2]; + PyObject *__pyx_codeobj_tab[11]; + PyObject *__pyx_string_tab[102]; + PyObject *__pyx_number_tab[5]; /* #### Code section: module_state_contents ### */ /* CommonTypesMetaclass.module_state_decls */ PyTypeObject *__pyx_CommonTypesMetaclassType; @@ -2739,103 +2797,110 @@ static __pyx_mstatetype * const __pyx_mstate_global = &__pyx_mstate_global_stati #define __pyx_kp_u_Could_not_allocate_hasmap __pyx_string_tab[0] #define __pyx_kp_u_Create_a_genesis_block_first __pyx_string_tab[1] #define __pyx_kp_u_Index_value_is_out_of_bounds __pyx_string_tab[2] -#define __pyx_kp_u_PyBlock __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__3 __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_Blockchain_print_key_value_pair __pyx_string_tab[20] -#define __pyx_n_u_PyBlock_2 __pyx_string_tab[21] -#define __pyx_n_u_PyBlock___reduce_cython __pyx_string_tab[22] -#define __pyx_n_u_PyBlock___setstate_cython __pyx_string_tab[23] -#define __pyx_n_u_PyBlock_bytes_serialize __pyx_string_tab[24] -#define __pyx_n_u_PyBlock_perform_hash __pyx_string_tab[25] -#define __pyx_n_u_Pyx_PyDict_NextRef __pyx_string_tab[26] -#define __pyx_n_u_TIMEZONE_UTC __pyx_string_tab[27] -#define __pyx_n_u_asyncio_coroutines __pyx_string_tab[28] -#define __pyx_n_u_block __pyx_string_tab[29] -#define __pyx_n_u_bytes_serialize __pyx_string_tab[30] -#define __pyx_n_u_cline_in_traceback __pyx_string_tab[31] -#define __pyx_n_u_create_genesis_block __pyx_string_tab[32] -#define __pyx_n_u_data __pyx_string_tab[33] -#define __pyx_n_u_datetime __pyx_string_tab[34] -#define __pyx_n_u_dopt_basics __pyx_string_tab[35] -#define __pyx_n_u_dopt_basics_datetime __pyx_string_tab[36] -#define __pyx_n_u_encode __pyx_string_tab[37] -#define __pyx_n_u_from_ptr __pyx_string_tab[38] -#define __pyx_n_u_fromtimestamp __pyx_string_tab[39] -#define __pyx_n_u_func __pyx_string_tab[40] -#define __pyx_n_u_get_block __pyx_string_tab[41] -#define __pyx_n_u_getstate __pyx_string_tab[42] -#define __pyx_n_u_hash __pyx_string_tab[43] -#define __pyx_n_u_hashlib __pyx_string_tab[44] -#define __pyx_n_u_hex __pyx_string_tab[45] -#define __pyx_n_u_idx __pyx_string_tab[46] -#define __pyx_n_u_index __pyx_string_tab[47] -#define __pyx_n_u_is_coroutine __pyx_string_tab[48] -#define __pyx_n_u_it __pyx_string_tab[49] -#define __pyx_n_u_items __pyx_string_tab[50] -#define __pyx_n_u_main __pyx_string_tab[51] -#define __pyx_n_u_module __pyx_string_tab[52] -#define __pyx_n_u_name __pyx_string_tab[53] -#define __pyx_n_u_new_block __pyx_string_tab[54] -#define __pyx_n_u_new_idx __pyx_string_tab[55] -#define __pyx_n_u_nonce __pyx_string_tab[56] -#define __pyx_n_u_perform_hash __pyx_string_tab[57] -#define __pyx_n_u_polluck_blockchain_placeholder_n __pyx_string_tab[58] -#define __pyx_n_u_pop __pyx_string_tab[59] -#define __pyx_n_u_prev_block __pyx_string_tab[60] -#define __pyx_n_u_prev_hash __pyx_string_tab[61] -#define __pyx_n_u_previous_hash __pyx_string_tab[62] -#define __pyx_n_u_print __pyx_string_tab[63] -#define __pyx_n_u_print_key_value_pair __pyx_string_tab[64] -#define __pyx_n_u_py_block __pyx_string_tab[65] -#define __pyx_n_u_pyx_state __pyx_string_tab[66] -#define __pyx_n_u_pyx_vtable __pyx_string_tab[67] -#define __pyx_n_u_qualname __pyx_string_tab[68] -#define __pyx_n_u_reduce __pyx_string_tab[69] -#define __pyx_n_u_reduce_cython __pyx_string_tab[70] -#define __pyx_n_u_reduce_ex __pyx_string_tab[71] -#define __pyx_n_u_repr __pyx_string_tab[72] -#define __pyx_n_u_self __pyx_string_tab[73] -#define __pyx_n_u_serialize_res __pyx_string_tab[74] -#define __pyx_n_u_serialize_size __pyx_string_tab[75] -#define __pyx_n_u_set_name __pyx_string_tab[76] -#define __pyx_n_u_setdefault __pyx_string_tab[77] -#define __pyx_n_u_setstate __pyx_string_tab[78] -#define __pyx_n_u_setstate_cython __pyx_string_tab[79] -#define __pyx_n_u_struct __pyx_string_tab[80] -#define __pyx_n_u_test __pyx_string_tab[81] -#define __pyx_n_u_time __pyx_string_tab[82] -#define __pyx_n_u_timestamp __pyx_string_tab[83] -#define __pyx_n_u_values __pyx_string_tab[84] -#define __pyx_kp_b_ __pyx_string_tab[85] -#define __pyx_kp_b_0 __pyx_string_tab[86] -#define __pyx_kp_b_Genesis_Block __pyx_string_tab[87] -#define __pyx_kp_b_dummy_hash __pyx_string_tab[88] -#define __pyx_kp_b_iso88591_A_4r_3d_D_AQ_D_AQ_iq_Q __pyx_string_tab[89] -#define __pyx_kp_b_iso88591_A_4t1_aq_a_HBa_IQ_q_Ct3b_q_gQa_J __pyx_string_tab[90] -#define __pyx_kp_b_iso88591_A_D_2_1A __pyx_string_tab[91] -#define __pyx_kp_b_iso88591_A_IQ_q_Ct3b_7_1_waq_gQa_X_Jaq_Q __pyx_string_tab[92] -#define __pyx_kp_b_iso88591_A_T_a_c_D_t1_c_L_1_iq __pyx_string_tab[93] -#define __pyx_kp_b_iso88591_A_T_xuAV2_b_q_t1 __pyx_string_tab[94] -#define __pyx_kp_b_iso88591_Q __pyx_string_tab[95] +#define __pyx_kp_u_No_valid_nonce_found __pyx_string_tab[3] +#define __pyx_kp_u_PyBlock __pyx_string_tab[4] +#define __pyx_kp_u_UTF_8 __pyx_string_tab[5] +#define __pyx_kp_u__2 __pyx_string_tab[6] +#define __pyx_kp_u__3 __pyx_string_tab[7] +#define __pyx_kp_u_disable __pyx_string_tab[8] +#define __pyx_kp_u_enable __pyx_string_tab[9] +#define __pyx_kp_u_gc __pyx_string_tab[10] +#define __pyx_kp_u_isenabled __pyx_string_tab[11] +#define __pyx_kp_u_no_default___reduce___due_to_non __pyx_string_tab[12] +#define __pyx_kp_u_src_polluck_blockchain_placehold __pyx_string_tab[13] +#define __pyx_kp_u_stringsource __pyx_string_tab[14] +#define __pyx_n_u_Blockchain __pyx_string_tab[15] +#define __pyx_n_u_Blockchain___reduce_cython __pyx_string_tab[16] +#define __pyx_n_u_Blockchain___setstate_cython __pyx_string_tab[17] +#define __pyx_n_u_Blockchain_create_genesis_block __pyx_string_tab[18] +#define __pyx_n_u_Blockchain_get_block __pyx_string_tab[19] +#define __pyx_n_u_Blockchain_new_block __pyx_string_tab[20] +#define __pyx_n_u_Blockchain_print_key_value_pair __pyx_string_tab[21] +#define __pyx_n_u_PyBlock_2 __pyx_string_tab[22] +#define __pyx_n_u_PyBlock___reduce_cython __pyx_string_tab[23] +#define __pyx_n_u_PyBlock___setstate_cython __pyx_string_tab[24] +#define __pyx_n_u_PyBlock_bytes_serialize __pyx_string_tab[25] +#define __pyx_n_u_PyBlock_mine __pyx_string_tab[26] +#define __pyx_n_u_PyBlock_perform_hash __pyx_string_tab[27] +#define __pyx_n_u_Pyx_PyDict_NextRef __pyx_string_tab[28] +#define __pyx_n_u_TIMEZONE_UTC __pyx_string_tab[29] +#define __pyx_n_u_asyncio_coroutines __pyx_string_tab[30] +#define __pyx_n_u_block __pyx_string_tab[31] +#define __pyx_n_u_bytes_serialize __pyx_string_tab[32] +#define __pyx_n_u_cline_in_traceback __pyx_string_tab[33] +#define __pyx_n_u_create_genesis_block __pyx_string_tab[34] +#define __pyx_n_u_data __pyx_string_tab[35] +#define __pyx_n_u_datetime __pyx_string_tab[36] +#define __pyx_n_u_difficulty __pyx_string_tab[37] +#define __pyx_n_u_dopt_basics __pyx_string_tab[38] +#define __pyx_n_u_dopt_basics_datetime __pyx_string_tab[39] +#define __pyx_n_u_encode __pyx_string_tab[40] +#define __pyx_n_u_from_ptr __pyx_string_tab[41] +#define __pyx_n_u_fromtimestamp __pyx_string_tab[42] +#define __pyx_n_u_func __pyx_string_tab[43] +#define __pyx_n_u_get_block __pyx_string_tab[44] +#define __pyx_n_u_getstate __pyx_string_tab[45] +#define __pyx_n_u_hash __pyx_string_tab[46] +#define __pyx_n_u_hashlib __pyx_string_tab[47] +#define __pyx_n_u_hex __pyx_string_tab[48] +#define __pyx_n_u_idx __pyx_string_tab[49] +#define __pyx_n_u_index __pyx_string_tab[50] +#define __pyx_n_u_is_coroutine __pyx_string_tab[51] +#define __pyx_n_u_it __pyx_string_tab[52] +#define __pyx_n_u_items __pyx_string_tab[53] +#define __pyx_n_u_main __pyx_string_tab[54] +#define __pyx_n_u_max_nonce __pyx_string_tab[55] +#define __pyx_n_u_mine __pyx_string_tab[56] +#define __pyx_n_u_module __pyx_string_tab[57] +#define __pyx_n_u_name __pyx_string_tab[58] +#define __pyx_n_u_new_block __pyx_string_tab[59] +#define __pyx_n_u_new_idx __pyx_string_tab[60] +#define __pyx_n_u_nonce __pyx_string_tab[61] +#define __pyx_n_u_perform_hash __pyx_string_tab[62] +#define __pyx_n_u_polluck_blockchain_placeholder_n __pyx_string_tab[63] +#define __pyx_n_u_pop __pyx_string_tab[64] +#define __pyx_n_u_prev_block __pyx_string_tab[65] +#define __pyx_n_u_prev_hash __pyx_string_tab[66] +#define __pyx_n_u_previous_hash __pyx_string_tab[67] +#define __pyx_n_u_print __pyx_string_tab[68] +#define __pyx_n_u_print_key_value_pair __pyx_string_tab[69] +#define __pyx_n_u_py_block __pyx_string_tab[70] +#define __pyx_n_u_pyx_state __pyx_string_tab[71] +#define __pyx_n_u_pyx_vtable __pyx_string_tab[72] +#define __pyx_n_u_qualname __pyx_string_tab[73] +#define __pyx_n_u_reduce __pyx_string_tab[74] +#define __pyx_n_u_reduce_cython __pyx_string_tab[75] +#define __pyx_n_u_reduce_ex __pyx_string_tab[76] +#define __pyx_n_u_repr __pyx_string_tab[77] +#define __pyx_n_u_self __pyx_string_tab[78] +#define __pyx_n_u_serialize_res __pyx_string_tab[79] +#define __pyx_n_u_serialize_size __pyx_string_tab[80] +#define __pyx_n_u_set_name __pyx_string_tab[81] +#define __pyx_n_u_setdefault __pyx_string_tab[82] +#define __pyx_n_u_setstate __pyx_string_tab[83] +#define __pyx_n_u_setstate_cython __pyx_string_tab[84] +#define __pyx_n_u_struct __pyx_string_tab[85] +#define __pyx_n_u_test __pyx_string_tab[86] +#define __pyx_n_u_time __pyx_string_tab[87] +#define __pyx_n_u_timestamp __pyx_string_tab[88] +#define __pyx_n_u_values __pyx_string_tab[89] +#define __pyx_kp_b_ __pyx_string_tab[90] +#define __pyx_kp_b_0 __pyx_string_tab[91] +#define __pyx_kp_b_Genesis_Block __pyx_string_tab[92] +#define __pyx_kp_b_dummy_hash __pyx_string_tab[93] +#define __pyx_kp_b_iso88591_A_4r_3d_D_AQ_D_AQ_iq_Q __pyx_string_tab[94] +#define __pyx_kp_b_iso88591_A_4t1_aq_a_HBa_IQ_q_Ct3b_q_gQa_J __pyx_string_tab[95] +#define __pyx_kp_b_iso88591_A_D_2_1A __pyx_string_tab[96] +#define __pyx_kp_b_iso88591_A_IQ_q_Ct3b_7_1_waq_gQa_X_Jaq_Q __pyx_string_tab[97] +#define __pyx_kp_b_iso88591_A_T_a_c_D_t1_c_L_1_iq __pyx_string_tab[98] +#define __pyx_kp_b_iso88591_A_T_wc_xuAV2_b_q_t1 __pyx_string_tab[99] +#define __pyx_kp_b_iso88591_EQ_q_1_AQ_T_1AQ_1_RRS_AQ_A_T_Qa __pyx_string_tab[100] +#define __pyx_kp_b_iso88591_Q __pyx_string_tab[101] #define __pyx_int_0 __pyx_number_tab[0] #define __pyx_int_1 __pyx_number_tab[1] #define __pyx_int_12 __pyx_number_tab[2] #define __pyx_int_2025 __pyx_number_tab[3] +#define __pyx_int_4294967295 __pyx_number_tab[4] /* #### Code section: module_state_clear ### */ #if CYTHON_USE_MODULE_STATE static CYTHON_SMALL_CODE int __pyx_m_clear(PyObject *m) { @@ -2854,10 +2919,10 @@ static CYTHON_SMALL_CODE int __pyx_m_clear(PyObject *m) { 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<10; ++i) { Py_CLEAR(clear_module_state->__pyx_codeobj_tab[i]); } - for (int i=0; i<96; ++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]); } + for (int i=0; i<2; ++i) { Py_CLEAR(clear_module_state->__pyx_tuple[i]); } + for (int i=0; i<11; ++i) { Py_CLEAR(clear_module_state->__pyx_codeobj_tab[i]); } + for (int i=0; i<102; ++i) { Py_CLEAR(clear_module_state->__pyx_string_tab[i]); } + for (int i=0; i<5; ++i) { Py_CLEAR(clear_module_state->__pyx_number_tab[i]); } /* #### Code section: module_state_clear_contents ### */ /* CommonTypesMetaclass.module_state_clear */ Py_CLEAR(clear_module_state->__pyx_CommonTypesMetaclassType); @@ -2884,10 +2949,10 @@ static CYTHON_SMALL_CODE int __pyx_m_traverse(PyObject *m, visitproc visit, void 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<10; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_codeobj_tab[i]); } - for (int i=0; i<96; ++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]); } + for (int i=0; i<2; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_tuple[i]); } + for (int i=0; i<11; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_codeobj_tab[i]); } + for (int i=0; i<102; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_string_tab[i]); } + for (int i=0; i<5; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_number_tab[i]); } /* #### Code section: module_state_traverse_contents ### */ /* CommonTypesMetaclass.module_state_traverse */ Py_VISIT(traverse_module_state->__pyx_CommonTypesMetaclassType); @@ -3282,7 +3347,7 @@ static CYTHON_INLINE PyObject *__pyx_convert_PyByteArray_string_to_py_6libcpp_6s return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":29 +/* "polluck_blockchain/placeholder_native.pyx":30 * ctypedef unordered_map[uint64_t, Block*] BcHashmap * * cdef timestamp_to_datetime(uint64_t ts): # <<<<<<<<<<<<<< @@ -3305,7 +3370,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":30 + /* "polluck_blockchain/placeholder_native.pyx":31 * * cdef timestamp_to_datetime(uint64_t ts): * return datetime.datetime.fromtimestamp(float(ts), dopt_basics.datetime.TIMEZONE_UTC) # <<<<<<<<<<<<<< @@ -3313,21 +3378,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, 30, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 31, __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, 30, __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, 31, __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(((double)__pyx_v_ts)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 30, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble(((double)__pyx_v_ts)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 31, __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, 30, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_dopt_basics); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 31, __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, 30, __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, 31, __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, 30, __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, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_7 = 0; @@ -3338,14 +3403,14 @@ 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, 30, __pyx_L1_error) + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __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":29 + /* "polluck_blockchain/placeholder_native.pyx":30 * ctypedef unordered_map[uint64_t, Block*] BcHashmap * * cdef timestamp_to_datetime(uint64_t ts): # <<<<<<<<<<<<<< @@ -3369,7 +3434,7 @@ static PyObject *__pyx_f_18polluck_blockchain_18placeholder_native_timestamp_to_ return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":36 +/* "polluck_blockchain/placeholder_native.pyx":37 * # return struct.pack(">d", num) * * cdef int serialize_uint32(unsigned char* out, unsigned int v) except -1 nogil: # <<<<<<<<<<<<<< @@ -3380,7 +3445,7 @@ static PyObject *__pyx_f_18polluck_blockchain_18placeholder_native_timestamp_to_ static int __pyx_f_18polluck_blockchain_18placeholder_native_serialize_uint32(unsigned char *__pyx_v_out, unsigned int __pyx_v_v) { int __pyx_r; - /* "polluck_blockchain/placeholder_native.pyx":37 + /* "polluck_blockchain/placeholder_native.pyx":38 * * cdef int serialize_uint32(unsigned char* out, unsigned int v) except -1 nogil: * out[0] = (v >> 24) & 0xFF # <<<<<<<<<<<<<< @@ -3389,7 +3454,7 @@ static int __pyx_f_18polluck_blockchain_18placeholder_native_serialize_uint32(un */ (__pyx_v_out[0]) = ((__pyx_v_v >> 24) & 0xFF); - /* "polluck_blockchain/placeholder_native.pyx":38 + /* "polluck_blockchain/placeholder_native.pyx":39 * cdef int serialize_uint32(unsigned char* out, unsigned int v) except -1 nogil: * out[0] = (v >> 24) & 0xFF * out[1] = (v >> 16) & 0xFF # <<<<<<<<<<<<<< @@ -3398,7 +3463,7 @@ static int __pyx_f_18polluck_blockchain_18placeholder_native_serialize_uint32(un */ (__pyx_v_out[1]) = ((__pyx_v_v >> 16) & 0xFF); - /* "polluck_blockchain/placeholder_native.pyx":39 + /* "polluck_blockchain/placeholder_native.pyx":40 * out[0] = (v >> 24) & 0xFF * out[1] = (v >> 16) & 0xFF * out[2] = (v >> 8) & 0xFF # <<<<<<<<<<<<<< @@ -3407,7 +3472,7 @@ static int __pyx_f_18polluck_blockchain_18placeholder_native_serialize_uint32(un */ (__pyx_v_out[2]) = ((__pyx_v_v >> 8) & 0xFF); - /* "polluck_blockchain/placeholder_native.pyx":40 + /* "polluck_blockchain/placeholder_native.pyx":41 * out[1] = (v >> 16) & 0xFF * out[2] = (v >> 8) & 0xFF * out[3] = v & 0xFF # <<<<<<<<<<<<<< @@ -3416,7 +3481,7 @@ static int __pyx_f_18polluck_blockchain_18placeholder_native_serialize_uint32(un */ (__pyx_v_out[3]) = (__pyx_v_v & 0xFF); - /* "polluck_blockchain/placeholder_native.pyx":36 + /* "polluck_blockchain/placeholder_native.pyx":37 * # return struct.pack(">d", num) * * cdef int serialize_uint32(unsigned char* out, unsigned int v) except -1 nogil: # <<<<<<<<<<<<<< @@ -3429,7 +3494,7 @@ static int __pyx_f_18polluck_blockchain_18placeholder_native_serialize_uint32(un return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":42 +/* "polluck_blockchain/placeholder_native.pyx":43 * out[3] = v & 0xFF * * cdef int serialize_uint64(unsigned char* out, unsigned long long v) except -1 nogil: # <<<<<<<<<<<<<< @@ -3440,7 +3505,7 @@ static int __pyx_f_18polluck_blockchain_18placeholder_native_serialize_uint32(un static int __pyx_f_18polluck_blockchain_18placeholder_native_serialize_uint64(unsigned char *__pyx_v_out, unsigned PY_LONG_LONG __pyx_v_v) { int __pyx_r; - /* "polluck_blockchain/placeholder_native.pyx":43 + /* "polluck_blockchain/placeholder_native.pyx":44 * * cdef int serialize_uint64(unsigned char* out, unsigned long long v) except -1 nogil: * out[0] = (v >> 56) & 0xFF # <<<<<<<<<<<<<< @@ -3449,7 +3514,7 @@ static int __pyx_f_18polluck_blockchain_18placeholder_native_serialize_uint64(un */ (__pyx_v_out[0]) = ((__pyx_v_v >> 56) & 0xFF); - /* "polluck_blockchain/placeholder_native.pyx":44 + /* "polluck_blockchain/placeholder_native.pyx":45 * cdef int serialize_uint64(unsigned char* out, unsigned long long v) except -1 nogil: * out[0] = (v >> 56) & 0xFF * out[1] = (v >> 48) & 0xFF # <<<<<<<<<<<<<< @@ -3458,7 +3523,7 @@ static int __pyx_f_18polluck_blockchain_18placeholder_native_serialize_uint64(un */ (__pyx_v_out[1]) = ((__pyx_v_v >> 48) & 0xFF); - /* "polluck_blockchain/placeholder_native.pyx":45 + /* "polluck_blockchain/placeholder_native.pyx":46 * out[0] = (v >> 56) & 0xFF * out[1] = (v >> 48) & 0xFF * out[2] = (v >> 40) & 0xFF # <<<<<<<<<<<<<< @@ -3467,7 +3532,7 @@ static int __pyx_f_18polluck_blockchain_18placeholder_native_serialize_uint64(un */ (__pyx_v_out[2]) = ((__pyx_v_v >> 40) & 0xFF); - /* "polluck_blockchain/placeholder_native.pyx":46 + /* "polluck_blockchain/placeholder_native.pyx":47 * out[1] = (v >> 48) & 0xFF * out[2] = (v >> 40) & 0xFF * out[3] = (v >> 32) & 0xFF # <<<<<<<<<<<<<< @@ -3476,7 +3541,7 @@ static int __pyx_f_18polluck_blockchain_18placeholder_native_serialize_uint64(un */ (__pyx_v_out[3]) = ((__pyx_v_v >> 32) & 0xFF); - /* "polluck_blockchain/placeholder_native.pyx":47 + /* "polluck_blockchain/placeholder_native.pyx":48 * out[2] = (v >> 40) & 0xFF * out[3] = (v >> 32) & 0xFF * out[4] = (v >> 24) & 0xFF # <<<<<<<<<<<<<< @@ -3485,7 +3550,7 @@ static int __pyx_f_18polluck_blockchain_18placeholder_native_serialize_uint64(un */ (__pyx_v_out[4]) = ((__pyx_v_v >> 24) & 0xFF); - /* "polluck_blockchain/placeholder_native.pyx":48 + /* "polluck_blockchain/placeholder_native.pyx":49 * out[3] = (v >> 32) & 0xFF * out[4] = (v >> 24) & 0xFF * out[5] = (v >> 16) & 0xFF # <<<<<<<<<<<<<< @@ -3494,7 +3559,7 @@ static int __pyx_f_18polluck_blockchain_18placeholder_native_serialize_uint64(un */ (__pyx_v_out[5]) = ((__pyx_v_v >> 16) & 0xFF); - /* "polluck_blockchain/placeholder_native.pyx":49 + /* "polluck_blockchain/placeholder_native.pyx":50 * out[4] = (v >> 24) & 0xFF * out[5] = (v >> 16) & 0xFF * out[6] = (v >> 8) & 0xFF # <<<<<<<<<<<<<< @@ -3503,7 +3568,7 @@ static int __pyx_f_18polluck_blockchain_18placeholder_native_serialize_uint64(un */ (__pyx_v_out[6]) = ((__pyx_v_v >> 8) & 0xFF); - /* "polluck_blockchain/placeholder_native.pyx":50 + /* "polluck_blockchain/placeholder_native.pyx":51 * out[5] = (v >> 16) & 0xFF * out[6] = (v >> 8) & 0xFF * out[7] = v & 0xFF # <<<<<<<<<<<<<< @@ -3512,7 +3577,7 @@ static int __pyx_f_18polluck_blockchain_18placeholder_native_serialize_uint64(un */ (__pyx_v_out[7]) = (__pyx_v_v & 0xFF); - /* "polluck_blockchain/placeholder_native.pyx":42 + /* "polluck_blockchain/placeholder_native.pyx":43 * out[3] = v & 0xFF * * cdef int serialize_uint64(unsigned char* out, unsigned long long v) except -1 nogil: # <<<<<<<<<<<<<< @@ -3525,7 +3590,257 @@ static int __pyx_f_18polluck_blockchain_18placeholder_native_serialize_uint64(un return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":71 +/* "polluck_blockchain/placeholder_native.pyx":63 + * cdef const size_t NONCE_OFFSET = 16 + * + * cdef inline bint has_leading_zero_bits(const unsigned char *digest, int num_bits) nogil: # <<<<<<<<<<<<<< + * cdef int i, full_bytes = num_bits // 8 + * cdef int rem_bits = num_bits % 8 +*/ + +static CYTHON_INLINE int __pyx_f_18polluck_blockchain_18placeholder_native_has_leading_zero_bits(unsigned char const *__pyx_v_digest, int __pyx_v_num_bits) { + int __pyx_v_i; + int __pyx_v_full_bytes; + int __pyx_v_rem_bits; + int __pyx_r; + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + + /* "polluck_blockchain/placeholder_native.pyx":64 + * + * cdef inline bint has_leading_zero_bits(const unsigned char *digest, int num_bits) nogil: + * cdef int i, full_bytes = num_bits // 8 # <<<<<<<<<<<<<< + * cdef int rem_bits = num_bits % 8 + * +*/ + __pyx_v_full_bytes = __Pyx_div_long(__pyx_v_num_bits, 8, 1); + + /* "polluck_blockchain/placeholder_native.pyx":65 + * cdef inline bint has_leading_zero_bits(const unsigned char *digest, int num_bits) nogil: + * cdef int i, full_bytes = num_bits // 8 + * cdef int rem_bits = num_bits % 8 # <<<<<<<<<<<<<< + * + * for i in range(full_bytes): +*/ + __pyx_v_rem_bits = __Pyx_mod_long(__pyx_v_num_bits, 8, 1); + + /* "polluck_blockchain/placeholder_native.pyx":67 + * cdef int rem_bits = num_bits % 8 + * + * for i in range(full_bytes): # <<<<<<<<<<<<<< + * if digest[i] != 0: + * return False +*/ + __pyx_t_1 = __pyx_v_full_bytes; + __pyx_t_2 = __pyx_t_1; + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + __pyx_v_i = __pyx_t_3; + + /* "polluck_blockchain/placeholder_native.pyx":68 + * + * for i in range(full_bytes): + * if digest[i] != 0: # <<<<<<<<<<<<<< + * return False + * +*/ + __pyx_t_4 = ((__pyx_v_digest[__pyx_v_i]) != 0); + if (__pyx_t_4) { + + /* "polluck_blockchain/placeholder_native.pyx":69 + * for i in range(full_bytes): + * if digest[i] != 0: + * return False # <<<<<<<<<<<<<< + * + * if rem_bits: +*/ + __pyx_r = 0; + goto __pyx_L0; + + /* "polluck_blockchain/placeholder_native.pyx":68 + * + * for i in range(full_bytes): + * if digest[i] != 0: # <<<<<<<<<<<<<< + * return False + * +*/ + } + } + + /* "polluck_blockchain/placeholder_native.pyx":71 + * return False + * + * if rem_bits: # <<<<<<<<<<<<<< + * if digest[full_bytes] >> (8 - rem_bits) != 0: + * return False +*/ + __pyx_t_4 = (__pyx_v_rem_bits != 0); + if (__pyx_t_4) { + + /* "polluck_blockchain/placeholder_native.pyx":72 + * + * if rem_bits: + * if digest[full_bytes] >> (8 - rem_bits) != 0: # <<<<<<<<<<<<<< + * return False + * +*/ + __pyx_t_4 = (((__pyx_v_digest[__pyx_v_full_bytes]) >> (8 - __pyx_v_rem_bits)) != 0); + if (__pyx_t_4) { + + /* "polluck_blockchain/placeholder_native.pyx":73 + * if rem_bits: + * if digest[full_bytes] >> (8 - rem_bits) != 0: + * return False # <<<<<<<<<<<<<< + * + * return True +*/ + __pyx_r = 0; + goto __pyx_L0; + + /* "polluck_blockchain/placeholder_native.pyx":72 + * + * if rem_bits: + * if digest[full_bytes] >> (8 - rem_bits) != 0: # <<<<<<<<<<<<<< + * return False + * +*/ + } + + /* "polluck_blockchain/placeholder_native.pyx":71 + * return False + * + * if rem_bits: # <<<<<<<<<<<<<< + * if digest[full_bytes] >> (8 - rem_bits) != 0: + * return False +*/ + } + + /* "polluck_blockchain/placeholder_native.pyx":75 + * return False + * + * return True # <<<<<<<<<<<<<< + * + * cdef inline bint has_leading_zero_bytes(const unsigned char *digest, int num_bytes) nogil: +*/ + __pyx_r = 1; + goto __pyx_L0; + + /* "polluck_blockchain/placeholder_native.pyx":63 + * cdef const size_t NONCE_OFFSET = 16 + * + * cdef inline bint has_leading_zero_bits(const unsigned char *digest, int num_bits) nogil: # <<<<<<<<<<<<<< + * cdef int i, full_bytes = num_bits // 8 + * cdef int rem_bits = num_bits % 8 +*/ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "polluck_blockchain/placeholder_native.pyx":77 + * return True + * + * cdef inline bint has_leading_zero_bytes(const unsigned char *digest, int num_bytes) nogil: # <<<<<<<<<<<<<< + * cdef int i, full_bytes = num_bytes // 8 + * cdef int rem_bits = num_bytes % 8 +*/ + +static CYTHON_INLINE int __pyx_f_18polluck_blockchain_18placeholder_native_has_leading_zero_bytes(unsigned char const *__pyx_v_digest, int __pyx_v_num_bytes) { + int __pyx_v_i; + CYTHON_UNUSED int __pyx_v_full_bytes; + CYTHON_UNUSED int __pyx_v_rem_bits; + int __pyx_r; + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + + /* "polluck_blockchain/placeholder_native.pyx":78 + * + * cdef inline bint has_leading_zero_bytes(const unsigned char *digest, int num_bytes) nogil: + * cdef int i, full_bytes = num_bytes // 8 # <<<<<<<<<<<<<< + * cdef int rem_bits = num_bytes % 8 + * +*/ + __pyx_v_full_bytes = __Pyx_div_long(__pyx_v_num_bytes, 8, 1); + + /* "polluck_blockchain/placeholder_native.pyx":79 + * cdef inline bint has_leading_zero_bytes(const unsigned char *digest, int num_bytes) nogil: + * cdef int i, full_bytes = num_bytes // 8 + * cdef int rem_bits = num_bytes % 8 # <<<<<<<<<<<<<< + * + * for i in range(num_bytes): +*/ + __pyx_v_rem_bits = __Pyx_mod_long(__pyx_v_num_bytes, 8, 1); + + /* "polluck_blockchain/placeholder_native.pyx":81 + * cdef int rem_bits = num_bytes % 8 + * + * for i in range(num_bytes): # <<<<<<<<<<<<<< + * if digest[i] != 0: + * return False +*/ + __pyx_t_1 = __pyx_v_num_bytes; + __pyx_t_2 = __pyx_t_1; + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + __pyx_v_i = __pyx_t_3; + + /* "polluck_blockchain/placeholder_native.pyx":82 + * + * for i in range(num_bytes): + * if digest[i] != 0: # <<<<<<<<<<<<<< + * return False + * +*/ + __pyx_t_4 = ((__pyx_v_digest[__pyx_v_i]) != 0); + if (__pyx_t_4) { + + /* "polluck_blockchain/placeholder_native.pyx":83 + * for i in range(num_bytes): + * if digest[i] != 0: + * return False # <<<<<<<<<<<<<< + * + * return True +*/ + __pyx_r = 0; + goto __pyx_L0; + + /* "polluck_blockchain/placeholder_native.pyx":82 + * + * for i in range(num_bytes): + * if digest[i] != 0: # <<<<<<<<<<<<<< + * return False + * +*/ + } + } + + /* "polluck_blockchain/placeholder_native.pyx":85 + * return False + * + * return True # <<<<<<<<<<<<<< + * + * +*/ + __pyx_r = 1; + goto __pyx_L0; + + /* "polluck_blockchain/placeholder_native.pyx":77 + * return True + * + * cdef inline bint has_leading_zero_bytes(const unsigned char *digest, int num_bytes) nogil: # <<<<<<<<<<<<<< + * cdef int i, full_bytes = num_bytes // 8 + * cdef int rem_bits = num_bytes % 8 +*/ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "polluck_blockchain/placeholder_native.pyx":93 * bint ptr_owner * * def __cinit__(self, # <<<<<<<<<<<<<< @@ -3559,36 +3874,36 @@ static int __pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_1__cinit_ { 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, 71, __pyx_L3_error) + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 93, __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, 71, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 93, __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, 71, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 93, __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, 71, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 93, __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, 71, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 93, __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, 71, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 93, __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, 71, __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, 93, __pyx_L3_error) - /* "polluck_blockchain/placeholder_native.pyx":76 + /* "polluck_blockchain/placeholder_native.pyx":98 * data, * previous_hash, * from_ptr=False, # <<<<<<<<<<<<<< @@ -3597,23 +3912,23 @@ static int __pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_1__cinit_ */ 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__", 0, 4, 5, i); __PYX_ERR(0, 71, __pyx_L3_error) } + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, i); __PYX_ERR(0, 93, __pyx_L3_error) } } } else { switch (__pyx_nargs) { case 5: values[4] = __Pyx_ArgRef_VARARGS(__pyx_args, 4); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 71, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 93, __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, 71, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 93, __pyx_L3_error) values[2] = __Pyx_ArgRef_VARARGS(__pyx_args, 2); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 71, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 93, __pyx_L3_error) values[1] = __Pyx_ArgRef_VARARGS(__pyx_args, 1); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 71, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 93, __pyx_L3_error) values[0] = __Pyx_ArgRef_VARARGS(__pyx_args, 0); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 71, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 93, __pyx_L3_error) break; default: goto __pyx_L5_argtuple_error; } @@ -3627,7 +3942,7 @@ static int __pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_1__cinit_ } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, __pyx_nargs); __PYX_ERR(0, 71, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, __pyx_nargs); __PYX_ERR(0, 93, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -3640,7 +3955,7 @@ static int __pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_1__cinit_ __pyx_L4_argument_unpacking_done:; __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":71 + /* "polluck_blockchain/placeholder_native.pyx":93 * bint ptr_owner * * def __cinit__(self, # <<<<<<<<<<<<<< @@ -3678,7 +3993,7 @@ static int __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock___cinit__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "polluck_blockchain/placeholder_native.pyx":78 + /* "polluck_blockchain/placeholder_native.pyx":100 * from_ptr=False, * ): * self.ptr_owner = False # <<<<<<<<<<<<<< @@ -3687,39 +4002,39 @@ static int __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock___cinit__ */ __pyx_v_self->ptr_owner = 0; - /* "polluck_blockchain/placeholder_native.pyx":79 + /* "polluck_blockchain/placeholder_native.pyx":101 * ): * self.ptr_owner = False * if not from_ptr: # <<<<<<<<<<<<<< * self.BlockC = new Block( * index, */ - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_from_ptr); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 79, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_from_ptr); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 101, __pyx_L1_error) __pyx_t_2 = (!__pyx_t_1); if (__pyx_t_2) { - /* "polluck_blockchain/placeholder_native.pyx":81 + /* "polluck_blockchain/placeholder_native.pyx":103 * if not from_ptr: * self.BlockC = new Block( * index, # <<<<<<<<<<<<<< * int(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, 81, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyLong_As_uint64_t(__pyx_v_index); if (unlikely((__pyx_t_3 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 103, __pyx_L1_error) - /* "polluck_blockchain/placeholder_native.pyx":82 + /* "polluck_blockchain/placeholder_native.pyx":104 * self.BlockC = new Block( * index, * int(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, 82, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 104, __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, 82, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 104, __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, 82, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_mstate_global->__pyx_tuple[0], NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_5 = __pyx_t_6; @@ -3730,25 +4045,25 @@ static int __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock___cinit__ __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, 82, __pyx_L1_error) + if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); } - __pyx_t_6 = __Pyx_PyNumber_Int(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 82, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyNumber_Int(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_9 = __Pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 82, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - /* "polluck_blockchain/placeholder_native.pyx":83 + /* "polluck_blockchain/placeholder_native.pyx":105 * index, * int(datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp()), * nonce, # <<<<<<<<<<<<<< * data.encode("UTF-8"), * previous_hash.encode("UTF-8"), */ - __pyx_t_10 = __Pyx_PyLong_As_uint64_t(__pyx_v_nonce); if (unlikely((__pyx_t_10 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 83, __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, 105, __pyx_L1_error) - /* "polluck_blockchain/placeholder_native.pyx":84 + /* "polluck_blockchain/placeholder_native.pyx":106 * int(datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp()), * nonce, * data.encode("UTF-8"), # <<<<<<<<<<<<<< @@ -3762,13 +4077,13 @@ static int __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock___cinit__ PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_UTF_8}; __pyx_t_6 = __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_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 84, __pyx_L1_error) + if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); } - __pyx_t_11 = __pyx_convert_string_from_py_6libcpp_6string_std__in_string(__pyx_t_6); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 84, __pyx_L1_error) + __pyx_t_11 = __pyx_convert_string_from_py_6libcpp_6string_std__in_string(__pyx_t_6); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 106, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - /* "polluck_blockchain/placeholder_native.pyx":85 + /* "polluck_blockchain/placeholder_native.pyx":107 * nonce, * data.encode("UTF-8"), * previous_hash.encode("UTF-8"), # <<<<<<<<<<<<<< @@ -3782,22 +4097,22 @@ static int __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock___cinit__ PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_UTF_8}; __pyx_t_6 = __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_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 85, __pyx_L1_error) + if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); } - __pyx_t_12 = __pyx_convert_string_from_py_6libcpp_6string_std__in_string(__pyx_t_6); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 85, __pyx_L1_error) + __pyx_t_12 = __pyx_convert_string_from_py_6libcpp_6string_std__in_string(__pyx_t_6); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - /* "polluck_blockchain/placeholder_native.pyx":86 + /* "polluck_blockchain/placeholder_native.pyx":108 * 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, 86, __pyx_L1_error) + __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, 108, __pyx_L1_error) - /* "polluck_blockchain/placeholder_native.pyx":80 + /* "polluck_blockchain/placeholder_native.pyx":102 * self.ptr_owner = False * if not from_ptr: * self.BlockC = new Block( # <<<<<<<<<<<<<< @@ -3808,11 +4123,11 @@ static int __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock___cinit__ __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, 80, __pyx_L1_error) + __PYX_ERR(0, 102, __pyx_L1_error) } __pyx_v_self->BlockC = __pyx_t_14; - /* "polluck_blockchain/placeholder_native.pyx":88 + /* "polluck_blockchain/placeholder_native.pyx":110 * "".encode("UTF-8"), * ) * if self.BlockC == NULL: # <<<<<<<<<<<<<< @@ -3822,16 +4137,16 @@ static int __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock___cinit__ __pyx_t_2 = (__pyx_v_self->BlockC == NULL); if (unlikely(__pyx_t_2)) { - /* "polluck_blockchain/placeholder_native.pyx":89 + /* "polluck_blockchain/placeholder_native.pyx":111 * ) * if self.BlockC == NULL: * raise MemoryError() # <<<<<<<<<<<<<< * * self.ptr_owner = True */ - PyErr_NoMemory(); __PYX_ERR(0, 89, __pyx_L1_error) + PyErr_NoMemory(); __PYX_ERR(0, 111, __pyx_L1_error) - /* "polluck_blockchain/placeholder_native.pyx":88 + /* "polluck_blockchain/placeholder_native.pyx":110 * "".encode("UTF-8"), * ) * if self.BlockC == NULL: # <<<<<<<<<<<<<< @@ -3840,7 +4155,7 @@ static int __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock___cinit__ */ } - /* "polluck_blockchain/placeholder_native.pyx":91 + /* "polluck_blockchain/placeholder_native.pyx":113 * raise MemoryError() * * self.ptr_owner = True # <<<<<<<<<<<<<< @@ -3849,7 +4164,7 @@ static int __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock___cinit__ */ __pyx_v_self->ptr_owner = 1; - /* "polluck_blockchain/placeholder_native.pyx":79 + /* "polluck_blockchain/placeholder_native.pyx":101 * ): * self.ptr_owner = False * if not from_ptr: # <<<<<<<<<<<<<< @@ -3858,7 +4173,7 @@ static int __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock___cinit__ */ } - /* "polluck_blockchain/placeholder_native.pyx":71 + /* "polluck_blockchain/placeholder_native.pyx":93 * bint ptr_owner * * def __cinit__(self, # <<<<<<<<<<<<<< @@ -3881,7 +4196,7 @@ static int __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock___cinit__ return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":93 +/* "polluck_blockchain/placeholder_native.pyx":115 * self.ptr_owner = True * * def __init__(self, *args, **kwargs): # <<<<<<<<<<<<<< @@ -3929,7 +4244,7 @@ static int __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_2__init__ return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":96 +/* "polluck_blockchain/placeholder_native.pyx":118 * pass * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -3954,7 +4269,7 @@ static void __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_4__deall int __pyx_t_1; int __pyx_t_2; - /* "polluck_blockchain/placeholder_native.pyx":97 + /* "polluck_blockchain/placeholder_native.pyx":119 * * def __dealloc__(self): * if self.BlockC is not NULL and self.ptr_owner is True: # <<<<<<<<<<<<<< @@ -3972,7 +4287,7 @@ static void __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_4__deall __pyx_L4_bool_binop_done:; if (__pyx_t_1) { - /* "polluck_blockchain/placeholder_native.pyx":98 + /* "polluck_blockchain/placeholder_native.pyx":120 * def __dealloc__(self): * if self.BlockC is not NULL and self.ptr_owner is True: * del self.BlockC # <<<<<<<<<<<<<< @@ -3981,7 +4296,7 @@ static void __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_4__deall */ delete __pyx_v_self->BlockC; - /* "polluck_blockchain/placeholder_native.pyx":99 + /* "polluck_blockchain/placeholder_native.pyx":121 * if self.BlockC is not NULL and self.ptr_owner is True: * del self.BlockC * self.BlockC = NULL # <<<<<<<<<<<<<< @@ -3990,7 +4305,7 @@ static void __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_4__deall */ __pyx_v_self->BlockC = NULL; - /* "polluck_blockchain/placeholder_native.pyx":97 + /* "polluck_blockchain/placeholder_native.pyx":119 * * def __dealloc__(self): * if self.BlockC is not NULL and self.ptr_owner is True: # <<<<<<<<<<<<<< @@ -3999,7 +4314,7 @@ static void __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_4__deall */ } - /* "polluck_blockchain/placeholder_native.pyx":96 + /* "polluck_blockchain/placeholder_native.pyx":118 * pass * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -4010,7 +4325,7 @@ static void __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_4__deall /* function exit code */ } -/* "polluck_blockchain/placeholder_native.pyx":101 +/* "polluck_blockchain/placeholder_native.pyx":123 * self.BlockC = NULL * * @staticmethod # <<<<<<<<<<<<<< @@ -4020,7 +4335,7 @@ static void __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_4__deall 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":102 + /* "polluck_blockchain/placeholder_native.pyx":124 * * @staticmethod * cdef PyBlock from_ptr(Block *block, bint owner=False): # <<<<<<<<<<<<<< @@ -4046,77 +4361,77 @@ static struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx } } - /* "polluck_blockchain/placeholder_native.pyx":105 + /* "polluck_blockchain/placeholder_native.pyx":127 * 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, 105, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyLong_From_uint64_t(__pyx_v_block->index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - /* "polluck_blockchain/placeholder_native.pyx":106 + /* "polluck_blockchain/placeholder_native.pyx":128 * 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, 106, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyLong_From_uint64_t(__pyx_v_block->nonce); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - /* "polluck_blockchain/placeholder_native.pyx":107 + /* "polluck_blockchain/placeholder_native.pyx":129 * 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, 107, __pyx_L1_error) + __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, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - /* "polluck_blockchain/placeholder_native.pyx":108 + /* "polluck_blockchain/placeholder_native.pyx":130 * 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, 108, __pyx_L1_error) + __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, 130, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - /* "polluck_blockchain/placeholder_native.pyx":103 + /* "polluck_blockchain/placeholder_native.pyx":125 * @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, 103, __pyx_L1_error) + __pyx_t_5 = PyTuple_New(5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 125, __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, 103, __pyx_L1_error); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1) != (0)) __PYX_ERR(0, 125, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_2); - if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2) != (0)) __PYX_ERR(0, 103, __pyx_L1_error); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2) != (0)) __PYX_ERR(0, 125, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); - if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3) != (0)) __PYX_ERR(0, 103, __pyx_L1_error); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3) != (0)) __PYX_ERR(0, 125, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_4); - if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4) != (0)) __PYX_ERR(0, 103, __pyx_L1_error); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4) != (0)) __PYX_ERR(0, 125, __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, 103, __pyx_L1_error); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 4, Py_True) != (0)) __PYX_ERR(0, 125, __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, 103, __pyx_L1_error) + __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, 125, __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":111 + /* "polluck_blockchain/placeholder_native.pyx":133 * True, * ) * py_block.BlockC = block # <<<<<<<<<<<<<< @@ -4125,7 +4440,7 @@ static struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx */ __pyx_v_py_block->BlockC = __pyx_v_block; - /* "polluck_blockchain/placeholder_native.pyx":112 + /* "polluck_blockchain/placeholder_native.pyx":134 * ) * py_block.BlockC = block * py_block.ptr_owner = owner # <<<<<<<<<<<<<< @@ -4134,7 +4449,7 @@ static struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx */ __pyx_v_py_block->ptr_owner = __pyx_v_owner; - /* "polluck_blockchain/placeholder_native.pyx":114 + /* "polluck_blockchain/placeholder_native.pyx":136 * py_block.ptr_owner = owner * * return py_block # <<<<<<<<<<<<<< @@ -4146,7 +4461,7 @@ static struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx __pyx_r = __pyx_v_py_block; goto __pyx_L0; - /* "polluck_blockchain/placeholder_native.pyx":101 + /* "polluck_blockchain/placeholder_native.pyx":123 * self.BlockC = NULL * * @staticmethod # <<<<<<<<<<<<<< @@ -4170,7 +4485,7 @@ static struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":116 +/* "polluck_blockchain/placeholder_native.pyx":138 * return py_block * * def __repr__(self): # <<<<<<<<<<<<<< @@ -4207,7 +4522,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_6__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__repr__", 0); - /* "polluck_blockchain/placeholder_native.pyx":117 + /* "polluck_blockchain/placeholder_native.pyx":139 * * def __repr__(self): * return f"PyBlock({self.index, self.timestamp, self.nonce, self.data})" # <<<<<<<<<<<<<< @@ -4215,43 +4530,43 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_6__ * def __str__(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_mstate_global->__pyx_n_u_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 117, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_mstate_global->__pyx_n_u_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_mstate_global->__pyx_n_u_timestamp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 117, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_mstate_global->__pyx_n_u_timestamp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_mstate_global->__pyx_n_u_nonce); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 117, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_mstate_global->__pyx_n_u_nonce); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_mstate_global->__pyx_n_u_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 117, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_mstate_global->__pyx_n_u_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 117, __pyx_L1_error) + __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 139, __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, 117, __pyx_L1_error); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1) != (0)) __PYX_ERR(0, 139, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_2); - if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2) != (0)) __PYX_ERR(0, 117, __pyx_L1_error); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2) != (0)) __PYX_ERR(0, 139, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); - if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3) != (0)) __PYX_ERR(0, 117, __pyx_L1_error); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3) != (0)) __PYX_ERR(0, 139, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_4); - if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4) != (0)) __PYX_ERR(0, 117, __pyx_L1_error); + if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4) != (0)) __PYX_ERR(0, 139, __pyx_L1_error); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_FormatSimple(__pyx_t_5, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 117, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_FormatSimple(__pyx_t_5, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_6[0] = __pyx_mstate_global->__pyx_kp_u_PyBlock; __pyx_t_6[1] = __pyx_t_4; __pyx_t_6[2] = __pyx_mstate_global->__pyx_kp_u__2; __pyx_t_5 = __Pyx_PyUnicode_Join(__pyx_t_6, 3, 8 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4) + 1, 127 | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4)); - if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 117, __pyx_L1_error) + if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; - /* "polluck_blockchain/placeholder_native.pyx":116 + /* "polluck_blockchain/placeholder_native.pyx":138 * return py_block * * def __repr__(self): # <<<<<<<<<<<<<< @@ -4274,7 +4589,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_6__ return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":119 +/* "polluck_blockchain/placeholder_native.pyx":141 * return f"PyBlock({self.index, self.timestamp, self.nonce, self.data})" * * def __str__(self): # <<<<<<<<<<<<<< @@ -4308,7 +4623,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_8__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__str__", 0); - /* "polluck_blockchain/placeholder_native.pyx":120 + /* "polluck_blockchain/placeholder_native.pyx":142 * * def __str__(self): * return self.__repr__() # <<<<<<<<<<<<<< @@ -4323,14 +4638,14 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_8__ PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_repr, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 120, __pyx_L1_error) + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 142, __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":119 + /* "polluck_blockchain/placeholder_native.pyx":141 * return f"PyBlock({self.index, self.timestamp, self.nonce, self.data})" * * def __str__(self): # <<<<<<<<<<<<<< @@ -4350,7 +4665,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_8__ return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":139 +/* "polluck_blockchain/placeholder_native.pyx":161 * * # Python public API * @property # <<<<<<<<<<<<<< @@ -4382,7 +4697,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_5in int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "polluck_blockchain/placeholder_native.pyx":141 + /* "polluck_blockchain/placeholder_native.pyx":163 * @property * def index(self): * return self.BlockC.index # <<<<<<<<<<<<<< @@ -4390,13 +4705,13 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_5in * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyLong_From_uint64_t(__pyx_v_self->BlockC->index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 141, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyLong_From_uint64_t(__pyx_v_self->BlockC->index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __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":139 + /* "polluck_blockchain/placeholder_native.pyx":161 * * # Python public API * @property # <<<<<<<<<<<<<< @@ -4415,7 +4730,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_5in return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":143 +/* "polluck_blockchain/placeholder_native.pyx":165 * return self.BlockC.index * * @property # <<<<<<<<<<<<<< @@ -4447,7 +4762,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_9ti int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "polluck_blockchain/placeholder_native.pyx":145 + /* "polluck_blockchain/placeholder_native.pyx":167 * @property * def timestamp(self): * return timestamp_to_datetime(self.BlockC.timestamp) # <<<<<<<<<<<<<< @@ -4455,13 +4770,13 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_9ti * @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, 145, __pyx_L1_error) + __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, 167, __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":143 + /* "polluck_blockchain/placeholder_native.pyx":165 * return self.BlockC.index * * @property # <<<<<<<<<<<<<< @@ -4480,7 +4795,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_9ti return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":147 +/* "polluck_blockchain/placeholder_native.pyx":169 * return timestamp_to_datetime(self.BlockC.timestamp) * * @property # <<<<<<<<<<<<<< @@ -4512,7 +4827,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_4da int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "polluck_blockchain/placeholder_native.pyx":149 + /* "polluck_blockchain/placeholder_native.pyx":171 * @property * def data(self): * return self.BlockC.data.decode("UTF-8") # <<<<<<<<<<<<<< @@ -4520,13 +4835,13 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_4da * @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, 149, __pyx_L1_error) + __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, 171, __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":147 + /* "polluck_blockchain/placeholder_native.pyx":169 * return timestamp_to_datetime(self.BlockC.timestamp) * * @property # <<<<<<<<<<<<<< @@ -4545,7 +4860,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_4da return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":151 +/* "polluck_blockchain/placeholder_native.pyx":173 * return self.BlockC.data.decode("UTF-8") * * @property # <<<<<<<<<<<<<< @@ -4577,7 +4892,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_9pr int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "polluck_blockchain/placeholder_native.pyx":153 + /* "polluck_blockchain/placeholder_native.pyx":175 * @property * def prev_hash(self): * return self.BlockC.prev_hash.decode("UTF-8") # <<<<<<<<<<<<<< @@ -4585,13 +4900,13 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_9pr * @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, 153, __pyx_L1_error) + __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, 175, __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":151 + /* "polluck_blockchain/placeholder_native.pyx":173 * return self.BlockC.data.decode("UTF-8") * * @property # <<<<<<<<<<<<<< @@ -4610,7 +4925,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_9pr return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":155 +/* "polluck_blockchain/placeholder_native.pyx":177 * return self.BlockC.prev_hash.decode("UTF-8") * * @property # <<<<<<<<<<<<<< @@ -4642,7 +4957,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_5no int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "polluck_blockchain/placeholder_native.pyx":157 + /* "polluck_blockchain/placeholder_native.pyx":179 * @property * def nonce(self): * return self.BlockC.nonce # <<<<<<<<<<<<<< @@ -4650,13 +4965,13 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_5no * # @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, 157, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyLong_From_uint64_t(__pyx_v_self->BlockC->nonce); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 179, __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":155 + /* "polluck_blockchain/placeholder_native.pyx":177 * return self.BlockC.prev_hash.decode("UTF-8") * * @property # <<<<<<<<<<<<<< @@ -4675,7 +4990,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_5no return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":163 +/* "polluck_blockchain/placeholder_native.pyx":185 * # self._nonce = value * * @property # <<<<<<<<<<<<<< @@ -4707,21 +5022,21 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_4ha int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "polluck_blockchain/placeholder_native.pyx":165 + /* "polluck_blockchain/placeholder_native.pyx":187 * @property * def hash(self): * return self.BlockC.hash.decode("UTF-8") # <<<<<<<<<<<<<< * - * cdef unsigned char* bytes_serialize_c(self, size_t *size): + * cdef unsigned char* bytes_serialize_c(self, size_t *size) nogil: */ __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, 165, __pyx_L1_error) + __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, 187, __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":163 + /* "polluck_blockchain/placeholder_native.pyx":185 * # self._nonce = value * * @property # <<<<<<<<<<<<<< @@ -4740,10 +5055,10 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_4ha return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":167 +/* "polluck_blockchain/placeholder_native.pyx":189 * return self.BlockC.hash.decode("UTF-8") * - * cdef unsigned char* bytes_serialize_c(self, size_t *size): # <<<<<<<<<<<<<< + * cdef unsigned char* bytes_serialize_c(self, size_t *size) nogil: # <<<<<<<<<<<<<< * cdef: * size_t total_len */ @@ -4757,8 +5072,9 @@ static unsigned char *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; + PyGILState_STATE __pyx_gilstate_save; - /* "polluck_blockchain/placeholder_native.pyx":171 + /* "polluck_blockchain/placeholder_native.pyx":193 * size_t total_len * unsigned char* buf * size_t pos = 0 # <<<<<<<<<<<<<< @@ -4767,7 +5083,7 @@ static unsigned char *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock */ __pyx_v_pos = 0; - /* "polluck_blockchain/placeholder_native.pyx":174 + /* "polluck_blockchain/placeholder_native.pyx":196 * * # index (8), timestamp (8), nonce (8), data, prev_hash * size[0] = ( # <<<<<<<<<<<<<< @@ -4776,7 +5092,7 @@ static unsigned char *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock */ (__pyx_v_size[0]) = ((((size_t)0x18) + __pyx_v_self->BlockC->data.size()) + __pyx_v_self->BlockC->prev_hash.size()); - /* "polluck_blockchain/placeholder_native.pyx":179 + /* "polluck_blockchain/placeholder_native.pyx":201 * self.BlockC.prev_hash.size() * ) * buf = malloc(size[0] * sizeof(unsigned char)) # <<<<<<<<<<<<<< @@ -4785,44 +5101,45 @@ static unsigned char *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock */ __pyx_v_buf = ((unsigned char *)malloc(((__pyx_v_size[0]) * (sizeof(unsigned char))))); - /* "polluck_blockchain/placeholder_native.pyx":181 + /* "polluck_blockchain/placeholder_native.pyx":203 * buf = malloc(size[0] * sizeof(unsigned char)) * * if buf == NULL: # <<<<<<<<<<<<<< - * raise MemoryError() + * return NULL * */ __pyx_t_1 = (__pyx_v_buf == NULL); - if (unlikely(__pyx_t_1)) { + if (__pyx_t_1) { - /* "polluck_blockchain/placeholder_native.pyx":182 + /* "polluck_blockchain/placeholder_native.pyx":204 * * if buf == NULL: - * raise MemoryError() # <<<<<<<<<<<<<< + * return NULL # <<<<<<<<<<<<<< * * serialize_uint64(buf + pos, self.BlockC.index) */ - PyErr_NoMemory(); __PYX_ERR(0, 182, __pyx_L1_error) + __pyx_r = NULL; + goto __pyx_L0; - /* "polluck_blockchain/placeholder_native.pyx":181 + /* "polluck_blockchain/placeholder_native.pyx":203 * buf = malloc(size[0] * sizeof(unsigned char)) * * if buf == NULL: # <<<<<<<<<<<<<< - * raise MemoryError() + * return NULL * */ } - /* "polluck_blockchain/placeholder_native.pyx":184 - * raise MemoryError() + /* "polluck_blockchain/placeholder_native.pyx":206 + * return NULL * * serialize_uint64(buf + pos, self.BlockC.index) # <<<<<<<<<<<<<< * pos += 8 * serialize_uint64(buf + pos, self.BlockC.timestamp) */ - __pyx_t_2 = __pyx_f_18polluck_blockchain_18placeholder_native_serialize_uint64((__pyx_v_buf + __pyx_v_pos), __pyx_v_self->BlockC->index); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 184, __pyx_L1_error) + __pyx_t_2 = __pyx_f_18polluck_blockchain_18placeholder_native_serialize_uint64((__pyx_v_buf + __pyx_v_pos), __pyx_v_self->BlockC->index); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 206, __pyx_L1_error) - /* "polluck_blockchain/placeholder_native.pyx":185 + /* "polluck_blockchain/placeholder_native.pyx":207 * * serialize_uint64(buf + pos, self.BlockC.index) * pos += 8 # <<<<<<<<<<<<<< @@ -4831,16 +5148,16 @@ static unsigned char *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock */ __pyx_v_pos = (__pyx_v_pos + 8); - /* "polluck_blockchain/placeholder_native.pyx":186 + /* "polluck_blockchain/placeholder_native.pyx":208 * serialize_uint64(buf + pos, self.BlockC.index) * pos += 8 * serialize_uint64(buf + pos, self.BlockC.timestamp) # <<<<<<<<<<<<<< * pos += 8 * serialize_uint64(buf + pos, self.BlockC.nonce) */ - __pyx_t_2 = __pyx_f_18polluck_blockchain_18placeholder_native_serialize_uint64((__pyx_v_buf + __pyx_v_pos), __pyx_v_self->BlockC->timestamp); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 186, __pyx_L1_error) + __pyx_t_2 = __pyx_f_18polluck_blockchain_18placeholder_native_serialize_uint64((__pyx_v_buf + __pyx_v_pos), __pyx_v_self->BlockC->timestamp); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 208, __pyx_L1_error) - /* "polluck_blockchain/placeholder_native.pyx":187 + /* "polluck_blockchain/placeholder_native.pyx":209 * pos += 8 * serialize_uint64(buf + pos, self.BlockC.timestamp) * pos += 8 # <<<<<<<<<<<<<< @@ -4849,16 +5166,16 @@ static unsigned char *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock */ __pyx_v_pos = (__pyx_v_pos + 8); - /* "polluck_blockchain/placeholder_native.pyx":188 + /* "polluck_blockchain/placeholder_native.pyx":210 * serialize_uint64(buf + pos, self.BlockC.timestamp) * pos += 8 * serialize_uint64(buf + pos, self.BlockC.nonce) # <<<<<<<<<<<<<< * pos += 8 * # Copy data */ - __pyx_t_2 = __pyx_f_18polluck_blockchain_18placeholder_native_serialize_uint64((__pyx_v_buf + __pyx_v_pos), __pyx_v_self->BlockC->nonce); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 188, __pyx_L1_error) + __pyx_t_2 = __pyx_f_18polluck_blockchain_18placeholder_native_serialize_uint64((__pyx_v_buf + __pyx_v_pos), __pyx_v_self->BlockC->nonce); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 210, __pyx_L1_error) - /* "polluck_blockchain/placeholder_native.pyx":189 + /* "polluck_blockchain/placeholder_native.pyx":211 * pos += 8 * serialize_uint64(buf + pos, self.BlockC.nonce) * pos += 8 # <<<<<<<<<<<<<< @@ -4867,7 +5184,7 @@ static unsigned char *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock */ __pyx_v_pos = (__pyx_v_pos + 8); - /* "polluck_blockchain/placeholder_native.pyx":191 + /* "polluck_blockchain/placeholder_native.pyx":213 * pos += 8 * # Copy data * memcpy( # <<<<<<<<<<<<<< @@ -4876,7 +5193,7 @@ static unsigned char *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock */ (void)(memcpy((__pyx_v_buf + __pyx_v_pos), __pyx_v_self->BlockC->data.c_str(), __pyx_v_self->BlockC->data.size())); - /* "polluck_blockchain/placeholder_native.pyx":196 + /* "polluck_blockchain/placeholder_native.pyx":218 * self.BlockC.data.size(), * ) * pos += self.BlockC.data.size() # <<<<<<<<<<<<<< @@ -4885,7 +5202,7 @@ static unsigned char *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock */ __pyx_v_pos = (__pyx_v_pos + __pyx_v_self->BlockC->data.size()); - /* "polluck_blockchain/placeholder_native.pyx":198 + /* "polluck_blockchain/placeholder_native.pyx":220 * pos += self.BlockC.data.size() * # Copy prev_hash * memcpy( # <<<<<<<<<<<<<< @@ -4894,7 +5211,7 @@ static unsigned char *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock */ (void)(memcpy((__pyx_v_buf + __pyx_v_pos), __pyx_v_self->BlockC->prev_hash.c_str(), __pyx_v_self->BlockC->prev_hash.size())); - /* "polluck_blockchain/placeholder_native.pyx":203 + /* "polluck_blockchain/placeholder_native.pyx":225 * self.BlockC.prev_hash.size(), * ) * pos += self.BlockC.prev_hash.size() # <<<<<<<<<<<<<< @@ -4903,35 +5220,216 @@ static unsigned char *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock */ __pyx_v_pos = (__pyx_v_pos + __pyx_v_self->BlockC->prev_hash.size()); - /* "polluck_blockchain/placeholder_native.pyx":205 + /* "polluck_blockchain/placeholder_native.pyx":227 * pos += self.BlockC.prev_hash.size() * * return buf # <<<<<<<<<<<<<< * - * def bytes_serialize(self): + * cdef unsigned char* digest(self, unsigned char *data, size_t data_size, size_t *digest_size) nogil: */ __pyx_r = __pyx_v_buf; goto __pyx_L0; - /* "polluck_blockchain/placeholder_native.pyx":167 + /* "polluck_blockchain/placeholder_native.pyx":189 * return self.BlockC.hash.decode("UTF-8") * - * cdef unsigned char* bytes_serialize_c(self, size_t *size): # <<<<<<<<<<<<<< + * cdef unsigned char* bytes_serialize_c(self, size_t *size) nogil: # <<<<<<<<<<<<<< * cdef: * size_t total_len */ /* function exit code */ __pyx_L1_error:; + __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); __Pyx_AddTraceback("polluck_blockchain.placeholder_native.PyBlock.bytes_serialize_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; + __Pyx_PyGILState_Release(__pyx_gilstate_save); __pyx_L0:; return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":207 +/* "polluck_blockchain/placeholder_native.pyx":229 * return buf * + * cdef unsigned char* digest(self, unsigned char *data, size_t data_size, size_t *digest_size) nogil: # <<<<<<<<<<<<<< + * cdef ossl.EVP_MD_CTX *ctx = ossl.EVP_MD_CTX_new() + * if ctx == NULL: +*/ + +static unsigned char *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_digest(CYTHON_UNUSED struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self, unsigned char *__pyx_v_data, size_t __pyx_v_data_size, size_t *__pyx_v_digest_size) { + EVP_MD_CTX *__pyx_v_ctx; + EVP_MD const *__pyx_v_algo; + unsigned char *__pyx_v_digest; + size_t __pyx_v_dig_buff_len; + unsigned int __pyx_v_digest_len; + unsigned char *__pyx_r; + int __pyx_t_1; + + /* "polluck_blockchain/placeholder_native.pyx":230 + * + * cdef unsigned char* digest(self, unsigned char *data, size_t data_size, size_t *digest_size) nogil: + * cdef ossl.EVP_MD_CTX *ctx = ossl.EVP_MD_CTX_new() # <<<<<<<<<<<<<< + * if ctx == NULL: + * return NULL +*/ + __pyx_v_ctx = EVP_MD_CTX_new(); + + /* "polluck_blockchain/placeholder_native.pyx":231 + * cdef unsigned char* digest(self, unsigned char *data, size_t data_size, size_t *digest_size) nogil: + * cdef ossl.EVP_MD_CTX *ctx = ossl.EVP_MD_CTX_new() + * if ctx == NULL: # <<<<<<<<<<<<<< + * return NULL + * cdef const ossl.EVP_MD *algo = ossl.EVP_sha256() +*/ + __pyx_t_1 = (__pyx_v_ctx == NULL); + if (__pyx_t_1) { + + /* "polluck_blockchain/placeholder_native.pyx":232 + * cdef ossl.EVP_MD_CTX *ctx = ossl.EVP_MD_CTX_new() + * if ctx == NULL: + * return NULL # <<<<<<<<<<<<<< + * cdef const ossl.EVP_MD *algo = ossl.EVP_sha256() + * if algo == NULL: +*/ + __pyx_r = NULL; + goto __pyx_L0; + + /* "polluck_blockchain/placeholder_native.pyx":231 + * cdef unsigned char* digest(self, unsigned char *data, size_t data_size, size_t *digest_size) nogil: + * cdef ossl.EVP_MD_CTX *ctx = ossl.EVP_MD_CTX_new() + * if ctx == NULL: # <<<<<<<<<<<<<< + * return NULL + * cdef const ossl.EVP_MD *algo = ossl.EVP_sha256() +*/ + } + + /* "polluck_blockchain/placeholder_native.pyx":233 + * if ctx == NULL: + * return NULL + * cdef const ossl.EVP_MD *algo = ossl.EVP_sha256() # <<<<<<<<<<<<<< + * if algo == NULL: + * return NULL +*/ + __pyx_v_algo = EVP_sha256(); + + /* "polluck_blockchain/placeholder_native.pyx":234 + * return NULL + * cdef const ossl.EVP_MD *algo = ossl.EVP_sha256() + * if algo == NULL: # <<<<<<<<<<<<<< + * return NULL + * +*/ + __pyx_t_1 = (__pyx_v_algo == NULL); + if (__pyx_t_1) { + + /* "polluck_blockchain/placeholder_native.pyx":235 + * cdef const ossl.EVP_MD *algo = ossl.EVP_sha256() + * if algo == NULL: + * return NULL # <<<<<<<<<<<<<< + * + * cdef: +*/ + __pyx_r = NULL; + goto __pyx_L0; + + /* "polluck_blockchain/placeholder_native.pyx":234 + * return NULL + * cdef const ossl.EVP_MD *algo = ossl.EVP_sha256() + * if algo == NULL: # <<<<<<<<<<<<<< + * return NULL + * +*/ + } + + /* "polluck_blockchain/placeholder_native.pyx":242 + * unsigned int digest_len + * + * dig_buff_len = ossl.EVP_MD_size(algo) # <<<<<<<<<<<<<< + * digest = malloc(dig_buff_len * sizeof(unsigned char)) + * ossl.EVP_DigestInit_ex(ctx, algo, NULL) +*/ + __pyx_v_dig_buff_len = ((size_t)EVP_MD_size(__pyx_v_algo)); + + /* "polluck_blockchain/placeholder_native.pyx":243 + * + * dig_buff_len = ossl.EVP_MD_size(algo) + * digest = malloc(dig_buff_len * sizeof(unsigned char)) # <<<<<<<<<<<<<< + * ossl.EVP_DigestInit_ex(ctx, algo, NULL) + * ossl.EVP_DigestUpdate(ctx, data, data_size) +*/ + __pyx_v_digest = ((unsigned char *)malloc((__pyx_v_dig_buff_len * (sizeof(unsigned char))))); + + /* "polluck_blockchain/placeholder_native.pyx":244 + * dig_buff_len = ossl.EVP_MD_size(algo) + * digest = malloc(dig_buff_len * sizeof(unsigned char)) + * ossl.EVP_DigestInit_ex(ctx, algo, NULL) # <<<<<<<<<<<<<< + * ossl.EVP_DigestUpdate(ctx, data, data_size) + * ossl.EVP_DigestFinal_ex(ctx, digest, &digest_len) +*/ + (void)(EVP_DigestInit_ex(__pyx_v_ctx, __pyx_v_algo, NULL)); + + /* "polluck_blockchain/placeholder_native.pyx":245 + * digest = malloc(dig_buff_len * sizeof(unsigned char)) + * ossl.EVP_DigestInit_ex(ctx, algo, NULL) + * ossl.EVP_DigestUpdate(ctx, data, data_size) # <<<<<<<<<<<<<< + * ossl.EVP_DigestFinal_ex(ctx, digest, &digest_len) + * +*/ + (void)(EVP_DigestUpdate(__pyx_v_ctx, __pyx_v_data, __pyx_v_data_size)); + + /* "polluck_blockchain/placeholder_native.pyx":246 + * ossl.EVP_DigestInit_ex(ctx, algo, NULL) + * ossl.EVP_DigestUpdate(ctx, data, data_size) + * ossl.EVP_DigestFinal_ex(ctx, digest, &digest_len) # <<<<<<<<<<<<<< + * + * digest_size[0] = dig_buff_len +*/ + (void)(EVP_DigestFinal_ex(__pyx_v_ctx, __pyx_v_digest, (&__pyx_v_digest_len))); + + /* "polluck_blockchain/placeholder_native.pyx":248 + * ossl.EVP_DigestFinal_ex(ctx, digest, &digest_len) + * + * digest_size[0] = dig_buff_len # <<<<<<<<<<<<<< + * + * ossl.EVP_MD_CTX_free(ctx) +*/ + (__pyx_v_digest_size[0]) = __pyx_v_dig_buff_len; + + /* "polluck_blockchain/placeholder_native.pyx":250 + * digest_size[0] = dig_buff_len + * + * ossl.EVP_MD_CTX_free(ctx) # <<<<<<<<<<<<<< + * + * return digest +*/ + EVP_MD_CTX_free(__pyx_v_ctx); + + /* "polluck_blockchain/placeholder_native.pyx":252 + * ossl.EVP_MD_CTX_free(ctx) + * + * return digest # <<<<<<<<<<<<<< + * + * def bytes_serialize(self): +*/ + __pyx_r = __pyx_v_digest; + goto __pyx_L0; + + /* "polluck_blockchain/placeholder_native.pyx":229 + * return buf + * + * cdef unsigned char* digest(self, unsigned char *data, size_t data_size, size_t *digest_size) nogil: # <<<<<<<<<<<<<< + * cdef ossl.EVP_MD_CTX *ctx = ossl.EVP_MD_CTX_new() + * if ctx == NULL: +*/ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "polluck_blockchain/placeholder_native.pyx":254 + * return digest + * * def bytes_serialize(self): # <<<<<<<<<<<<<< * cdef: * unsigned char *serialize_res @@ -5000,7 +5498,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_10b int __pyx_clineno = 0; __Pyx_RefNannySetupContext("bytes_serialize", 0); - /* "polluck_blockchain/placeholder_native.pyx":211 + /* "polluck_blockchain/placeholder_native.pyx":258 * unsigned char *serialize_res * size_t serialize_size * try: # <<<<<<<<<<<<<< @@ -5009,17 +5507,17 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_10b */ /*try:*/ { - /* "polluck_blockchain/placeholder_native.pyx":212 + /* "polluck_blockchain/placeholder_native.pyx":259 * size_t serialize_size * try: * serialize_res = self.bytes_serialize_c(&serialize_size) # <<<<<<<<<<<<<< * return serialize_res[:serialize_size] * finally: */ - __pyx_t_1 = ((struct __pyx_vtabstruct_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_v_self->__pyx_vtab)->bytes_serialize_c(__pyx_v_self, (&__pyx_v_serialize_size)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 212, __pyx_L4_error) + __pyx_t_1 = ((struct __pyx_vtabstruct_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_v_self->__pyx_vtab)->bytes_serialize_c(__pyx_v_self, (&__pyx_v_serialize_size)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 259, __pyx_L4_error) __pyx_v_serialize_res = __pyx_t_1; - /* "polluck_blockchain/placeholder_native.pyx":213 + /* "polluck_blockchain/placeholder_native.pyx":260 * try: * serialize_res = self.bytes_serialize_c(&serialize_size) * return serialize_res[:serialize_size] # <<<<<<<<<<<<<< @@ -5027,19 +5525,19 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_10b * free(serialize_res) */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(((char const *)__pyx_v_serialize_res) + 0, __pyx_v_serialize_size - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 213, __pyx_L4_error) + __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(((char const *)__pyx_v_serialize_res) + 0, __pyx_v_serialize_size - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 260, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L3_return; } - /* "polluck_blockchain/placeholder_native.pyx":215 + /* "polluck_blockchain/placeholder_native.pyx":262 * return serialize_res[:serialize_size] * finally: * free(serialize_res) # <<<<<<<<<<<<<< * - * cdef unsigned char* digest(self, unsigned char *data, size_t data_size, size_t *digest_size): + * cpdef mine(self, unsigned int difficulty, unsigned int max_nonce=0xFFFFFFFF): */ /*finally:*/ { __pyx_L4_error:; @@ -5082,8 +5580,8 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_10b } } - /* "polluck_blockchain/placeholder_native.pyx":207 - * return buf + /* "polluck_blockchain/placeholder_native.pyx":254 + * return digest * * def bytes_serialize(self): # <<<<<<<<<<<<<< * cdef: @@ -5101,165 +5599,622 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_10b return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":217 +/* "polluck_blockchain/placeholder_native.pyx":264 * free(serialize_res) * - * cdef unsigned char* digest(self, unsigned char *data, size_t data_size, size_t *digest_size): # <<<<<<<<<<<<<< - * cdef ossl.EVP_MD_CTX *ctx = ossl.EVP_MD_CTX_new() - * if ctx == NULL: + * cpdef mine(self, unsigned int difficulty, unsigned int max_nonce=0xFFFFFFFF): # <<<<<<<<<<<<<< + * cdef: + * unsigned char *serial_buf */ -static unsigned char *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_digest(CYTHON_UNUSED struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self, unsigned char *__pyx_v_data, size_t __pyx_v_data_size, size_t *__pyx_v_digest_size) { - EVP_MD_CTX *__pyx_v_ctx; - EVP_MD const *__pyx_v_algo; +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_13mine(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 PyObject *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_mine(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self, unsigned int __pyx_v_difficulty, int __pyx_skip_dispatch, struct __pyx_opt_args_18polluck_blockchain_18placeholder_native_7PyBlock_mine *__pyx_optional_args) { + unsigned int __pyx_v_max_nonce = ((unsigned int)0xFFFFFFFF); + unsigned char *__pyx_v_serial_buf; + size_t __pyx_v_serialize_size; unsigned char *__pyx_v_digest; - size_t __pyx_v_dig_buff_len; - unsigned int __pyx_v_digest_len; - unsigned char *__pyx_r; - int __pyx_t_1; + size_t __pyx_v_digest_size; + int __pyx_v_nonce_found; + int __pyx_v_nonce; + int __pyx_v_nonce_solution; + int *__pyx_v_p_nonce_found; + int *__pyx_v_p_nonce_solution; + 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; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + size_t __pyx_t_7; + unsigned char *__pyx_t_8; + unsigned int __pyx_t_9; + unsigned int __pyx_t_10; + unsigned int __pyx_t_11; + int __pyx_t_12; + int __pyx_t_13; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("mine", 0); + if (__pyx_optional_args) { + if (__pyx_optional_args->__pyx_n > 0) { + __pyx_v_max_nonce = __pyx_optional_args->max_nonce; + } + } + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if ( + #if !CYTHON_USE_TYPE_SLOTS + unlikely(Py_TYPE(((PyObject *)__pyx_v_self)) != __pyx_mstate_global->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock && + __Pyx_PyType_HasFeature(Py_TYPE(((PyObject *)__pyx_v_self)), Py_TPFLAGS_HAVE_GC)) + #else + unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0 || __Pyx_PyType_HasFeature(Py_TYPE(((PyObject *)__pyx_v_self)), (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE))) + #endif + ) { + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { + PY_UINT64_T __pyx_typedict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + #endif + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_mstate_global->__pyx_n_u_mine); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 264, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!__Pyx_IsSameCFunction(__pyx_t_1, (void(*)(void)) __pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_13mine)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = NULL; + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; + __pyx_t_5 = __Pyx_PyLong_From_unsigned_int(__pyx_v_difficulty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 264, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = __Pyx_PyLong_From_unsigned_int(__pyx_v_max_nonce); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 264, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = 1; + #if CYTHON_UNPACK_METHODS + if (unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); + assert(__pyx_t_3); + PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(__pyx__function); + __Pyx_DECREF_SET(__pyx_t_4, __pyx__function); + __pyx_t_7 = 0; + } + #endif + { + PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_t_5, __pyx_t_6}; + __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 264, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + } + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); + if (unlikely(__pyx_typedict_guard != __pyx_tp_dict_version)) { + __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + } + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + } + #endif + } - /* "polluck_blockchain/placeholder_native.pyx":218 - * - * cdef unsigned char* digest(self, unsigned char *data, size_t data_size, size_t *digest_size): - * cdef ossl.EVP_MD_CTX *ctx = ossl.EVP_MD_CTX_new() # <<<<<<<<<<<<<< - * if ctx == NULL: - * raise MemoryError() + /* "polluck_blockchain/placeholder_native.pyx":270 + * unsigned char *digest + * size_t digest_size + * bint nonce_found = False # <<<<<<<<<<<<<< + * int nonce, nonce_solution = 0 + * bint *p_nonce_found = &nonce_found */ - __pyx_v_ctx = EVP_MD_CTX_new(); + __pyx_v_nonce_found = 0; - /* "polluck_blockchain/placeholder_native.pyx":219 - * cdef unsigned char* digest(self, unsigned char *data, size_t data_size, size_t *digest_size): - * cdef ossl.EVP_MD_CTX *ctx = ossl.EVP_MD_CTX_new() - * if ctx == NULL: # <<<<<<<<<<<<<< - * raise MemoryError() - * cdef const ossl.EVP_MD *algo = ossl.EVP_sha256() + /* "polluck_blockchain/placeholder_native.pyx":271 + * size_t digest_size + * bint nonce_found = False + * int nonce, nonce_solution = 0 # <<<<<<<<<<<<<< + * bint *p_nonce_found = &nonce_found + * int *p_nonce_solution = &nonce_solution */ - __pyx_t_1 = (__pyx_v_ctx == NULL); - if (unlikely(__pyx_t_1)) { + __pyx_v_nonce_solution = 0; - /* "polluck_blockchain/placeholder_native.pyx":220 - * cdef ossl.EVP_MD_CTX *ctx = ossl.EVP_MD_CTX_new() - * if ctx == NULL: - * raise MemoryError() # <<<<<<<<<<<<<< - * cdef const ossl.EVP_MD *algo = ossl.EVP_sha256() + /* "polluck_blockchain/placeholder_native.pyx":272 + * bint nonce_found = False + * int nonce, nonce_solution = 0 + * bint *p_nonce_found = &nonce_found # <<<<<<<<<<<<<< + * int *p_nonce_solution = &nonce_solution * */ - PyErr_NoMemory(); __PYX_ERR(0, 220, __pyx_L1_error) + __pyx_v_p_nonce_found = (&__pyx_v_nonce_found); - /* "polluck_blockchain/placeholder_native.pyx":219 - * cdef unsigned char* digest(self, unsigned char *data, size_t data_size, size_t *digest_size): - * cdef ossl.EVP_MD_CTX *ctx = ossl.EVP_MD_CTX_new() - * if ctx == NULL: # <<<<<<<<<<<<<< - * raise MemoryError() - * cdef const ossl.EVP_MD *algo = ossl.EVP_sha256() + /* "polluck_blockchain/placeholder_native.pyx":273 + * int nonce, nonce_solution = 0 + * bint *p_nonce_found = &nonce_found + * int *p_nonce_solution = &nonce_solution # <<<<<<<<<<<<<< + * + * serial_buf = self.bytes_serialize_c(&serialize_size) +*/ + __pyx_v_p_nonce_solution = (&__pyx_v_nonce_solution); + + /* "polluck_blockchain/placeholder_native.pyx":275 + * int *p_nonce_solution = &nonce_solution + * + * serial_buf = self.bytes_serialize_c(&serialize_size) # <<<<<<<<<<<<<< + * + * for nonce in prange(max_nonce, nogil=True, schedule="static", num_threads=16): +*/ + __pyx_t_8 = ((struct __pyx_vtabstruct_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_v_self->__pyx_vtab)->bytes_serialize_c(__pyx_v_self, (&__pyx_v_serialize_size)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 275, __pyx_L1_error) + __pyx_v_serial_buf = __pyx_t_8; + + /* "polluck_blockchain/placeholder_native.pyx":277 + * serial_buf = self.bytes_serialize_c(&serialize_size) + * + * for nonce in prange(max_nonce, nogil=True, schedule="static", num_threads=16): # <<<<<<<<<<<<<< + * if p_nonce_found[0]: + * break +*/ + { + PyThreadState * _save; + _save = PyEval_SaveThread(); + __Pyx_FastGIL_Remember(); + /*try:*/ { + __pyx_t_9 = __pyx_v_max_nonce; + { + const char *__pyx_parallel_filename = NULL; int __pyx_parallel_lineno = 0, __pyx_parallel_clineno = 0; + PyObject *__pyx_parallel_exc_type = NULL, *__pyx_parallel_exc_value = NULL, *__pyx_parallel_exc_tb = NULL; + #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING + PyMutex __pyx_parallel_freethreading_mutex = {0}; + #endif + int __pyx_parallel_why; + __pyx_parallel_why = 0; + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + #undef likely + #undef unlikely + #define likely(x) (x) + #define unlikely(x) (x) + #endif + __pyx_t_11 = (__pyx_t_9 - 0 + 1 - 1/abs(1)) / 1; + if (__pyx_t_11 > 0) + { + #ifdef _OPENMP + #pragma omp parallel num_threads(16) private(__pyx_t_12, __pyx_t_13, __pyx_t_8) __Pyx_shared_in_cpython_freethreading(__pyx_parallel_freethreading_mutex) private(__pyx_filename, __pyx_lineno, __pyx_clineno) shared(__pyx_parallel_why, __pyx_parallel_exc_type, __pyx_parallel_exc_value, __pyx_parallel_exc_tb) + #endif /* _OPENMP */ + { + #ifdef _OPENMP + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + Py_BEGIN_ALLOW_THREADS + #endif /* _OPENMP */ + #ifdef _OPENMP + #pragma omp for firstprivate(__pyx_v_digest) lastprivate(__pyx_v_digest) firstprivate(__pyx_v_nonce) lastprivate(__pyx_v_nonce) schedule(static) + #endif /* _OPENMP */ + for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_11; __pyx_t_10++){ + if (__pyx_parallel_why < 2) + { + __pyx_v_nonce = (int)(0 + 1 * __pyx_t_10); + + /* "polluck_blockchain/placeholder_native.pyx":278 + * + * for nonce in prange(max_nonce, nogil=True, schedule="static", num_threads=16): + * if p_nonce_found[0]: # <<<<<<<<<<<<<< + * break + * +*/ + if ((__pyx_v_p_nonce_found[0])) { + + /* "polluck_blockchain/placeholder_native.pyx":279 + * for nonce in prange(max_nonce, nogil=True, schedule="static", num_threads=16): + * if p_nonce_found[0]: + * break # <<<<<<<<<<<<<< + * + * serialize_uint64(serial_buf + NONCE_OFFSET, nonce) +*/ + goto __pyx_L7_break; + + /* "polluck_blockchain/placeholder_native.pyx":278 + * + * for nonce in prange(max_nonce, nogil=True, schedule="static", num_threads=16): + * if p_nonce_found[0]: # <<<<<<<<<<<<<< + * break + * +*/ + } + + /* "polluck_blockchain/placeholder_native.pyx":281 + * break + * + * serialize_uint64(serial_buf + NONCE_OFFSET, nonce) # <<<<<<<<<<<<<< + * digest = self.digest(serial_buf, serialize_size, &digest_size) + * +*/ + __pyx_t_12 = __pyx_f_18polluck_blockchain_18placeholder_native_serialize_uint64((__pyx_v_serial_buf + __pyx_v_18polluck_blockchain_18placeholder_native_NONCE_OFFSET), ((uint64_t)__pyx_v_nonce)); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 281, __pyx_L8_error) + + /* "polluck_blockchain/placeholder_native.pyx":282 + * + * serialize_uint64(serial_buf + NONCE_OFFSET, nonce) + * digest = self.digest(serial_buf, serialize_size, &digest_size) # <<<<<<<<<<<<<< + * + * if has_leading_zero_bits(digest, difficulty): +*/ + __pyx_t_8 = ((struct __pyx_vtabstruct_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_v_self->__pyx_vtab)->digest(__pyx_v_self, __pyx_v_serial_buf, __pyx_v_serialize_size, (&__pyx_v_digest_size)); if (unlikely(__Pyx_ErrOccurredWithGIL())) __PYX_ERR(0, 282, __pyx_L8_error) + __pyx_v_digest = __pyx_t_8; + + /* "polluck_blockchain/placeholder_native.pyx":284 + * digest = self.digest(serial_buf, serialize_size, &digest_size) + * + * if has_leading_zero_bits(digest, difficulty): # <<<<<<<<<<<<<< + * p_nonce_found[0] = True + * p_nonce_solution[0] = nonce +*/ + __pyx_t_13 = __pyx_f_18polluck_blockchain_18placeholder_native_has_leading_zero_bits(__pyx_v_digest, __pyx_v_difficulty); if (unlikely(__pyx_t_13 == ((int)-1) && __Pyx_ErrOccurredWithGIL())) __PYX_ERR(0, 284, __pyx_L8_error) + if (__pyx_t_13) { + + /* "polluck_blockchain/placeholder_native.pyx":285 + * + * if has_leading_zero_bits(digest, difficulty): + * p_nonce_found[0] = True # <<<<<<<<<<<<<< + * p_nonce_solution[0] = nonce + * break +*/ + (__pyx_v_p_nonce_found[0]) = 1; + + /* "polluck_blockchain/placeholder_native.pyx":286 + * if has_leading_zero_bits(digest, difficulty): + * p_nonce_found[0] = True + * p_nonce_solution[0] = nonce # <<<<<<<<<<<<<< + * break + * +*/ + (__pyx_v_p_nonce_solution[0]) = __pyx_v_nonce; + + /* "polluck_blockchain/placeholder_native.pyx":287 + * p_nonce_found[0] = True + * p_nonce_solution[0] = nonce + * break # <<<<<<<<<<<<<< + * + * free(digest) +*/ + goto __pyx_L7_break; + + /* "polluck_blockchain/placeholder_native.pyx":284 + * digest = self.digest(serial_buf, serialize_size, &digest_size) + * + * if has_leading_zero_bits(digest, difficulty): # <<<<<<<<<<<<<< + * p_nonce_found[0] = True + * p_nonce_solution[0] = nonce +*/ + } + + /* "polluck_blockchain/placeholder_native.pyx":289 + * break + * + * free(digest) # <<<<<<<<<<<<<< + * + * # with nogil: +*/ + free(__pyx_v_digest); + goto __pyx_L13; + __pyx_L7_break:; + __pyx_parallel_why = 2; + goto __pyx_L13; + __pyx_L8_error:; + { + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING + PyMutex_Lock(&__pyx_parallel_freethreading_mutex); + #endif + #ifdef _OPENMP + #pragma omp flush(__pyx_parallel_exc_type) + #endif /* _OPENMP */ + if (!__pyx_parallel_exc_type) { + __Pyx_ErrFetchWithState(&__pyx_parallel_exc_type, &__pyx_parallel_exc_value, &__pyx_parallel_exc_tb); + __pyx_parallel_filename = __pyx_filename; __pyx_parallel_lineno = __pyx_lineno; __pyx_parallel_clineno = __pyx_clineno; + __Pyx_GOTREF(__pyx_parallel_exc_type); + } + #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING + PyMutex_Unlock(&__pyx_parallel_freethreading_mutex); + #endif + __Pyx_PyGILState_Release(__pyx_gilstate_save); + } + __pyx_parallel_why = 4; + goto __pyx_L13; + __pyx_L13:; + #ifdef _OPENMP + #pragma omp flush(__pyx_parallel_why) + #endif /* _OPENMP */ + } + } + #ifdef _OPENMP + Py_END_ALLOW_THREADS + #else +{ +PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #endif /* _OPENMP */ + /* Clean up any temporaries */ + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #ifndef _OPENMP +} +#endif /* _OPENMP */ + } + } + if (__pyx_parallel_exc_type) { + /* This may have been overridden by a continue, break or return in another thread. Prefer the error. */ + __pyx_parallel_why = 4; + } + if (__pyx_parallel_why) { + switch (__pyx_parallel_why) { + case 4: + { + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING + PyMutex_Lock(&__pyx_parallel_freethreading_mutex); + #endif + __Pyx_GIVEREF(__pyx_parallel_exc_type); + __Pyx_ErrRestoreWithState(__pyx_parallel_exc_type, __pyx_parallel_exc_value, __pyx_parallel_exc_tb); + __pyx_filename = __pyx_parallel_filename; __pyx_lineno = __pyx_parallel_lineno; __pyx_clineno = __pyx_parallel_clineno; + #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING + PyMutex_Unlock(&__pyx_parallel_freethreading_mutex); + #endif + __Pyx_PyGILState_Release(__pyx_gilstate_save); + } + goto __pyx_L4_error; + } + } + } + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + #undef likely + #undef unlikely + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + #endif + } + + /* "polluck_blockchain/placeholder_native.pyx":277 + * serial_buf = self.bytes_serialize_c(&serialize_size) + * + * for nonce in prange(max_nonce, nogil=True, schedule="static", num_threads=16): # <<<<<<<<<<<<<< + * if p_nonce_found[0]: + * break +*/ + /*finally:*/ { + /*normal exit:*/{ + __Pyx_FastGIL_Forget(); + PyEval_RestoreThread(_save); + goto __pyx_L5; + } + __pyx_L4_error: { + __Pyx_FastGIL_Forget(); + PyEval_RestoreThread(_save); + goto __pyx_L1_error; + } + __pyx_L5:; + } + } + + /* "polluck_blockchain/placeholder_native.pyx":303 + * # free(digest) + * + * if not nonce_found: # <<<<<<<<<<<<<< + * raise RuntimeError("No valid nonce found") + * +*/ + __pyx_t_13 = (!__pyx_v_nonce_found); + if (unlikely(__pyx_t_13)) { + + /* "polluck_blockchain/placeholder_native.pyx":304 + * + * if not nonce_found: + * raise RuntimeError("No valid nonce found") # <<<<<<<<<<<<<< + * + * self.BlockC.nonce = nonce_solution +*/ + __pyx_t_2 = NULL; + __pyx_t_7 = 1; + { + PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_No_valid_nonce_found}; + __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 304, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + } + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(0, 304, __pyx_L1_error) + + /* "polluck_blockchain/placeholder_native.pyx":303 + * # free(digest) + * + * if not nonce_found: # <<<<<<<<<<<<<< + * raise RuntimeError("No valid nonce found") + * */ } - /* "polluck_blockchain/placeholder_native.pyx":221 - * if ctx == NULL: - * raise MemoryError() - * cdef const ossl.EVP_MD *algo = ossl.EVP_sha256() # <<<<<<<<<<<<<< + /* "polluck_blockchain/placeholder_native.pyx":306 + * raise RuntimeError("No valid nonce found") * - * cdef: + * self.BlockC.nonce = nonce_solution # <<<<<<<<<<<<<< + * + * cdef unsigned char* perform_hash_c(self, size_t *digest_size) nogil: */ - __pyx_v_algo = EVP_sha256(); + __pyx_v_self->BlockC->nonce = ((uint64_t)__pyx_v_nonce_solution); - /* "polluck_blockchain/placeholder_native.pyx":228 - * unsigned int digest_len - * - * dig_buff_len = ossl.EVP_MD_size(algo) # <<<<<<<<<<<<<< - * digest = malloc(dig_buff_len * sizeof(unsigned char)) - * ossl.EVP_DigestInit_ex(ctx, algo, NULL) -*/ - __pyx_v_dig_buff_len = ((size_t)EVP_MD_size(__pyx_v_algo)); - - /* "polluck_blockchain/placeholder_native.pyx":229 - * - * dig_buff_len = ossl.EVP_MD_size(algo) - * digest = malloc(dig_buff_len * sizeof(unsigned char)) # <<<<<<<<<<<<<< - * ossl.EVP_DigestInit_ex(ctx, algo, NULL) - * ossl.EVP_DigestUpdate(ctx, data, data_size) -*/ - __pyx_v_digest = ((unsigned char *)malloc((__pyx_v_dig_buff_len * (sizeof(unsigned char))))); - - /* "polluck_blockchain/placeholder_native.pyx":230 - * dig_buff_len = ossl.EVP_MD_size(algo) - * digest = malloc(dig_buff_len * sizeof(unsigned char)) - * ossl.EVP_DigestInit_ex(ctx, algo, NULL) # <<<<<<<<<<<<<< - * ossl.EVP_DigestUpdate(ctx, data, data_size) - * ossl.EVP_DigestFinal_ex(ctx, digest, &digest_len) -*/ - (void)(EVP_DigestInit_ex(__pyx_v_ctx, __pyx_v_algo, NULL)); - - /* "polluck_blockchain/placeholder_native.pyx":231 - * digest = malloc(dig_buff_len * sizeof(unsigned char)) - * ossl.EVP_DigestInit_ex(ctx, algo, NULL) - * ossl.EVP_DigestUpdate(ctx, data, data_size) # <<<<<<<<<<<<<< - * ossl.EVP_DigestFinal_ex(ctx, digest, &digest_len) - * -*/ - (void)(EVP_DigestUpdate(__pyx_v_ctx, __pyx_v_data, __pyx_v_data_size)); - - /* "polluck_blockchain/placeholder_native.pyx":232 - * ossl.EVP_DigestInit_ex(ctx, algo, NULL) - * ossl.EVP_DigestUpdate(ctx, data, data_size) - * ossl.EVP_DigestFinal_ex(ctx, digest, &digest_len) # <<<<<<<<<<<<<< - * - * digest_size[0] = dig_buff_len -*/ - (void)(EVP_DigestFinal_ex(__pyx_v_ctx, __pyx_v_digest, (&__pyx_v_digest_len))); - - /* "polluck_blockchain/placeholder_native.pyx":234 - * ossl.EVP_DigestFinal_ex(ctx, digest, &digest_len) - * - * digest_size[0] = dig_buff_len # <<<<<<<<<<<<<< - * - * ossl.EVP_MD_CTX_free(ctx) -*/ - (__pyx_v_digest_size[0]) = __pyx_v_dig_buff_len; - - /* "polluck_blockchain/placeholder_native.pyx":236 - * digest_size[0] = dig_buff_len - * - * ossl.EVP_MD_CTX_free(ctx) # <<<<<<<<<<<<<< - * - * return digest -*/ - EVP_MD_CTX_free(__pyx_v_ctx); - - /* "polluck_blockchain/placeholder_native.pyx":238 - * ossl.EVP_MD_CTX_free(ctx) - * - * return digest # <<<<<<<<<<<<<< - * - * cdef unsigned char* perform_hash_c(self, size_t *digest_size): -*/ - __pyx_r = __pyx_v_digest; - goto __pyx_L0; - - /* "polluck_blockchain/placeholder_native.pyx":217 + /* "polluck_blockchain/placeholder_native.pyx":264 * free(serialize_res) * - * cdef unsigned char* digest(self, unsigned char *data, size_t data_size, size_t *digest_size): # <<<<<<<<<<<<<< - * cdef ossl.EVP_MD_CTX *ctx = ossl.EVP_MD_CTX_new() - * if ctx == NULL: + * cpdef mine(self, unsigned int difficulty, unsigned int max_nonce=0xFFFFFFFF): # <<<<<<<<<<<<<< + * cdef: + * unsigned char *serial_buf */ /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; __pyx_L1_error:; - __Pyx_AddTraceback("polluck_blockchain.placeholder_native.PyBlock.digest", __pyx_clineno, __pyx_lineno, __pyx_filename); + __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_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("polluck_blockchain.placeholder_native.PyBlock.mine", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":240 - * return digest +/* Python wrapper */ +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_13mine(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_7PyBlock_13mine = {"mine", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_13mine, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_13mine(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 +) { + unsigned int __pyx_v_difficulty; + unsigned int __pyx_v_max_nonce; + #if !CYTHON_METH_FASTCALL + CYTHON_UNUSED Py_ssize_t __pyx_nargs; + #endif + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject* values[2] = {0,0}; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("mine (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_difficulty,&__pyx_mstate_global->__pyx_n_u_max_nonce,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, 264, __pyx_L3_error) + if (__pyx_kwds_len > 0) { + switch (__pyx_nargs) { + case 2: + values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 264, __pyx_L3_error) + CYTHON_FALLTHROUGH; + case 1: + values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 264, __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, "mine", 0) < (0)) __PYX_ERR(0, 264, __pyx_L3_error) + for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("mine", 0, 1, 2, i); __PYX_ERR(0, 264, __pyx_L3_error) } + } + } else { + switch (__pyx_nargs) { + case 2: + values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 264, __pyx_L3_error) + CYTHON_FALLTHROUGH; + case 1: + values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 264, __pyx_L3_error) + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_difficulty = __Pyx_PyLong_As_unsigned_int(values[0]); if (unlikely((__pyx_v_difficulty == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 264, __pyx_L3_error) + if (values[1]) { + __pyx_v_max_nonce = __Pyx_PyLong_As_unsigned_int(values[1]); if (unlikely((__pyx_v_max_nonce == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 264, __pyx_L3_error) + } else { + __pyx_v_max_nonce = ((unsigned int)0xFFFFFFFF); + } + } + goto __pyx_L6_skip; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("mine", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 264, __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.PyBlock.mine", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_12mine(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_v_self), __pyx_v_difficulty, __pyx_v_max_nonce); + + /* 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_7PyBlock_12mine(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self, unsigned int __pyx_v_difficulty, unsigned int __pyx_v_max_nonce) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + struct __pyx_opt_args_18polluck_blockchain_18placeholder_native_7PyBlock_mine __pyx_t_2; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("mine", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_2.__pyx_n = 1; + __pyx_t_2.max_nonce = __pyx_v_max_nonce; + __pyx_t_1 = __pyx_vtabptr_18polluck_blockchain_18placeholder_native_PyBlock->mine(__pyx_v_self, __pyx_v_difficulty, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 264, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("polluck_blockchain.placeholder_native.PyBlock.mine", __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":308 + * self.BlockC.nonce = nonce_solution * - * cdef unsigned char* perform_hash_c(self, size_t *digest_size): # <<<<<<<<<<<<<< + * cdef unsigned char* perform_hash_c(self, size_t *digest_size) nogil: # <<<<<<<<<<<<<< * cdef: * unsigned char *serialize_res */ @@ -5270,32 +6225,101 @@ static unsigned char *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock unsigned char *__pyx_v_digest; unsigned char *__pyx_r; unsigned char *__pyx_t_1; + int __pyx_t_2; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; + PyGILState_STATE __pyx_gilstate_save; - /* "polluck_blockchain/placeholder_native.pyx":246 + /* "polluck_blockchain/placeholder_native.pyx":314 * unsigned char *digest * * serialize_res = self.bytes_serialize_c(&serialize_size) # <<<<<<<<<<<<<< - * digest = self.digest(serialize_res, serialize_size, digest_size) - * + * if serialize_res == NULL: + * return NULL */ - __pyx_t_1 = ((struct __pyx_vtabstruct_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_v_self->__pyx_vtab)->bytes_serialize_c(__pyx_v_self, (&__pyx_v_serialize_size)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 246, __pyx_L1_error) + __pyx_t_1 = ((struct __pyx_vtabstruct_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_v_self->__pyx_vtab)->bytes_serialize_c(__pyx_v_self, (&__pyx_v_serialize_size)); if (unlikely(__Pyx_ErrOccurredWithGIL())) __PYX_ERR(0, 314, __pyx_L1_error) __pyx_v_serialize_res = __pyx_t_1; - /* "polluck_blockchain/placeholder_native.pyx":247 + /* "polluck_blockchain/placeholder_native.pyx":315 * * serialize_res = self.bytes_serialize_c(&serialize_size) + * if serialize_res == NULL: # <<<<<<<<<<<<<< + * return NULL + * digest = self.digest(serialize_res, serialize_size, digest_size) +*/ + __pyx_t_2 = (__pyx_v_serialize_res == NULL); + if (__pyx_t_2) { + + /* "polluck_blockchain/placeholder_native.pyx":316 + * serialize_res = self.bytes_serialize_c(&serialize_size) + * if serialize_res == NULL: + * return NULL # <<<<<<<<<<<<<< + * digest = self.digest(serialize_res, serialize_size, digest_size) + * if digest == NULL: +*/ + __pyx_r = NULL; + goto __pyx_L0; + + /* "polluck_blockchain/placeholder_native.pyx":315 + * + * serialize_res = self.bytes_serialize_c(&serialize_size) + * if serialize_res == NULL: # <<<<<<<<<<<<<< + * return NULL + * digest = self.digest(serialize_res, serialize_size, digest_size) +*/ + } + + /* "polluck_blockchain/placeholder_native.pyx":317 + * if serialize_res == NULL: + * return NULL * digest = self.digest(serialize_res, serialize_size, digest_size) # <<<<<<<<<<<<<< + * if digest == NULL: + * return NULL +*/ + __pyx_t_1 = ((struct __pyx_vtabstruct_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_v_self->__pyx_vtab)->digest(__pyx_v_self, __pyx_v_serialize_res, __pyx_v_serialize_size, __pyx_v_digest_size); if (unlikely(__Pyx_ErrOccurredWithGIL())) __PYX_ERR(0, 317, __pyx_L1_error) + __pyx_v_digest = __pyx_t_1; + + /* "polluck_blockchain/placeholder_native.pyx":318 + * return NULL + * digest = self.digest(serialize_res, serialize_size, digest_size) + * if digest == NULL: # <<<<<<<<<<<<<< + * return NULL + * +*/ + __pyx_t_2 = (__pyx_v_digest == NULL); + if (__pyx_t_2) { + + /* "polluck_blockchain/placeholder_native.pyx":319 + * digest = self.digest(serialize_res, serialize_size, digest_size) + * if digest == NULL: + * return NULL # <<<<<<<<<<<<<< + * + * free(serialize_res) +*/ + __pyx_r = NULL; + goto __pyx_L0; + + /* "polluck_blockchain/placeholder_native.pyx":318 + * return NULL + * digest = self.digest(serialize_res, serialize_size, digest_size) + * if digest == NULL: # <<<<<<<<<<<<<< + * return NULL + * +*/ + } + + /* "polluck_blockchain/placeholder_native.pyx":321 + * return NULL + * + * free(serialize_res) # <<<<<<<<<<<<<< * * return digest */ - __pyx_t_1 = ((struct __pyx_vtabstruct_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_v_self->__pyx_vtab)->digest(__pyx_v_self, __pyx_v_serialize_res, __pyx_v_serialize_size, __pyx_v_digest_size); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 247, __pyx_L1_error) - __pyx_v_digest = __pyx_t_1; + free(__pyx_v_serialize_res); - /* "polluck_blockchain/placeholder_native.pyx":249 - * digest = self.digest(serialize_res, serialize_size, digest_size) + /* "polluck_blockchain/placeholder_native.pyx":323 + * free(serialize_res) * * return digest # <<<<<<<<<<<<<< * @@ -5304,23 +6328,25 @@ static unsigned char *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock __pyx_r = __pyx_v_digest; goto __pyx_L0; - /* "polluck_blockchain/placeholder_native.pyx":240 - * return digest + /* "polluck_blockchain/placeholder_native.pyx":308 + * self.BlockC.nonce = nonce_solution * - * cdef unsigned char* perform_hash_c(self, size_t *digest_size): # <<<<<<<<<<<<<< + * cdef unsigned char* perform_hash_c(self, size_t *digest_size) nogil: # <<<<<<<<<<<<<< * cdef: * unsigned char *serialize_res */ /* function exit code */ __pyx_L1_error:; + __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); __Pyx_AddTraceback("polluck_blockchain.placeholder_native.PyBlock.perform_hash_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; + __Pyx_PyGILState_Release(__pyx_gilstate_save); __pyx_L0:; return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":251 +/* "polluck_blockchain/placeholder_native.pyx":325 * return digest * * cpdef perform_hash(self): # <<<<<<<<<<<<<< @@ -5328,7 +6354,7 @@ static unsigned char *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock * unsigned char *digest */ -static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_13perform_hash(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_15perform_hash(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else @@ -5346,17 +6372,18 @@ static PyObject *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_perf PyObject *__pyx_t_4 = NULL; size_t __pyx_t_5; unsigned char *__pyx_t_6; - PyObject *__pyx_t_7 = NULL; - std::string __pyx_t_8; - int __pyx_t_9; + int __pyx_t_7; + PyObject *__pyx_t_8 = NULL; + std::string __pyx_t_9; int __pyx_t_10; - char const *__pyx_t_11; - PyObject *__pyx_t_12 = NULL; + int __pyx_t_11; + char const *__pyx_t_12; PyObject *__pyx_t_13 = NULL; PyObject *__pyx_t_14 = NULL; PyObject *__pyx_t_15 = NULL; PyObject *__pyx_t_16 = NULL; PyObject *__pyx_t_17 = NULL; + PyObject *__pyx_t_18 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -5377,9 +6404,9 @@ static PyObject *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_perf if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { PY_UINT64_T __pyx_typedict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); #endif - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_mstate_global->__pyx_n_u_perform_hash); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 251, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_mstate_global->__pyx_n_u_perform_hash); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 325, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (!__Pyx_IsSameCFunction(__pyx_t_1, (void(*)(void)) __pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_13perform_hash)) { + if (!__Pyx_IsSameCFunction(__pyx_t_1, (void(*)(void)) __pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_15perform_hash)) { __Pyx_XDECREF(__pyx_r); __pyx_t_3 = NULL; __Pyx_INCREF(__pyx_t_1); @@ -5401,7 +6428,7 @@ static PyObject *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_perf __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 251, __pyx_L1_error) + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 325, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __pyx_r = __pyx_t_2; @@ -5422,42 +6449,70 @@ static PyObject *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_perf #endif } - /* "polluck_blockchain/placeholder_native.pyx":256 + /* "polluck_blockchain/placeholder_native.pyx":330 * size_t digest_size * * try: # <<<<<<<<<<<<<< * digest = self.perform_hash_c(&digest_size) - * self.BlockC.hash = bytes(digest[:digest_size]).hex().encode("UTF-8") + * if digest == NULL: */ /*try:*/ { - /* "polluck_blockchain/placeholder_native.pyx":257 + /* "polluck_blockchain/placeholder_native.pyx":331 * * try: * digest = self.perform_hash_c(&digest_size) # <<<<<<<<<<<<<< + * if digest == NULL: + * raise MemoryError() +*/ + __pyx_t_6 = ((struct __pyx_vtabstruct_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_v_self->__pyx_vtab)->perform_hash_c(__pyx_v_self, (&__pyx_v_digest_size)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 331, __pyx_L4_error) + __pyx_v_digest = __pyx_t_6; + + /* "polluck_blockchain/placeholder_native.pyx":332 + * try: + * digest = self.perform_hash_c(&digest_size) + * if digest == NULL: # <<<<<<<<<<<<<< + * raise MemoryError() + * self.BlockC.hash = bytes(digest[:digest_size]).hex().encode("UTF-8") +*/ + __pyx_t_7 = (__pyx_v_digest == NULL); + if (unlikely(__pyx_t_7)) { + + /* "polluck_blockchain/placeholder_native.pyx":333 + * digest = self.perform_hash_c(&digest_size) + * if digest == NULL: + * raise MemoryError() # <<<<<<<<<<<<<< * self.BlockC.hash = bytes(digest[:digest_size]).hex().encode("UTF-8") * finally: */ - __pyx_t_6 = ((struct __pyx_vtabstruct_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_v_self->__pyx_vtab)->perform_hash_c(__pyx_v_self, (&__pyx_v_digest_size)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 257, __pyx_L4_error) - __pyx_v_digest = __pyx_t_6; + PyErr_NoMemory(); __PYX_ERR(0, 333, __pyx_L4_error) - /* "polluck_blockchain/placeholder_native.pyx":258 + /* "polluck_blockchain/placeholder_native.pyx":332 * try: * digest = self.perform_hash_c(&digest_size) + * if digest == NULL: # <<<<<<<<<<<<<< + * raise MemoryError() + * self.BlockC.hash = bytes(digest[:digest_size]).hex().encode("UTF-8") +*/ + } + + /* "polluck_blockchain/placeholder_native.pyx":334 + * if digest == NULL: + * raise MemoryError() * self.BlockC.hash = bytes(digest[:digest_size]).hex().encode("UTF-8") # <<<<<<<<<<<<<< * finally: * free(digest) */ __pyx_t_3 = NULL; - __pyx_t_7 = __Pyx_PyBytes_FromStringAndSize(((char const *)__pyx_v_digest) + 0, __pyx_v_digest_size - 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 258, __pyx_L4_error) - __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = __Pyx_PyBytes_FromStringAndSize(((char const *)__pyx_v_digest) + 0, __pyx_v_digest_size - 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 334, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_8); __pyx_t_5 = 1; { - PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_7}; + PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_8}; __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)(&PyBytes_Type), __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__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_4)) __PYX_ERR(0, 258, __pyx_L4_error) + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 334, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_4); } __pyx_t_2 = __pyx_t_4; @@ -5468,18 +6523,18 @@ static PyObject *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_perf __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_hex, __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_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 258, __pyx_L4_error) + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 334, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); } - __pyx_t_4 = PyUnicode_AsUTF8String(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 258, __pyx_L4_error) + __pyx_t_4 = PyUnicode_AsUTF8String(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 334, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_8 = __pyx_convert_string_from_py_6libcpp_6string_std__in_string(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 258, __pyx_L4_error) + __pyx_t_9 = __pyx_convert_string_from_py_6libcpp_6string_std__in_string(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 334, __pyx_L4_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_v_self->BlockC->hash = __PYX_STD_MOVE_IF_SUPPORTED(__pyx_t_8); + __pyx_v_self->BlockC->hash = __PYX_STD_MOVE_IF_SUPPORTED(__pyx_t_9); } - /* "polluck_blockchain/placeholder_native.pyx":260 + /* "polluck_blockchain/placeholder_native.pyx":336 * self.BlockC.hash = bytes(digest[:digest_size]).hex().encode("UTF-8") * finally: * free(digest) # <<<<<<<<<<<<<< @@ -5495,40 +6550,40 @@ static PyObject *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_perf /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign - __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; + __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17); - if ( unlikely(__Pyx_GetException(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14); - __Pyx_XGOTREF(__pyx_t_12); + __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_ExceptionSwap(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18); + if ( unlikely(__Pyx_GetException(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15) < 0)) __Pyx_ErrFetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15); __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); - __pyx_t_9 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_11 = __pyx_filename; + __Pyx_XGOTREF(__pyx_t_18); + __pyx_t_10 = __pyx_lineno; __pyx_t_11 = __pyx_clineno; __pyx_t_12 = __pyx_filename; { free(__pyx_v_digest); } - __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); - __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17); - __Pyx_XGIVEREF(__pyx_t_12); + __Pyx_XGIVEREF(__pyx_t_18); + __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); - __Pyx_ErrRestore(__pyx_t_12, __pyx_t_13, __pyx_t_14); - __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; - __pyx_lineno = __pyx_t_9; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_11; + __Pyx_XGIVEREF(__pyx_t_15); + __Pyx_ErrRestore(__pyx_t_13, __pyx_t_14, __pyx_t_15); + __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; + __pyx_lineno = __pyx_t_10; __pyx_clineno = __pyx_t_11; __pyx_filename = __pyx_t_12; goto __pyx_L1_error; } __pyx_L5:; } - /* "polluck_blockchain/placeholder_native.pyx":262 + /* "polluck_blockchain/placeholder_native.pyx":338 * free(digest) * * return self.hash # <<<<<<<<<<<<<< @@ -5536,13 +6591,13 @@ static PyObject *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_perf * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_mstate_global->__pyx_n_u_hash); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 262, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_mstate_global->__pyx_n_u_hash); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 338, __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":251 + /* "polluck_blockchain/placeholder_native.pyx":325 * return digest * * cpdef perform_hash(self): # <<<<<<<<<<<<<< @@ -5556,7 +6611,7 @@ static PyObject *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_perf __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("polluck_blockchain.placeholder_native.PyBlock.perform_hash", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; @@ -5566,15 +6621,15 @@ static PyObject *__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_perf } /* Python wrapper */ -static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_13perform_hash(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_15perform_hash(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_7PyBlock_13perform_hash = {"perform_hash", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_13perform_hash, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_13perform_hash(PyObject *__pyx_v_self, +static PyMethodDef __pyx_mdef_18polluck_blockchain_18placeholder_native_7PyBlock_15perform_hash = {"perform_hash", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_15perform_hash, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_15perform_hash(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else @@ -5600,14 +6655,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("perform_hash", __pyx_kwds); return NULL;} - __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_12perform_hash(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_v_self)); + __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_14perform_hash(((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_12perform_hash(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self) { +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_14perform_hash(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -5616,7 +6671,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_12p int __pyx_clineno = 0; __Pyx_RefNannySetupContext("perform_hash", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_perform_hash(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 251, __pyx_L1_error) + __pyx_t_1 = __pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_perform_hash(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 325, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -5640,15 +6695,15 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_12p */ /* Python wrapper */ -static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_15__reduce_cython__(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_17__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_7PyBlock_15__reduce_cython__ = {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_15__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_15__reduce_cython__(PyObject *__pyx_v_self, +static PyMethodDef __pyx_mdef_18polluck_blockchain_18placeholder_native_7PyBlock_17__reduce_cython__ = {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_17__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_17__reduce_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else @@ -5674,14 +6729,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_7PyBlock_14__reduce_cython__(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_v_self)); + __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_16__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_7PyBlock_14__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self) { +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_16__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; @@ -5721,15 +6776,15 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_14_ */ /* Python wrapper */ -static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_17__setstate_cython__(PyObject *__pyx_v_self, +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_19__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_7PyBlock_17__setstate_cython__ = {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_17__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_17__setstate_cython__(PyObject *__pyx_v_self, +static PyMethodDef __pyx_mdef_18polluck_blockchain_18placeholder_native_7PyBlock_19__setstate_cython__ = {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_19__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_19__setstate_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else @@ -5795,7 +6850,7 @@ PyObject *__pyx_args, PyObject *__pyx_kwds __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_16__setstate_cython__(((struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_v_self), __pyx_v___pyx_state); + __pyx_r = __pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_18__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) { @@ -5805,7 +6860,7 @@ PyObject *__pyx_args, PyObject *__pyx_kwds return __pyx_r; } -static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_16__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { +static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_18__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; @@ -5837,7 +6892,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_7PyBlock_16_ return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":285 +/* "polluck_blockchain/placeholder_native.pyx":361 * cdef bint _genesis_done * * def __cinit__(self): # <<<<<<<<<<<<<< @@ -5883,7 +6938,7 @@ static int __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain___cin int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "polluck_blockchain/placeholder_native.pyx":286 + /* "polluck_blockchain/placeholder_native.pyx":362 * * def __cinit__(self): * self._difficulty = 1 # <<<<<<<<<<<<<< @@ -5892,7 +6947,7 @@ static int __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain___cin */ __pyx_v_self->_difficulty = 1; - /* "polluck_blockchain/placeholder_native.pyx":287 + /* "polluck_blockchain/placeholder_native.pyx":363 * def __cinit__(self): * self._difficulty = 1 * self._index = 0 # <<<<<<<<<<<<<< @@ -5901,7 +6956,7 @@ static int __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain___cin */ __pyx_v_self->_index = ((uint64_t)0); - /* "polluck_blockchain/placeholder_native.pyx":288 + /* "polluck_blockchain/placeholder_native.pyx":364 * self._difficulty = 1 * self._index = 0 * self._genesis_done = 0 # <<<<<<<<<<<<<< @@ -5910,7 +6965,7 @@ static int __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain___cin */ __pyx_v_self->_genesis_done = 0; - /* "polluck_blockchain/placeholder_native.pyx":289 + /* "polluck_blockchain/placeholder_native.pyx":365 * self._index = 0 * self._genesis_done = 0 * self._chain = new unordered_map[uint64_t, Block*]() # <<<<<<<<<<<<<< @@ -5921,11 +6976,11 @@ static int __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain___cin __pyx_t_1 = new std::unordered_map (); } catch(...) { __Pyx_CppExn2PyErr(); - __PYX_ERR(0, 289, __pyx_L1_error) + __PYX_ERR(0, 365, __pyx_L1_error) } __pyx_v_self->_chain = __pyx_t_1; - /* "polluck_blockchain/placeholder_native.pyx":290 + /* "polluck_blockchain/placeholder_native.pyx":366 * self._genesis_done = 0 * self._chain = new unordered_map[uint64_t, Block*]() * if self._chain is NULL: # <<<<<<<<<<<<<< @@ -5935,7 +6990,7 @@ static int __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain___cin __pyx_t_2 = (__pyx_v_self->_chain == NULL); if (unlikely(__pyx_t_2)) { - /* "polluck_blockchain/placeholder_native.pyx":291 + /* "polluck_blockchain/placeholder_native.pyx":367 * self._chain = new unordered_map[uint64_t, Block*]() * if self._chain is NULL: * raise MemoryError("Could not allocate hasmap") # <<<<<<<<<<<<<< @@ -5948,14 +7003,14 @@ static int __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain___cin 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, 291, __pyx_L1_error) + if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 367, __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, 291, __pyx_L1_error) + __PYX_ERR(0, 367, __pyx_L1_error) - /* "polluck_blockchain/placeholder_native.pyx":290 + /* "polluck_blockchain/placeholder_native.pyx":366 * self._genesis_done = 0 * self._chain = new unordered_map[uint64_t, Block*]() * if self._chain is NULL: # <<<<<<<<<<<<<< @@ -5964,7 +7019,7 @@ static int __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain___cin */ } - /* "polluck_blockchain/placeholder_native.pyx":285 + /* "polluck_blockchain/placeholder_native.pyx":361 * cdef bint _genesis_done * * def __cinit__(self): # <<<<<<<<<<<<<< @@ -5985,7 +7040,7 @@ static int __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain___cin return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":293 +/* "polluck_blockchain/placeholder_native.pyx":369 * raise MemoryError("Could not allocate hasmap") * * def __init__(self, *args, **kwargs): # <<<<<<<<<<<<<< @@ -6033,7 +7088,7 @@ static int __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_2__in return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":296 +/* "polluck_blockchain/placeholder_native.pyx":372 * pass * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -6058,7 +7113,7 @@ static void __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_4__d std::unordered_map ::iterator __pyx_v_it; int __pyx_t_1; - /* "polluck_blockchain/placeholder_native.pyx":298 + /* "polluck_blockchain/placeholder_native.pyx":374 * def __dealloc__(self): * # ownership is typically not transferred from the Blockchain extension class * cdef BcHashmap.iterator it = self._chain.begin() # <<<<<<<<<<<<<< @@ -6067,7 +7122,7 @@ static void __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_4__d */ __pyx_v_it = __pyx_v_self->_chain->begin(); - /* "polluck_blockchain/placeholder_native.pyx":299 + /* "polluck_blockchain/placeholder_native.pyx":375 * # ownership is typically not transferred from the Blockchain extension class * cdef BcHashmap.iterator it = self._chain.begin() * if self._chain is not NULL: # <<<<<<<<<<<<<< @@ -6077,7 +7132,7 @@ static void __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_4__d __pyx_t_1 = (__pyx_v_self->_chain != NULL); if (__pyx_t_1) { - /* "polluck_blockchain/placeholder_native.pyx":300 + /* "polluck_blockchain/placeholder_native.pyx":376 * cdef BcHashmap.iterator it = self._chain.begin() * if self._chain is not NULL: * while it != self._chain.end(): # <<<<<<<<<<<<<< @@ -6088,7 +7143,7 @@ static void __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_4__d __pyx_t_1 = (__pyx_v_it != __pyx_v_self->_chain->end()); if (!__pyx_t_1) break; - /* "polluck_blockchain/placeholder_native.pyx":301 + /* "polluck_blockchain/placeholder_native.pyx":377 * if self._chain is not NULL: * while it != self._chain.end(): * del dereference(it).second # <<<<<<<<<<<<<< @@ -6097,7 +7152,7 @@ static void __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_4__d */ delete (*__pyx_v_it).second; - /* "polluck_blockchain/placeholder_native.pyx":302 + /* "polluck_blockchain/placeholder_native.pyx":378 * while it != self._chain.end(): * del dereference(it).second * postincrement(it) # <<<<<<<<<<<<<< @@ -6107,7 +7162,7 @@ static void __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_4__d (void)((__pyx_v_it++)); } - /* "polluck_blockchain/placeholder_native.pyx":304 + /* "polluck_blockchain/placeholder_native.pyx":380 * postincrement(it) * * del self._chain # <<<<<<<<<<<<<< @@ -6116,7 +7171,7 @@ static void __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_4__d */ delete __pyx_v_self->_chain; - /* "polluck_blockchain/placeholder_native.pyx":305 + /* "polluck_blockchain/placeholder_native.pyx":381 * * del self._chain * self._chain = NULL # <<<<<<<<<<<<<< @@ -6125,7 +7180,7 @@ static void __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_4__d */ __pyx_v_self->_chain = NULL; - /* "polluck_blockchain/placeholder_native.pyx":299 + /* "polluck_blockchain/placeholder_native.pyx":375 * # ownership is typically not transferred from the Blockchain extension class * cdef BcHashmap.iterator it = self._chain.begin() * if self._chain is not NULL: # <<<<<<<<<<<<<< @@ -6134,7 +7189,7 @@ static void __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_4__d */ } - /* "polluck_blockchain/placeholder_native.pyx":296 + /* "polluck_blockchain/placeholder_native.pyx":372 * pass * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -6145,7 +7200,7 @@ static void __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain_4__d /* function exit code */ } -/* "polluck_blockchain/placeholder_native.pyx":307 +/* "polluck_blockchain/placeholder_native.pyx":383 * self._chain = NULL * * def __len__(self): # <<<<<<<<<<<<<< @@ -6171,7 +7226,7 @@ static Py_ssize_t __pyx_pw_18polluck_blockchain_18placeholder_native_10Blockchai 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":308 + /* "polluck_blockchain/placeholder_native.pyx":384 * * def __len__(self): * return self._index + 1 # <<<<<<<<<<<<<< @@ -6181,7 +7236,7 @@ static Py_ssize_t __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchai __pyx_r = (__pyx_v_self->_index + 1); goto __pyx_L0; - /* "polluck_blockchain/placeholder_native.pyx":307 + /* "polluck_blockchain/placeholder_native.pyx":383 * self._chain = NULL * * def __len__(self): # <<<<<<<<<<<<<< @@ -6194,7 +7249,7 @@ static Py_ssize_t __pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchai return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":310 +/* "polluck_blockchain/placeholder_native.pyx":386 * return self._index + 1 * * def print_key_value_pair(self): # <<<<<<<<<<<<<< @@ -6261,7 +7316,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain int __pyx_clineno = 0; __Pyx_RefNannySetupContext("print_key_value_pair", 0); - /* "polluck_blockchain/placeholder_native.pyx":311 + /* "polluck_blockchain/placeholder_native.pyx":387 * * def print_key_value_pair(self): * cdef BcHashmap.iterator it = self._chain.begin() # <<<<<<<<<<<<<< @@ -6270,7 +7325,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain */ __pyx_v_it = __pyx_v_self->_chain->begin(); - /* "polluck_blockchain/placeholder_native.pyx":313 + /* "polluck_blockchain/placeholder_native.pyx":389 * cdef BcHashmap.iterator it = self._chain.begin() * cdef Block *block * while it != self._chain.end(): # <<<<<<<<<<<<<< @@ -6281,7 +7336,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain __pyx_t_1 = (__pyx_v_it != __pyx_v_self->_chain->end()); if (!__pyx_t_1) break; - /* "polluck_blockchain/placeholder_native.pyx":314 + /* "polluck_blockchain/placeholder_native.pyx":390 * cdef Block *block * while it != self._chain.end(): * print(dereference(it).first) # <<<<<<<<<<<<<< @@ -6289,7 +7344,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain * py_block = PyBlock.from_ptr(block) */ __pyx_t_3 = NULL; - __pyx_t_4 = __Pyx_PyLong_From_uint64_t((*__pyx_v_it).first); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 314, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyLong_From_uint64_t((*__pyx_v_it).first); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 390, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = 1; { @@ -6297,12 +7352,12 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_builtin_print, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 314, __pyx_L1_error) + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 390, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "polluck_blockchain/placeholder_native.pyx":315 + /* "polluck_blockchain/placeholder_native.pyx":391 * while it != self._chain.end(): * print(dereference(it).first) * block = dereference(it).second # <<<<<<<<<<<<<< @@ -6312,19 +7367,19 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain __pyx_t_6 = (*__pyx_v_it).second; __pyx_v_block = __pyx_t_6; - /* "polluck_blockchain/placeholder_native.pyx":316 + /* "polluck_blockchain/placeholder_native.pyx":392 * print(dereference(it).first) * block = dereference(it).second * py_block = PyBlock.from_ptr(block) # <<<<<<<<<<<<<< * print(py_block) * postincrement(it) */ - __pyx_t_2 = ((PyObject *)__pyx_vtabptr_18polluck_blockchain_18placeholder_native_PyBlock->from_ptr(__pyx_v_block, NULL)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 316, __pyx_L1_error) + __pyx_t_2 = ((PyObject *)__pyx_vtabptr_18polluck_blockchain_18placeholder_native_PyBlock->from_ptr(__pyx_v_block, NULL)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 392, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_XDECREF_SET(__pyx_v_py_block, ((struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *)__pyx_t_2)); __pyx_t_2 = 0; - /* "polluck_blockchain/placeholder_native.pyx":317 + /* "polluck_blockchain/placeholder_native.pyx":393 * block = dereference(it).second * py_block = PyBlock.from_ptr(block) * print(py_block) # <<<<<<<<<<<<<< @@ -6337,12 +7392,12 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain PyObject *__pyx_callargs[2] = {__pyx_t_4, ((PyObject *)__pyx_v_py_block)}; __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_builtin_print, __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_2)) __PYX_ERR(0, 317, __pyx_L1_error) + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "polluck_blockchain/placeholder_native.pyx":318 + /* "polluck_blockchain/placeholder_native.pyx":394 * py_block = PyBlock.from_ptr(block) * print(py_block) * postincrement(it) # <<<<<<<<<<<<<< @@ -6352,7 +7407,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain (void)((__pyx_v_it++)); } - /* "polluck_blockchain/placeholder_native.pyx":310 + /* "polluck_blockchain/placeholder_native.pyx":386 * return self._index + 1 * * def print_key_value_pair(self): # <<<<<<<<<<<<<< @@ -6376,7 +7431,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":320 +/* "polluck_blockchain/placeholder_native.pyx":396 * postincrement(it) * * @property # <<<<<<<<<<<<<< @@ -6408,7 +7463,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "polluck_blockchain/placeholder_native.pyx":322 + /* "polluck_blockchain/placeholder_native.pyx":398 * @property * def genesis_done(self): * return self._genesis_done # <<<<<<<<<<<<<< @@ -6416,13 +7471,13 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_genesis_done); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 322, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_genesis_done); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 398, __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":320 + /* "polluck_blockchain/placeholder_native.pyx":396 * postincrement(it) * * @property # <<<<<<<<<<<<<< @@ -6441,7 +7496,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":324 +/* "polluck_blockchain/placeholder_native.pyx":400 * return self._genesis_done * * @property # <<<<<<<<<<<<<< @@ -6473,7 +7528,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "polluck_blockchain/placeholder_native.pyx":326 + /* "polluck_blockchain/placeholder_native.pyx":402 * @property * def index(self): * return self._index # <<<<<<<<<<<<<< @@ -6481,13 +7536,13 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain * # 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, 326, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyLong_From_uint64_t(__pyx_v_self->_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 402, __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":324 + /* "polluck_blockchain/placeholder_native.pyx":400 * return self._genesis_done * * @property # <<<<<<<<<<<<<< @@ -6506,7 +7561,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":329 +/* "polluck_blockchain/placeholder_native.pyx":405 * * # TODO error handling * cdef Block* get_block_c(self, uint64_t idx): # <<<<<<<<<<<<<< @@ -6517,7 +7572,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain 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":330 + /* "polluck_blockchain/placeholder_native.pyx":406 * # TODO error handling * cdef Block* get_block_c(self, uint64_t idx): * return self._chain[0][idx] # <<<<<<<<<<<<<< @@ -6527,7 +7582,7 @@ static ::Block *__pyx_f_18polluck_blockchain_18placeholder_native_10Blockchain_g __pyx_r = ((__pyx_v_self->_chain[0])[__pyx_v_idx]); goto __pyx_L0; - /* "polluck_blockchain/placeholder_native.pyx":329 + /* "polluck_blockchain/placeholder_native.pyx":405 * * # TODO error handling * cdef Block* get_block_c(self, uint64_t idx): # <<<<<<<<<<<<<< @@ -6540,7 +7595,7 @@ static ::Block *__pyx_f_18polluck_blockchain_18placeholder_native_10Blockchain_g return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":332 +/* "polluck_blockchain/placeholder_native.pyx":408 * return self._chain[0][idx] * * def get_block(self, idx): # <<<<<<<<<<<<<< @@ -6587,32 +7642,32 @@ PyObject *__pyx_args, PyObject *__pyx_kwds { 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, 332, __pyx_L3_error) + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 408, __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, 332, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 408, __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, 332, __pyx_L3_error) + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "get_block", 0) < (0)) __PYX_ERR(0, 408, __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, 332, __pyx_L3_error) } + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("get_block", 1, 1, 1, i); __PYX_ERR(0, 408, __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, 332, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 408, __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, 332, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("get_block", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 408, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -6650,32 +7705,32 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_block", 0); - /* "polluck_blockchain/placeholder_native.pyx":333 + /* "polluck_blockchain/placeholder_native.pyx":409 * * 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, 333, __pyx_L1_error) - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 333, __pyx_L1_error) + __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, 409, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 409, __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, 333, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyLong_From_uint64_t(__pyx_v_self->_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 409, __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, 333, __pyx_L1_error) + __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, 409, __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, 333, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 409, __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":334 + /* "polluck_blockchain/placeholder_native.pyx":410 * def get_block(self, idx): * if idx < 0 or idx > self._index: * raise IndexError("Index value is out of bounds") # <<<<<<<<<<<<<< @@ -6688,14 +7743,14 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain 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, 334, __pyx_L1_error) + if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 410, __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, 334, __pyx_L1_error) + __PYX_ERR(0, 410, __pyx_L1_error) - /* "polluck_blockchain/placeholder_native.pyx":333 + /* "polluck_blockchain/placeholder_native.pyx":409 * * def get_block(self, idx): * if idx < 0 or idx > self._index: # <<<<<<<<<<<<<< @@ -6704,18 +7759,18 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain */ } - /* "polluck_blockchain/placeholder_native.pyx":336 + /* "polluck_blockchain/placeholder_native.pyx":412 * 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, 336, __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, 336, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyLong_As_uint64_t(__pyx_v_idx); if (unlikely((__pyx_t_6 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 412, __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, 412, __pyx_L1_error) __pyx_v_block = __pyx_t_7; - /* "polluck_blockchain/placeholder_native.pyx":337 + /* "polluck_blockchain/placeholder_native.pyx":413 * * cdef Block *block = self.get_block_c(idx) * return PyBlock.from_ptr(block, owner=False) # <<<<<<<<<<<<<< @@ -6725,13 +7780,13 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain __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, 337, __pyx_L1_error) + __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, 413, __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":332 + /* "polluck_blockchain/placeholder_native.pyx":408 * return self._chain[0][idx] * * def get_block(self, idx): # <<<<<<<<<<<<<< @@ -6751,7 +7806,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":339 +/* "polluck_blockchain/placeholder_native.pyx":415 * return PyBlock.from_ptr(block, owner=False) * * cdef void add_block(self, Block *block): # <<<<<<<<<<<<<< @@ -6761,7 +7816,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain 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":340 + /* "polluck_blockchain/placeholder_native.pyx":416 * * cdef void add_block(self, Block *block): * self._chain[0][block.index] = block # <<<<<<<<<<<<<< @@ -6770,7 +7825,7 @@ static void __pyx_f_18polluck_blockchain_18placeholder_native_10Blockchain_add_b */ ((__pyx_v_self->_chain[0])[__pyx_v_block->index]) = __pyx_v_block; - /* "polluck_blockchain/placeholder_native.pyx":341 + /* "polluck_blockchain/placeholder_native.pyx":417 * cdef void add_block(self, Block *block): * self._chain[0][block.index] = block * if self._genesis_done: # <<<<<<<<<<<<<< @@ -6779,7 +7834,7 @@ static void __pyx_f_18polluck_blockchain_18placeholder_native_10Blockchain_add_b */ if (__pyx_v_self->_genesis_done) { - /* "polluck_blockchain/placeholder_native.pyx":342 + /* "polluck_blockchain/placeholder_native.pyx":418 * self._chain[0][block.index] = block * if self._genesis_done: * self._index += 1 # <<<<<<<<<<<<<< @@ -6788,7 +7843,7 @@ static void __pyx_f_18polluck_blockchain_18placeholder_native_10Blockchain_add_b */ __pyx_v_self->_index = (__pyx_v_self->_index + 1); - /* "polluck_blockchain/placeholder_native.pyx":341 + /* "polluck_blockchain/placeholder_native.pyx":417 * cdef void add_block(self, Block *block): * self._chain[0][block.index] = block * if self._genesis_done: # <<<<<<<<<<<<<< @@ -6797,7 +7852,7 @@ static void __pyx_f_18polluck_blockchain_18placeholder_native_10Blockchain_add_b */ } - /* "polluck_blockchain/placeholder_native.pyx":339 + /* "polluck_blockchain/placeholder_native.pyx":415 * return PyBlock.from_ptr(block, owner=False) * * cdef void add_block(self, Block *block): # <<<<<<<<<<<<<< @@ -6808,7 +7863,7 @@ static void __pyx_f_18polluck_blockchain_18placeholder_native_10Blockchain_add_b /* function exit code */ } -/* "polluck_blockchain/placeholder_native.pyx":344 +/* "polluck_blockchain/placeholder_native.pyx":420 * self._index += 1 * * def create_genesis_block(self): # <<<<<<<<<<<<<< @@ -6877,19 +7932,19 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain int __pyx_clineno = 0; __Pyx_RefNannySetupContext("create_genesis_block", 0); - /* "polluck_blockchain/placeholder_native.pyx":347 + /* "polluck_blockchain/placeholder_native.pyx":423 * cdef Block *block = new Block( * self._index, * int(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, 347, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 423, __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, 347, __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, 423, __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, 347, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_mstate_global->__pyx_tuple[0], NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 423, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_2 = __pyx_t_3; @@ -6900,43 +7955,43 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain __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, 347, __pyx_L1_error) + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 423, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } - __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 347, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 423, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_6 = __Pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 347, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 423, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "polluck_blockchain/placeholder_native.pyx":349 + /* "polluck_blockchain/placeholder_native.pyx":425 * int(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, 349, __pyx_L1_error) + __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, 425, __pyx_L1_error) - /* "polluck_blockchain/placeholder_native.pyx":350 + /* "polluck_blockchain/placeholder_native.pyx":426 * 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, 350, __pyx_L1_error) + __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, 426, __pyx_L1_error) - /* "polluck_blockchain/placeholder_native.pyx":351 + /* "polluck_blockchain/placeholder_native.pyx":427 * "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, 351, __pyx_L1_error) + __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, 427, __pyx_L1_error) - /* "polluck_blockchain/placeholder_native.pyx":345 + /* "polluck_blockchain/placeholder_native.pyx":421 * * def create_genesis_block(self): * cdef Block *block = new Block( # <<<<<<<<<<<<<< @@ -6947,30 +8002,30 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain __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, 345, __pyx_L1_error) + __PYX_ERR(0, 421, __pyx_L1_error) } __pyx_v_block = __pyx_t_10; - /* "polluck_blockchain/placeholder_native.pyx":353 + /* "polluck_blockchain/placeholder_native.pyx":429 * "".encode("UTF-8"), * ) * block.hash = "dummy hash".encode("UTF-8") # <<<<<<<<<<<<<< * self.add_block(block) * self._genesis_done = True */ - __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, 353, __pyx_L1_error) + __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, 429, __pyx_L1_error) __pyx_v_block->hash = __PYX_STD_MOVE_IF_SUPPORTED(__pyx_t_9); - /* "polluck_blockchain/placeholder_native.pyx":354 + /* "polluck_blockchain/placeholder_native.pyx":430 * ) * block.hash = "dummy hash".encode("UTF-8") * self.add_block(block) # <<<<<<<<<<<<<< * self._genesis_done = True * */ - ((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, 354, __pyx_L1_error) + ((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, 430, __pyx_L1_error) - /* "polluck_blockchain/placeholder_native.pyx":355 + /* "polluck_blockchain/placeholder_native.pyx":431 * block.hash = "dummy hash".encode("UTF-8") * self.add_block(block) * self._genesis_done = True # <<<<<<<<<<<<<< @@ -6979,7 +8034,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain */ __pyx_v_self->_genesis_done = 1; - /* "polluck_blockchain/placeholder_native.pyx":344 + /* "polluck_blockchain/placeholder_native.pyx":420 * self._index += 1 * * def create_genesis_block(self): # <<<<<<<<<<<<<< @@ -7003,7 +8058,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain return __pyx_r; } -/* "polluck_blockchain/placeholder_native.pyx":357 +/* "polluck_blockchain/placeholder_native.pyx":433 * self._genesis_done = True * * def new_block(self, data): # <<<<<<<<<<<<<< @@ -7050,32 +8105,32 @@ PyObject *__pyx_args, PyObject *__pyx_kwds { 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, 357, __pyx_L3_error) + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 433, __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, 357, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 433, __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, 357, __pyx_L3_error) + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "new_block", 0) < (0)) __PYX_ERR(0, 433, __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, 357, __pyx_L3_error) } + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("new_block", 1, 1, 1, i); __PYX_ERR(0, 433, __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, 357, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 433, __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, 357, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("new_block", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 433, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -7118,7 +8173,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain int __pyx_clineno = 0; __Pyx_RefNannySetupContext("new_block", 0); - /* "polluck_blockchain/placeholder_native.pyx":358 + /* "polluck_blockchain/placeholder_native.pyx":434 * * def new_block(self, data): * if not self._genesis_done: # <<<<<<<<<<<<<< @@ -7128,7 +8183,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain __pyx_t_1 = (!__pyx_v_self->_genesis_done); if (unlikely(__pyx_t_1)) { - /* "polluck_blockchain/placeholder_native.pyx":359 + /* "polluck_blockchain/placeholder_native.pyx":435 * def new_block(self, data): * if not self._genesis_done: * raise RuntimeError("Create a genesis block first.") # <<<<<<<<<<<<<< @@ -7141,14 +8196,14 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain 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, 359, __pyx_L1_error) + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 435, __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, 359, __pyx_L1_error) + __PYX_ERR(0, 435, __pyx_L1_error) - /* "polluck_blockchain/placeholder_native.pyx":358 + /* "polluck_blockchain/placeholder_native.pyx":434 * * def new_block(self, data): * if not self._genesis_done: # <<<<<<<<<<<<<< @@ -7157,17 +8212,17 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain */ } - /* "polluck_blockchain/placeholder_native.pyx":361 + /* "polluck_blockchain/placeholder_native.pyx":437 * 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, 361, __pyx_L1_error) + __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, 437, __pyx_L1_error) __pyx_v_prev_block = __pyx_t_5; - /* "polluck_blockchain/placeholder_native.pyx":362 + /* "polluck_blockchain/placeholder_native.pyx":438 * * cdef Block *prev_block = self.get_block_c(self._index) * cdef string prev_hash = prev_block.prev_hash # <<<<<<<<<<<<<< @@ -7177,7 +8232,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain __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":363 + /* "polluck_blockchain/placeholder_native.pyx":439 * 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 # <<<<<<<<<<<<<< @@ -7186,19 +8241,19 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain */ __pyx_v_new_idx = (__pyx_v_self->_index + 1); - /* "polluck_blockchain/placeholder_native.pyx":367 + /* "polluck_blockchain/placeholder_native.pyx":443 * cdef Block *block = new Block( * new_idx, * int(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, 367, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 443, __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, 367, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 443, __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, 367, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_mstate_global->__pyx_tuple[0], NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 443, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_3 = __pyx_t_7; @@ -7209,16 +8264,16 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain __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, 367, __pyx_L1_error) + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 443, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } - __pyx_t_7 = __Pyx_PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 367, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 443, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_9 = __Pyx_PyFloat_AsDouble(__pyx_t_7); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 367, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyFloat_AsDouble(__pyx_t_7); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 443, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - /* "polluck_blockchain/placeholder_native.pyx":369 + /* "polluck_blockchain/placeholder_native.pyx":445 * int(datetime.datetime(2025, 12, 1, 12, 0, 0).timestamp()), * 0, * data.encode("UTF-8"), # <<<<<<<<<<<<<< @@ -7232,22 +8287,22 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_UTF_8}; __pyx_t_7 = __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_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 369, __pyx_L1_error) + if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 445, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); } - __pyx_t_6 = __pyx_convert_string_from_py_6libcpp_6string_std__in_string(__pyx_t_7); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 369, __pyx_L1_error) + __pyx_t_6 = __pyx_convert_string_from_py_6libcpp_6string_std__in_string(__pyx_t_7); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 445, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - /* "polluck_blockchain/placeholder_native.pyx":371 + /* "polluck_blockchain/placeholder_native.pyx":447 * 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, 371, __pyx_L1_error) + __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, 447, __pyx_L1_error) - /* "polluck_blockchain/placeholder_native.pyx":365 + /* "polluck_blockchain/placeholder_native.pyx":441 * cdef uint64_t new_idx = self._index + 1 * * cdef Block *block = new Block( # <<<<<<<<<<<<<< @@ -7258,20 +8313,20 @@ static PyObject *__pyx_pf_18polluck_blockchain_18placeholder_native_10Blockchain __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, 365, __pyx_L1_error) + __PYX_ERR(0, 441, __pyx_L1_error) } __pyx_v_block = __pyx_t_5; - /* "polluck_blockchain/placeholder_native.pyx":373 + /* "polluck_blockchain/placeholder_native.pyx":449 * "".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, 373, __pyx_L1_error) + ((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, 449, __pyx_L1_error) - /* "polluck_blockchain/placeholder_native.pyx":357 + /* "polluck_blockchain/placeholder_native.pyx":433 * self._genesis_done = True * * def new_block(self, data): # <<<<<<<<<<<<<< @@ -7571,8 +8626,8 @@ static PyObject *__pyx_getprop_18polluck_blockchain_18placeholder_native_7PyBloc static PyMethodDef __pyx_methods_18polluck_blockchain_18placeholder_native_PyBlock[] = { {"bytes_serialize", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_11bytes_serialize, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, - {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_15__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, - {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_17__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, + {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_17__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, + {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_18placeholder_native_7PyBlock_19__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {0, 0, 0, 0} }; @@ -7915,18 +8970,19 @@ static int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate) { __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; __pyx_vtable_18polluck_blockchain_18placeholder_native_PyBlock.bytes_serialize_c = (unsigned char *(*)(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *, size_t *))__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_bytes_serialize_c; __pyx_vtable_18polluck_blockchain_18placeholder_native_PyBlock.digest = (unsigned char *(*)(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *, unsigned char *, size_t, size_t *))__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_digest; + __pyx_vtable_18polluck_blockchain_18placeholder_native_PyBlock.mine = (PyObject *(*)(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *, unsigned int, int __pyx_skip_dispatch, struct __pyx_opt_args_18polluck_blockchain_18placeholder_native_7PyBlock_mine *__pyx_optional_args))__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_mine; __pyx_vtable_18polluck_blockchain_18placeholder_native_PyBlock.perform_hash_c = (unsigned char *(*)(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *, size_t *))__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_perform_hash_c; __pyx_vtable_18polluck_blockchain_18placeholder_native_PyBlock.perform_hash = (PyObject *(*)(struct __pyx_obj_18polluck_blockchain_18placeholder_native_PyBlock *, int __pyx_skip_dispatch))__pyx_f_18polluck_blockchain_18placeholder_native_7PyBlock_perform_hash; #if CYTHON_USE_TYPE_SPECS - __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, 60, __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, 60, __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, 88, __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, 88, __pyx_L1_error) #else __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_PyBlock) < (0)) __PYX_ERR(0, 60, __pyx_L1_error) + if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock) < (0)) __PYX_ERR(0, 88, __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_PyBlock); @@ -7936,23 +8992,23 @@ static int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate) { __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock->tp_getattro = PyObject_GenericGetAttr; } #endif - if (__Pyx_SetVtable(__pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock, __pyx_vtabptr_18polluck_blockchain_18placeholder_native_PyBlock) < (0)) __PYX_ERR(0, 60, __pyx_L1_error) - if (__Pyx_MergeVtables(__pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock) < (0)) __PYX_ERR(0, 60, __pyx_L1_error) - if (PyObject_SetAttr(__pyx_m, __pyx_mstate_global->__pyx_n_u_PyBlock_2, (PyObject *) __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock) < (0)) __PYX_ERR(0, 60, __pyx_L1_error) - if (__Pyx_setup_reduce((PyObject *) __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock) < (0)) __PYX_ERR(0, 60, __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, 88, __pyx_L1_error) + if (__Pyx_MergeVtables(__pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock) < (0)) __PYX_ERR(0, 88, __pyx_L1_error) + if (PyObject_SetAttr(__pyx_m, __pyx_mstate_global->__pyx_n_u_PyBlock_2, (PyObject *) __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock) < (0)) __PYX_ERR(0, 88, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject *) __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock) < (0)) __PYX_ERR(0, 88, __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, 279, __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, 279, __pyx_L1_error) + __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, 355, __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, 355, __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, 279, __pyx_L1_error) + if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_Blockchain) < (0)) __PYX_ERR(0, 355, __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); @@ -7962,10 +9018,10 @@ static int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate) { __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, 279, __pyx_L1_error) - if (__Pyx_MergeVtables(__pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_Blockchain) < (0)) __PYX_ERR(0, 279, __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, 279, __pyx_L1_error) - if (__Pyx_setup_reduce((PyObject *) __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_Blockchain) < (0)) __PYX_ERR(0, 279, __pyx_L1_error) + if (__Pyx_SetVtable(__pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_Blockchain, __pyx_vtabptr_18polluck_blockchain_18placeholder_native_Blockchain) < (0)) __PYX_ERR(0, 355, __pyx_L1_error) + if (__Pyx_MergeVtables(__pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_Blockchain) < (0)) __PYX_ERR(0, 355, __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, 355, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject *) __pyx_mstate->__pyx_ptype_18polluck_blockchain_18placeholder_native_Blockchain) < (0)) __PYX_ERR(0, 355, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -8331,34 +9387,50 @@ __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":207 - * return buf + /* "polluck_blockchain/placeholder_native.pyx":254 + * return digest * * def bytes_serialize(self): # <<<<<<<<<<<<<< * cdef: * unsigned char *serialize_res */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_18placeholder_native_7PyBlock_11bytes_serialize, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_PyBlock_bytes_serialize, 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, 207, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_18placeholder_native_7PyBlock_11bytes_serialize, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_PyBlock_bytes_serialize, 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, 254, __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_PyBlock, __pyx_mstate_global->__pyx_n_u_bytes_serialize, __pyx_t_2) < (0)) __PYX_ERR(0, 207, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock, __pyx_mstate_global->__pyx_n_u_bytes_serialize, __pyx_t_2) < (0)) __PYX_ERR(0, 254, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "polluck_blockchain/placeholder_native.pyx":251 + /* "polluck_blockchain/placeholder_native.pyx":264 + * free(serialize_res) + * + * cpdef mine(self, unsigned int difficulty, unsigned int max_nonce=0xFFFFFFFF): # <<<<<<<<<<<<<< + * cdef: + * unsigned char *serial_buf +*/ + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_18placeholder_native_7PyBlock_13mine, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_PyBlock_mine, 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(0, 264, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 + PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); + #endif + __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_mstate_global->__pyx_tuple[1]); + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock, __pyx_mstate_global->__pyx_n_u_mine, __pyx_t_2) < (0)) __PYX_ERR(0, 264, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "polluck_blockchain/placeholder_native.pyx":325 * return digest * * cpdef perform_hash(self): # <<<<<<<<<<<<<< * cdef: * unsigned char *digest */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_18placeholder_native_7PyBlock_13perform_hash, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_PyBlock_perform_hash, 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(0, 251, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_18placeholder_native_7PyBlock_15perform_hash, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_PyBlock_perform_hash, 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, 325, __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_PyBlock, __pyx_mstate_global->__pyx_n_u_perform_hash, __pyx_t_2) < (0)) __PYX_ERR(0, 251, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_18polluck_blockchain_18placeholder_native_PyBlock, __pyx_mstate_global->__pyx_n_u_perform_hash, __pyx_t_2) < (0)) __PYX_ERR(0, 325, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":1 @@ -8366,7 +9438,7 @@ __Pyx_RefNannySetupContext("PyInit_placeholder_native", 0); * 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_7PyBlock_15__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[2])); 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_17__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[3])); 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); @@ -8380,7 +9452,7 @@ __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_7PyBlock_17__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[3])); 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_19__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[4])); 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); @@ -8388,64 +9460,64 @@ __Pyx_RefNannySetupContext("PyInit_placeholder_native", 0); 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":310 + /* "polluck_blockchain/placeholder_native.pyx":386 * return self._index + 1 * * def print_key_value_pair(self): # <<<<<<<<<<<<<< * cdef BcHashmap.iterator it = self._chain.begin() * cdef Block *block */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_18placeholder_native_10Blockchain_9print_key_value_pair, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Blockchain_print_key_value_pair, 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, 310, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_18placeholder_native_10Blockchain_9print_key_value_pair, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Blockchain_print_key_value_pair, 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(0, 386, __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_print_key_value_pair, __pyx_t_2) < (0)) __PYX_ERR(0, 310, __pyx_L1_error) + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_18polluck_blockchain_18placeholder_native_Blockchain, __pyx_mstate_global->__pyx_n_u_print_key_value_pair, __pyx_t_2) < (0)) __PYX_ERR(0, 386, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "polluck_blockchain/placeholder_native.pyx":332 + /* "polluck_blockchain/placeholder_native.pyx":408 * 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_11get_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[5])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 332, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_18placeholder_native_10Blockchain_11get_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[6])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 408, __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, 332, __pyx_L1_error) + 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, 408, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "polluck_blockchain/placeholder_native.pyx":344 + /* "polluck_blockchain/placeholder_native.pyx":420 * 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_13create_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[6])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 344, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_18placeholder_native_10Blockchain_13create_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[7])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 420, __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, 344, __pyx_L1_error) + 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, 420, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "polluck_blockchain/placeholder_native.pyx":357 + /* "polluck_blockchain/placeholder_native.pyx":433 * self._genesis_done = True * * 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_15new_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[7])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 357, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_18placeholder_native_10Blockchain_15new_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[8])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 433, __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, 357, __pyx_L1_error) + 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, 433, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":1 @@ -8453,7 +9525,7 @@ __Pyx_RefNannySetupContext("PyInit_placeholder_native", 0); * 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_17__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[8])); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_18placeholder_native_10Blockchain_17__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[9])); 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); @@ -8467,7 +9539,7 @@ __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_10Blockchain_19__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[9])); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_18placeholder_native_10Blockchain_19__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[10])); 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); @@ -8521,7 +9593,7 @@ __Pyx_RefNannySetupContext("PyInit_placeholder_native", 0); static int __Pyx_InitCachedBuiltins(__pyx_mstatetype *__pyx_mstate) { CYTHON_UNUSED_VAR(__pyx_mstate); - __pyx_builtin_print = __Pyx_GetBuiltinName(__pyx_mstate->__pyx_n_u_print); if (!__pyx_builtin_print) __PYX_ERR(0, 314, __pyx_L1_error) + __pyx_builtin_print = __Pyx_GetBuiltinName(__pyx_mstate->__pyx_n_u_print); if (!__pyx_builtin_print) __PYX_ERR(0, 390, __pyx_L1_error) /* Cached unbound methods */ __pyx_mstate->__pyx_umethod_PyDict_Type_items.type = (PyObject*)&PyDict_Type; @@ -8541,20 +9613,31 @@ static int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate) { CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "polluck_blockchain/placeholder_native.pyx":82 + /* "polluck_blockchain/placeholder_native.pyx":104 * self.BlockC = new Block( * index, * int(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, 82, __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, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[0]); __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[0]); + + /* "polluck_blockchain/placeholder_native.pyx":264 + * free(serialize_res) + * + * cpdef mine(self, unsigned int difficulty, unsigned int max_nonce=0xFFFFFFFF): # <<<<<<<<<<<<<< + * cdef: + * unsigned char *serial_buf +*/ + __pyx_mstate_global->__pyx_tuple[1] = PyTuple_Pack(1, __pyx_mstate_global->__pyx_int_4294967295); if (unlikely(!__pyx_mstate_global->__pyx_tuple[1])) __PYX_ERR(0, 264, __pyx_L1_error) + __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[1]); + __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[1]); #if CYTHON_IMMORTAL_CONSTANTS { PyObject **table = __pyx_mstate->__pyx_tuple; - for (Py_ssize_t i=0; i<1; ++i) { + for (Py_ssize_t i=0; i<2; ++i) { #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL); #else @@ -8574,34 +9657,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: 7; } index[] = {{25},{29},{28},{8},{5},{1},{1},{7},{6},{2},{9},{50},{45},{14},{10},{28},{30},{31},{20},{20},{31},{7},{25},{27},{23},{20},{20},{12},{18},{5},{15},{18},{20},{4},{8},{11},{20},{6},{8},{13},{8},{9},{12},{4},{7},{3},{3},{5},{13},{2},{5},{8},{10},{8},{9},{7},{5},{12},{37},{3},{10},{9},{13},{5},{20},{8},{11},{14},{12},{10},{17},{13},{8},{4},{13},{14},{12},{10},{12},{19},{6},{8},{4},{9},{6},{0},{1},{13},{10},{52},{121},{37},{101},{71},{61},{9}}; - #if (CYTHON_COMPRESS_STRINGS) == 2 /* compression: bz2 (1004 bytes) */ -const char* const cstring = "BZh91AY&SY\000\t\240\345\000\000\177\177\377\375\377\377\257\367\177\374\307\277\367\367V\277\357\377\360@@@@@@@@@@@@@\000@\000P\003xh\000\003\010jj5##G\246\230\243\312\000= z\206\200\017P\032\r\000\017S \006\232\003\322z\232l\223\365AR\001\246\200\320\000\000\000\000\000\000\000\000\000\006\200\000\000Jj\001\t\211\240L\004S \320\0324\000\000\000\000\000\001\221\352=OD\306(p\000\r\000\003@d\000\000\r\000\001\246\200\000\000\000\r\0008\000\006\200\001\2402\000\000\006\200\000\323@\000\000\000\006\200UO\220\016C\262rr\275\375\236\3429\223\316\334Iwz&t!2Bd\242\\H\216J\371\315\0062\246\n\304\303t'\222B\324\016@\220\330\220\213 _zt\"$\223\224\235\007\217HD\251\331\343\355u\323\373\037\356\237\363\257\315B\204}}\254jI\031\035\202\036\214\027$)v!\313\037\242\370\026\230{\231\211\027\232HA\027\200\002\016\002 \004i \005\n\331\260\366\r\340\200\n\2332\026\255a\331\024}\202`B\000\364\214s\212S\3175w\034S%\216\035p\376\0363\251(\317\346v?\336/\256L\305H\342R@[\270;O\001\317\005\027n\333\323\313\014\311\312:L\357-x\253A5\316\267\324B\034\367>\246g!\035\324\241\010\306\372\211\254C\240Q\3149LL9I5\226\017\266\250MU\325;q\310\301\213!\335b\276|\002\306\241:3T.>\266M\023\031\303\312\033\215\215\303\3418[g\244\311\344\206W\261\300\230v\335\265\035mw\365]\250k\032\023`\255\334\323\006\220\206$\202\350\312\302\2275 7K&\351YLz-\221\210\376\256\312\236\206\234\253\274\317Y\214\335\253\241\\ot\207(9\357I$\213fD\320\321t\347\001\234\356\336\326|\212aZ\300\345\324\322\273\025gxP/\254\261\211:\342\262C\307\271\351\240\321jk\\^6sF\r\301P\345\226\247\301\306\244Y\264\2673\004\013SL\351D\250\3103\203=\241k\316^\366\271\261\274a\317\224\t\332\231U3\247Yj+\317<+\271\026b\242m\334Tf\032\261\026\3546p\0130[\236sbB\262\\\254&I\223\t$\222(<\200\\J\313\240\334LO\330yl\367\2510 HO+\225MIx\022\352\322)\236\033\247\276\006\235[S\333^\267^\3146\214%\300i4\025\221k\307\r\0032\205\244\244qW\033+\364\025Li5\370\247F\301\262\232S\223hu\342\330\361\251Y\216\362\374\032\017#Z\222\340\201\002\262\005v\304F4\203\205\246\006\201\217\030\204\223\007\333v\2013O\213\240O\017t\232\200\200\210\272\214$\007\244\202\300Y>\260N\004\273\007k\363G\177\354Cq\221V\226E\"\004\266\315\021O\231w= \177\334\017\210j\212\230\352\2539Xk\272\023c\33075\025\376\231\007\304\203z\243\302\026\\\267\255Z\\C06\352\250u\022\206\242\210\356\242\024\271=\233M\t\310Fh\236?\216\222\343\025\246&4\270R6\202r\234J\300\3608$\241\204_\030A)S\024d\350\324\321\243\252\235U\037\370\273\222)\302\204\200\000M\007("; - PyObject *data = __Pyx_DecompressString(cstring, 1004, 2); + const struct { const unsigned int length: 8; } index[] = {{25},{29},{28},{20},{8},{5},{1},{1},{7},{6},{2},{9},{50},{45},{14},{10},{28},{30},{31},{20},{20},{31},{7},{25},{27},{23},{12},{20},{20},{12},{18},{5},{15},{18},{20},{4},{8},{10},{11},{20},{6},{8},{13},{8},{9},{12},{4},{7},{3},{3},{5},{13},{2},{5},{8},{9},{4},{10},{8},{9},{7},{5},{12},{37},{3},{10},{9},{13},{5},{20},{8},{11},{14},{12},{10},{17},{13},{8},{4},{13},{14},{12},{10},{12},{19},{6},{8},{4},{9},{6},{0},{1},{13},{10},{52},{121},{37},{101},{71},{73},{170},{9}}; + #if (CYTHON_COMPRESS_STRINGS) == 2 /* compression: bz2 (1149 bytes) */ +const char* const cstring = "BZh91AY&SYw\304\363Q\000\000\250\177\377\375\377\377\257\367\177\374\347\277\367\377^\277\357\377\362@@@@@@@@@@@@@\000@\000P\003\376+l\032\002\203\033\rS\320\242mM\006\230z$\323\324\006\200\323M4\032\003CM\000\006\200\310\006A\265\036\246&&\010!\004\323F\223\010F\217\322\217)\220\000\000\006\200\000\000\000\000\032\000\000\032\034\000\000\000\000\000\001\220\000\000\000\000\000\000\000\031\000\016\000\000\000\000\000\000\310\000\000\000\000\000\000\000\014\200\002SH\020\010\236\251\260\nz\221\262C@\032\000h\000\r\003C \000\000\323\324=C\324\365=J\352\325w]\233\367o\344\343?\2168\302+\221\335r\362\274\016I\224\345\346\250\346\020\201!2R7\232d\263Y\314\332\216q*\331\213\0010\311%\202\tI\250\254O\210:&\207A6\020\327!\027L\311\221n\204e\001M\222J(\251\324\236u\311\257s7\"\r\214\340\255\233Sj\244\362;4\237\320o>\301\203f\202\252\241\0261\335;\016\211\330K\346\001\022\310\236s\247N}s7\347\354\327\315\341\273vv\361\350U\244f}\n\t#F\373\361J\030\333\277\274:h\3173\000\370\2434\353!\\\312`[\026\302\304\001\262\004B/U\004\003\262\372hu|\030\032\201\321\350\351\266k\235g\207\346p\020\tY\276\317 5\t(\020\005c\005^\2710,\203\272\0071\214l\2500c3\364\"\271\026+\272\360\316\276\354'\014(1r;\245D\315\217\010q\301\232\001\t?\017\007w\246;(\344\024\367\032\340_\001M\005\027*\351VF<\270B\266gB9\022\214e,\225\224ep\360\211T\030uA0\352)\255\264\205\365\306\212\277 \376\345\213\005\330\234\231P[\313\000\265\252)S5b\3758q\317A\234\201Q\270\257^\306\332x0\200\374\376\225\232\315\376\250f\203\032\223\017\273u\205{7\274D\372\306\265\240Q\202\307\377h\303LC\023A\204\247iV\002\222\034\006t\022\217\023Iq\270)\235d\031\007{\211.i\314\002\226T\340:\250I$#7\362\212\360B\364#\007\223\306\t$\221\032\02244\236t\210\311\373\235\315\t\225b\366>\361\305\255\245\205\326\034\005A\222\302\326&\370\026\023 A\340\232-&\253b\350\3653\033tb\332::\256\024_=\320\213\233Q\206\343.\206\010\231SP\341\221Y\230g\r7\205\3608\262C\270\267=lv\343\020\216\242r,\312\231]Qe\306D[u1\263\"-\272\244\335\r\025\0035\202/\332m""\324,\301~y\32111[>!\223$\311\204\222I\0254\010\206\004\355\301E\265\261\256\372\345\"\024\320\250\300\230I@\263\324\243U6\350\316\035J\2351\000\266\233\242i\324Gk\305\265\353\350C(3h\306\232MF\202\310\014\232\027\233J\210\364\340\265\310R\201r$\204\272N\262\300S,\222f0\212R\240\022\322\220`\206)\240H\354\256L\0078\312y\360\311\277\273N\263\014\020\231T\325\025 N\313\023P\213H^\355]6o\305\257\210\352V\301Y\203\215~\226\n\004\037\205\341\2356\004\023v\236{\267\260\267\266\311,\217\036qq\320\027\r\262\002\0161N\002\370\0164M\365\033\311\314\355\254\225\266y\212\2660\322k\357\217\373`\3224\247M\235\362\031\237dY\253\264\3362\231qh\3016Af\021s\217h\271\371\377\240,\211\2637H\304iM\0301}\374\035^\302\323\365\373\276\257`M\326\354\267X\355\t&\366\306\254\370.\020\303zy\212\022\340\332]\303\275\230\203\305J\365D\227\340\250\315bi\002{\"`\226\372PN_\250\376\373\225\362@SdUR\222\211j&\242Bd\235\245\252\326@=\353!\376|+EYj\014\006\360\350\233b\237\031{\313\014T!\026\034K\372\227\313\316\265\372\027\020\344,\274kR+\331XIN\251Y\235\340\037b\242\357\013\020\\\340\331\2169G\245\033\213\326XX\367\336Nqz\021\232\352}\n\272\200\230\333\346\231\200T\034\341\032\010u\036\212\030i\010#%I\323\212\243\312\212\223\262\2621\203F#\301U9IV;\377\342\356H\247\n\022\016\370\236j "; + PyObject *data = __Pyx_DecompressString(cstring, 1149, 2); 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 - #elif (CYTHON_COMPRESS_STRINGS) != 0 /* compression: zlib (895 bytes) */ -const char* const cstring = "x\332\205T\315\217\0335\024't\305\246a\266%m\241B|MPA\320\322\224m\221\340\300\207\262\273\005\026A\333\240\024!\324\312r\016CN\260\242\376\010\313\010'\373\202\272\r\366\2074\246\222I\277\017\346#\177\300\204T\355\3038\240S\177\202\303\224\372`\342\251\362\371\300\357\3634\016\344\223\331\236\363\374\344i\357\373\273_}\372]\300$\356\207\224\306n\036\022&\027R\020s?\240\003\234\206\312GH\320 %\024!?\200\013\025\207|\342\273J\260\t\303!X\t\213\231BH\nr/\341a\230\222#T&CF\230\305\367\222\020\023:\342a@\005\212\261b\023\332Nf\323\257%\234\217\207\222\247\202\320o\367V\356\347R{\025\226\314\324\210\307\010\375\313&\251\222\n\020\270\310JJlP\205\314\"\2315\363\220\252\r]L_l\350\022\310P\241#:C%\222(\301LT\350U\313f\216\347\206\215\004\227\246\376LQ\tf\001\350\261?\351R\235P1\340\"B\320\336\221s\236\3028`D\241Gt\252~\245\203\336\341/\017\377x\374\350!z\332\333\307r\026\023\306\333\204\013\350-\2032\313\334\377s3\t\301\202X\214\224\200\026\3641\324u\0010\001V\030\006U,\242\001O\000\032,\031\221kb{i\2461\341@\n\301#\224(\341V\247\205*\243\004\241A\032\023\204V\330\226\342\002\200\262$7B\326\037\321)\013\246\314\361\023A\006\253\002\230b\212F\022\241\010\220G\360E\324]\r\207\275\371O\032\353\361q\347\357\372+\227\033\205\007Y\275\364\357\347\255|7\357\024\336u\375\215}\325\266\316\340lM7]vU0\330\377_\270w\314\227\266ew\235\333\013\027b-\350\316\374w\375\314\336\314jY\263Xf\000\302K\357=SB\360\221\355e7\363\327rp\2752'\372\272>0\333F\271\273\232\272\t\250\020\333,\274\033\372g{\311\351\3367\314\216\263\332\302\010\261\3376M\323\202\202\032eAo\352\236\371\300E\002\324J\010\246&\265\035\373[v?{~r\353\244\177\272}:\376\253VUxV\277\352\260?\256\025[\215\371\035\335\375\007\021\312s\260"; - PyObject *data = __Pyx_DecompressString(cstring, 895, 1); + #elif (CYTHON_COMPRESS_STRINGS) != 0 /* compression: zlib (1041 bytes) */ +const char* const cstring = "x\332\205TMo\033E\030\216KD\234\260i\342~\020U\004XW\001\025J\\\322\"\001\022\0059\037\224T%\340\220\242\n\212F\343\331q<\312\356\316zg6\265\221\220r\364q\216s\234\343\036}\3141G\216>\356\321?!?\201w\326\03718\022\207\235yg\336\357\347}fwx\342{n\310\245\213}\237\023,\251\333\304\"\300\321NL\355\001\273\3074\244\202\t\267\016\352\023\267\301b!+\373\241G\333\356)\366\023\352\202\212'\322\345\r\267\316\223\320\023\007\334*\230\r\032\022\3526\354\345\317\235m\353\375\340\345\321\367\233_}\362\235\307\004\256\373\224\206v=&L\014%/\344\256G\0338\361\245\213PL\275\204P\204\\\017\222Hn\303m\312\230\2352\354\203\226\260\220I\204DL\036E\334\367\023r\202\362\002I\023\263\360Q\344cB\233\334\367h\214B,\331)\255D\235\3667\002\374\303c\301\223\230\320o\267'\346WRe\222\226td\223\207\010\375K'\250\024\022P\271NKr\274\320\010\255a1S\352c*g\356B\372f\346.\202\n%:\241\035\224\243\213\"\314\342\021z\243m\266\306+\305L\201cU\275#\251\000u\014\350\261?\351\370:`\341D\216h\334\340q\200`\374M\353\330\206o\227\021\211\016h[\036\322\306\321\376\217{\277\375t\260\207^\036\355`\321\t\t\343\025\302c\230=\004\021y\037\377\311B|\320 \026\"\031\3038\352\030z\274\006$\017K\014\037\225,\240\036k4\030\201\371w<\036\001`X0\"\246\304\312\330\220\206\204\003Ub\036\240H\306v\267\267\320{\020!\324HB\202\320\004\361\\\034\302\2227g?\237\325\233\264\315\2746\263LFP\313\244\025&\231\244\201@(\200y\330\265\215r&[\254\340\310\275\304\207\035\001\257\002\330'3\264\002\304\313M\247\241\234ege\226\235\021\217\242\230\236\016\215r)w\005\201\361D\214\016@\214\353\330\021u\306m\002\305\321\250O+\236J\373\250l\251\255\004\373\303r\257\236\325\014\213&\027\200G~\210bK(\2771\231'\334\211\253\203\260\213e\334\010\t\220F\217w\212\207\350\032N\302+L\200V\010\270bW\230\333dvyW\342\363g\243_NNL/\t\202\216\375)5\317\252Y\361\235\356\027\335X\335RO\224\247\357\353]S\310\234[\352S]\325\265Aq\035\316NZMkY\361]\305t\313,\247\265\261\217T[\326\3623\215ukP,\233;\346u\257\324\333\350\341\254\350\232\245\264l\267y\363C\272\235b\033h""\337\3242g9sV\272-U\324\213\246d>N\347\323\235T\366\236\364\352\347K\027\345\\\273\252\026TK\027r\371f\367X\325\0248;\335\347\n\253\326Y\365\2628\267\270\2249PU\337}\334+\367\266z\325\314\271\255\236\232\033\246<\000\337\202*\331\352F\311\340\374\177\351\336\323_\232\262\331\262fol\212\251\244\313\335W\352\265YK\013i)\033W\000B\337y_\347\020|d\216\322\265\336\333=0\275\331%\352\266\332\325\013Z\332X%U\002T\210)e\316\035\365\302\274e\357>\320\314\264\322\302P\t\271\357\351\222.CCKyCw\325\221\376\320f\002\324\362R\210.e\253\245!\034m\235\230\252\3715}\234\376q\276q^\277X\270h\375]\030u;(\256\3309\364\347\367.j\227\316\334\262\253\241\205\0076\317\375a_\033\340\ns\204\004\375{\017\323-;\312\001t\275\325_?\354\037\376b\223\375e'\r\311\006\000kU\377\236\336H+CxlQk\246`\326\373\233O\317k\347x\340\254\364Wl\274W@\207U@AS\310\260\352\202\311]\203\363\010yM\227\353s\213\016\360\2435\305\016\247\373L}\255\237\033|V\310\346\227\272\017U\355\037\254n\317b"; + PyObject *data = __Pyx_DecompressString(cstring, 1041, 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 (1593 bytes) */ -const char* const bytes = "Could not allocate hasmapCreate a genesis block first.Index value is out of boundsPyBlock(UTF-8)?disableenablegcisenabledno 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_blockBlockchain.print_key_value_pairPyBlockPyBlock.__reduce_cython__PyBlock.__setstate_cython__PyBlock.bytes_serializePyBlock.perform_hash__Pyx_PyDict_NextRefTIMEZONE_UTCasyncio.coroutinesblockbytes_serializecline_in_tracebackcreate_genesis_blockdatadatetimedopt_basicsdopt_basics.datetimeencodefrom_ptrfromtimestamp__func__get_block__getstate__hashhashlibhexidxindex_is_coroutineititems__main____module____name__new_blocknew_idxnonceperform_hashpolluck_blockchain.placeholder_nativepopprev_blockprev_hashprevious_hashprintprint_key_value_pairpy_block__pyx_state__pyx_vtable____qualname____reduce____reduce_cython____reduce_ex____repr__selfserialize_resserialize_size__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\017\210q\220\010\230\t\240\021\240&\250\004\250C\250t\2603\260b\270\n\300!\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\360\010\000\t\n\330\014\034\230D\320 2\260!\2601\260A\330\014\023\220=\240\002\240!\340\014\020\220\001\220\021\200A\330\010\034\230I\240Q\330\014\020\220\001\330\014\017\210q\220\010\230\t\240\021\240&\250\004\250C\250t\2603\260b\270\n\300!\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\220\\\240\027\250\001\250\021\330\010\014\210J\220a\220q\330\010\014\320\014\035\230Q\200A\330\010%\240T\250\027\260\006\260a\340\010\016\210c\220\023\220D\230\007\230t\2401\330\014\021\220\021\220,\230c\240\021\330\014\024\220L\240\003\2401\330\014\036\230i\240q\250\001\330\014\021\220\021\220!\330\014\031\230\021\230!\200A\360\n\000\t\n\330\014\025\220T\230\037\250\001\250\021\250!\330\014\020\220\007\220x\230u\240A\240V\2502\250]\270$\270b\300\007\300q\310\001\340\014\020\220\001\220\021\340\010\017\210t\2201\200\001\330\004\n\210+\220Q"; + #else /* compression: none (1830 bytes) */ +const char* const bytes = "Could not allocate hasmapCreate a genesis block first.Index value is out of boundsNo valid nonce foundPyBlock(UTF-8)?disableenablegcisenabledno 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_blockBlockchain.print_key_value_pairPyBlockPyBlock.__reduce_cython__PyBlock.__setstate_cython__PyBlock.bytes_serializePyBlock.minePyBlock.perform_hash__Pyx_PyDict_NextRefTIMEZONE_UTCasyncio.coroutinesblockbytes_serializecline_in_tracebackcreate_genesis_blockdatadatetimedifficultydopt_basicsdopt_basics.datetimeencodefrom_ptrfromtimestamp__func__get_block__getstate__hashhashlibhexidxindex_is_coroutineititems__main__max_noncemine__module____name__new_blocknew_idxnonceperform_hashpolluck_blockchain.placeholder_nativepopprev_blockprev_hashprevious_hashprintprint_key_value_pairpy_block__pyx_state__pyx_vtable____qualname____reduce____reduce_cython____reduce_ex____repr__selfserialize_resserialize_size__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\017\210q\220\010\230\t\240\021\240&\250\004\250C\250t\2603\260b\270\n\300!\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\360\010\000\t\n\330\014\034\230D\320 2\260!\2601\260A\330\014\023\220=\240\002\240!\340\014\020\220\001\220\021\200A\330\010\034\230I\240Q\330\014\020\220\001\330\014\017\210q\220\010\230\t\240\021\240&\250\004\250C\250t\2603\260b\270\n\300!\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\220\\\240\027\250\001\250\021\330\010\014\210J\220a\220q\330\010\014\320\014\035\230Q\200A\330\010%\240T\250\027\260\006\260a\340\010\016\210c\220\023\220D\230\007\230t\2401\330\014\021\220\021\220,\230c\240\021\330\014\024\220L\240\003\2401\330\014\036\230i\240q\250\001\330\014\021\220\021\220!\330\014\031\230\021\230!\200A\360\n\000\t\n\330\014\025\220T\230\037\250\001\250\021\250!\330\014\017\210w\220c\230\021\330\020\021\330\014\020\220\007\220x\230u\240A\240V\2502\250]\270$\270b\300\007\300q\310\001\340\014\020\220\001\220\021\340\010\017\210t\2201\320\004E\300Q\360\014\000\r \230q\330\014(\250\001\330\014\"\240!\2401\330\014$\240A\240Q\340\010\025\220T\320\031+\2501\250A\250Q\340\014\033\2301\320\034R\320RS\330\014\017\210}\230A\230Q\330\020\021\340\014\034\230A\230[\250\002\250.\270\n\300!\330\014\025\220T\230\027\240\001\240\034\320-=\270Q\270a\340\014\017\320\017$\240A\240X\250Q\330\020\035\230Q\230e\2401\330\020 \240\001\240\025\240a\330\020\021\340\014\020\220\001\220\021\360\034\000\t\014\2104\210q\330\014\022\220,\230a\230q\340\010\014\210G\2209\230J\240a\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 < 85; i++) { + for (int i = 0; i < 90; i++) { Py_ssize_t bytes_length = index[i].length; PyObject *string = PyUnicode_DecodeUTF8(bytes + pos, bytes_length, NULL); - if (likely(string) && i >= 14) PyUnicode_InternInPlace(&string); + if (likely(string) && i >= 15) PyUnicode_InternInPlace(&string); if (unlikely(!string)) { Py_XDECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) @@ -8609,7 +9692,7 @@ const char* const bytes = "Could not allocate hasmapCreate a genesis block first stringtab[i] = string; pos += bytes_length; } - for (int i = 85; i < 96; i++) { + for (int i = 90; i < 102; i++) { Py_ssize_t bytes_length = index[i].length; PyObject *string = PyBytes_FromStringAndSize(bytes + pos, bytes_length); stringtab[i] = string; @@ -8620,15 +9703,15 @@ const char* const bytes = "Could not allocate hasmapCreate a genesis block first } } Py_XDECREF(data); - for (Py_ssize_t i = 0; i < 96; i++) { + for (Py_ssize_t i = 0; i < 102; i++) { if (unlikely(PyObject_Hash(stringtab[i]) == -1)) { __PYX_ERR(0, 1, __pyx_L1_error) } } #if CYTHON_IMMORTAL_CONSTANTS { - PyObject **table = stringtab + 85; - for (Py_ssize_t i=0; i<11; ++i) { + PyObject **table = stringtab + 90; + for (Py_ssize_t i=0; i<12; ++i) { #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL); #else @@ -8642,15 +9725,16 @@ const char* const bytes = "Could not allocate hasmapCreate a genesis block first PyObject **numbertab = __pyx_mstate->__pyx_number_tab + 0; int8_t const cint_constants_1[] = {0,1,12}; int16_t const cint_constants_2[] = {2025}; - for (int i = 0; i < 4; i++) { - numbertab[i] = PyLong_FromLong((i < 3 ? cint_constants_1[i - 0] : cint_constants_2[i - 3])); + int64_t const cint_constants_8[] = {4294967295LL}; + for (int i = 0; i < 5; i++) { + numbertab[i] = PyLong_FromLongLong((i < 3 ? cint_constants_1[i - 0] : (i < 4 ? cint_constants_2[i - 3] : cint_constants_8[i - 4]))); if (unlikely(!numbertab[i])) __PYX_ERR(0, 1, __pyx_L1_error) } } #if CYTHON_IMMORTAL_CONSTANTS { PyObject **table = __pyx_mstate->__pyx_number_tab; - for (Py_ssize_t i=0; i<4; ++i) { + for (Py_ssize_t i=0; i<5; ++i) { #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL); #else @@ -8687,54 +9771,59 @@ 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, 3, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 207}; + const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 3, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 254}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_serialize_res, __pyx_mstate->__pyx_n_u_serialize_size}; __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_bytes_serialize, __pyx_mstate->__pyx_kp_b_iso88591_A_D_2_1A, 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), 251}; + const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 3, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 264}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_difficulty, __pyx_mstate->__pyx_n_u_max_nonce}; + __pyx_mstate_global->__pyx_codeobj_tab[1] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_src_polluck_blockchain_placehold, __pyx_mstate->__pyx_n_u_mine, __pyx_mstate->__pyx_kp_b_iso88591_EQ_q_1_AQ_T_1AQ_1_RRS_AQ_A_T_Qa, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[1])) goto bad; + } + { + const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 325}; 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_src_polluck_blockchain_placehold, __pyx_mstate->__pyx_n_u_perform_hash, __pyx_mstate->__pyx_kp_b_iso88591_A_T_xuAV2_b_q_t1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[1])) goto bad; + __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_perform_hash, __pyx_mstate->__pyx_kp_b_iso88591_A_T_wc_xuAV2_b_q_t1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[2])) 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[2] = __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[2])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[3] = __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[3])) 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[3] = __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[3])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[4] = __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[4])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 310}; + const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 386}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_it, __pyx_mstate->__pyx_n_u_block, __pyx_mstate->__pyx_n_u_py_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_print_key_value_pair, __pyx_mstate->__pyx_kp_b_iso88591_A_T_a_c_D_t1_c_L_1_iq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[4])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[5] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_src_polluck_blockchain_placehold, __pyx_mstate->__pyx_n_u_print_key_value_pair, __pyx_mstate->__pyx_kp_b_iso88591_A_T_a_c_D_t1_c_L_1_iq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[5])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 3, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 332}; + const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 3, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 408}; 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[5] = __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[5])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[6] = __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[6])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 344}; + const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 420}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_block}; - __pyx_mstate_global->__pyx_codeobj_tab[6] = __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_q_Ct3b_7_1_waq_gQa_X_Jaq_Q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[6])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[7] = __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_q_Ct3b_7_1_waq_gQa_X_Jaq_Q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[7])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 6, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 357}; + const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 6, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 433}; 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[7] = __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_q_Ct3b_q_gQa_J, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[7])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[8] = __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_q_Ct3b_q_gQa_J, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[8])) 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[8] = __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[8])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[9] = __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[9])) 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[9] = __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[9])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[10] = __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[10])) goto bad; } Py_DECREF(tuple_dedup_map); return 0; @@ -9154,6 +10243,27 @@ static PyObject *__Pyx_PyObject_FastCallMethod(PyObject *name, PyObject *const * } #endif +/* DivInt[long] */ +static CYTHON_INLINE long __Pyx_div_long(long a, long b, int b_is_constant) { + long q = a / b; + long r = a - q*b; + long adapt_python = (b_is_constant ? + ((r != 0) & ((r < 0) ^ (b < 0))) : + ((r != 0) & ((r ^ b) < 0)) + ); + return q - adapt_python; +} + +/* ModInt[long] */ +static CYTHON_INLINE long __Pyx_mod_long(long a, long b, int b_is_constant) { + long r = a % b; + long adapt_python = (b_is_constant ? + ((r != 0) & ((r < 0) ^ (b < 0))) : + ((r != 0) & ((r ^ b) < 0)) + ); + return r + adapt_python * b; +} + /* TupleAndListFromArray (used by fastcall) */ #if !CYTHON_COMPILING_IN_CPYTHON && CYTHON_METH_FASTCALL static CYTHON_INLINE PyObject * @@ -10480,6 +11590,15 @@ static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject } #endif +/* ErrOccurredWithGIL */ +static CYTHON_INLINE int __Pyx_ErrOccurredWithGIL(void) { + int err; + PyGILState_STATE _save = PyGILState_Ensure(); + err = !!PyErr_Occurred(); + PyGILState_Release(_save); + return err; +} + /* RaiseException */ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { PyObject* owned_instance = NULL; @@ -13150,6 +14269,256 @@ bad: return (target_type) value;\ } +/* CIntFromPy */ +static CYTHON_INLINE unsigned int __Pyx_PyLong_As_unsigned_int(PyObject *x) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; + if (unlikely(!PyLong_Check(x))) { + unsigned int val; + PyObject *tmp = __Pyx_PyNumber_Long(x); + if (!tmp) return (unsigned int) -1; + val = __Pyx_PyLong_As_unsigned_int(tmp); + Py_DECREF(tmp); + return val; + } + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + if (unlikely(__Pyx_PyLong_IsNeg(x))) { + goto raise_neg_overflow; + } else if (__Pyx_PyLong_IsCompact(x)) { + __PYX_VERIFY_RETURN_INT(unsigned int, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) + } else { + const digit* digits = __Pyx_PyLong_Digits(x); + assert(__Pyx_PyLong_DigitCount(x) > 1); + switch (__Pyx_PyLong_DigitCount(x)) { + case 2: + if ((8 * sizeof(unsigned int) > 1 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(unsigned int) >= 2 * PyLong_SHIFT)) { + return (unsigned int) (((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); + } + } + break; + case 3: + if ((8 * sizeof(unsigned int) > 2 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(unsigned int) >= 3 * PyLong_SHIFT)) { + return (unsigned int) (((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); + } + } + break; + case 4: + if ((8 * sizeof(unsigned int) > 3 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(unsigned int) >= 4 * PyLong_SHIFT)) { + return (unsigned int) (((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); + } + } + break; + } + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (unsigned int) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if ((sizeof(unsigned int) <= sizeof(unsigned long))) { + __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned long, PyLong_AsUnsignedLong(x)) + } else if ((sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG))) { + __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + if (__Pyx_PyLong_IsCompact(x)) { + __PYX_VERIFY_RETURN_INT(unsigned int, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) + } else { + const digit* digits = __Pyx_PyLong_Digits(x); + assert(__Pyx_PyLong_DigitCount(x) > 1); + switch (__Pyx_PyLong_SignedDigitCount(x)) { + case -2: + if ((8 * sizeof(unsigned int) - 1 > 1 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT)) { + return (unsigned int) (((unsigned int)-1)*(((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + case 2: + if ((8 * sizeof(unsigned int) > 1 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT)) { + return (unsigned int) ((((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + case -3: + if ((8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT)) { + return (unsigned int) (((unsigned int)-1)*(((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + case 3: + if ((8 * sizeof(unsigned int) > 2 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT)) { + return (unsigned int) ((((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + case -4: + if ((8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT)) { + return (unsigned int) (((unsigned int)-1)*(((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + case 4: + if ((8 * sizeof(unsigned int) > 3 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT)) { + return (unsigned int) ((((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + } + } +#endif + if ((sizeof(unsigned int) <= sizeof(long))) { + __PYX_VERIFY_RETURN_INT_EXC(unsigned int, long, PyLong_AsLong(x)) + } else if ((sizeof(unsigned int) <= sizeof(PY_LONG_LONG))) { + __PYX_VERIFY_RETURN_INT_EXC(unsigned int, PY_LONG_LONG, PyLong_AsLongLong(x)) + } + } + { + unsigned int val; + int ret = -1; +#if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API + Py_ssize_t bytes_copied = PyLong_AsNativeBytes( + x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0)); + if (unlikely(bytes_copied == -1)) { + } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) { + goto raise_overflow; + } else { + ret = 0; + } +#elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + ret = _PyLong_AsByteArray((PyLongObject *)x, + bytes, sizeof(val), + is_little, !is_unsigned); +#else + PyObject *v; + PyObject *stepval = NULL, *mask = NULL, *shift = NULL; + int bits, remaining_bits, is_negative = 0; + int chunk_size = (sizeof(long) < 8) ? 30 : 62; + if (likely(PyLong_CheckExact(x))) { + v = __Pyx_NewRef(x); + } else { + v = PyNumber_Long(x); + if (unlikely(!v)) return (unsigned int) -1; + assert(PyLong_CheckExact(v)); + } + { + int result = PyObject_RichCompareBool(v, Py_False, Py_LT); + if (unlikely(result < 0)) { + Py_DECREF(v); + return (unsigned int) -1; + } + is_negative = result == 1; + } + if (is_unsigned && unlikely(is_negative)) { + Py_DECREF(v); + goto raise_neg_overflow; + } else if (is_negative) { + stepval = PyNumber_Invert(v); + Py_DECREF(v); + if (unlikely(!stepval)) + return (unsigned int) -1; + } else { + stepval = v; + } + v = NULL; + val = (unsigned int) 0; + mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; + shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; + for (bits = 0; bits < (int) sizeof(unsigned int) * 8 - chunk_size; bits += chunk_size) { + PyObject *tmp, *digit; + long idigit; + digit = PyNumber_And(stepval, mask); + if (unlikely(!digit)) goto done; + idigit = PyLong_AsLong(digit); + Py_DECREF(digit); + if (unlikely(idigit < 0)) goto done; + val |= ((unsigned int) idigit) << bits; + tmp = PyNumber_Rshift(stepval, shift); + if (unlikely(!tmp)) goto done; + Py_DECREF(stepval); stepval = tmp; + } + Py_DECREF(shift); shift = NULL; + Py_DECREF(mask); mask = NULL; + { + long idigit = PyLong_AsLong(stepval); + if (unlikely(idigit < 0)) goto done; + remaining_bits = ((int) sizeof(unsigned int) * 8) - bits - (is_unsigned ? 0 : 1); + if (unlikely(idigit >= (1L << remaining_bits))) + goto raise_overflow; + val |= ((unsigned int) idigit) << bits; + } + if (!is_unsigned) { + if (unlikely(val & (((unsigned int) 1) << (sizeof(unsigned int) * 8 - 1)))) + goto raise_overflow; + if (is_negative) + val = ~val; + } + ret = 0; + done: + Py_XDECREF(shift); + Py_XDECREF(mask); + Py_XDECREF(stepval); +#endif + if (unlikely(ret)) + return (unsigned int) -1; + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to unsigned int"); + return (unsigned int) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned int"); + return (unsigned int) -1; +} + /* PyObjectVectorCallKwBuilder (used by CIntToPy) */ #if CYTHON_VECTORCALL static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) { @@ -13251,6 +14620,325 @@ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_uint64_t(uint64_t value) { } } +/* CIntToPy */ +static CYTHON_INLINE PyObject* __Pyx_PyLong_From_int(int value) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const int neg_one = (int) -1, const_zero = (int) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(int) < sizeof(long)) { + return PyLong_FromLong((long) value); + } else if (sizeof(int) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#if !CYTHON_COMPILING_IN_PYPY + } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(int) <= sizeof(long)) { + return PyLong_FromLong((long) value); + } else if (sizeof(int) <= 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(int), + 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(int)); + 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 + } +} + +/* CIntFromPy */ +static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *x) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const int neg_one = (int) -1, const_zero = (int) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; + if (unlikely(!PyLong_Check(x))) { + int val; + PyObject *tmp = __Pyx_PyNumber_Long(x); + if (!tmp) return (int) -1; + val = __Pyx_PyLong_As_int(tmp); + Py_DECREF(tmp); + return val; + } + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + if (unlikely(__Pyx_PyLong_IsNeg(x))) { + goto raise_neg_overflow; + } else if (__Pyx_PyLong_IsCompact(x)) { + __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) + } else { + const digit* digits = __Pyx_PyLong_Digits(x); + assert(__Pyx_PyLong_DigitCount(x) > 1); + switch (__Pyx_PyLong_DigitCount(x)) { + case 2: + if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(int) >= 2 * PyLong_SHIFT)) { + return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + case 3: + if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(int) >= 3 * PyLong_SHIFT)) { + return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + case 4: + if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(int) >= 4 * PyLong_SHIFT)) { + return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + } + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (int) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if ((sizeof(int) <= sizeof(unsigned long))) { + __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) + } else if ((sizeof(int) <= sizeof(unsigned PY_LONG_LONG))) { + __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + if (__Pyx_PyLong_IsCompact(x)) { + __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) + } else { + const digit* digits = __Pyx_PyLong_Digits(x); + assert(__Pyx_PyLong_DigitCount(x) > 1); + switch (__Pyx_PyLong_SignedDigitCount(x)) { + case -2: + if ((8 * sizeof(int) - 1 > 1 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { + return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 2: + if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { + return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case -3: + if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { + return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 3: + if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { + return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case -4: + if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) { + return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 4: + if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) { + if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) { + return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + } + } +#endif + if ((sizeof(int) <= sizeof(long))) { + __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) + } else if ((sizeof(int) <= sizeof(PY_LONG_LONG))) { + __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) + } + } + { + int val; + int ret = -1; +#if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API + Py_ssize_t bytes_copied = PyLong_AsNativeBytes( + x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0)); + if (unlikely(bytes_copied == -1)) { + } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) { + goto raise_overflow; + } else { + ret = 0; + } +#elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + ret = _PyLong_AsByteArray((PyLongObject *)x, + bytes, sizeof(val), + is_little, !is_unsigned); +#else + PyObject *v; + PyObject *stepval = NULL, *mask = NULL, *shift = NULL; + int bits, remaining_bits, is_negative = 0; + int chunk_size = (sizeof(long) < 8) ? 30 : 62; + if (likely(PyLong_CheckExact(x))) { + v = __Pyx_NewRef(x); + } else { + v = PyNumber_Long(x); + if (unlikely(!v)) return (int) -1; + assert(PyLong_CheckExact(v)); + } + { + int result = PyObject_RichCompareBool(v, Py_False, Py_LT); + if (unlikely(result < 0)) { + Py_DECREF(v); + return (int) -1; + } + is_negative = result == 1; + } + if (is_unsigned && unlikely(is_negative)) { + Py_DECREF(v); + goto raise_neg_overflow; + } else if (is_negative) { + stepval = PyNumber_Invert(v); + Py_DECREF(v); + if (unlikely(!stepval)) + return (int) -1; + } else { + stepval = v; + } + v = NULL; + val = (int) 0; + mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; + shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; + for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) { + PyObject *tmp, *digit; + long idigit; + digit = PyNumber_And(stepval, mask); + if (unlikely(!digit)) goto done; + idigit = PyLong_AsLong(digit); + Py_DECREF(digit); + if (unlikely(idigit < 0)) goto done; + val |= ((int) idigit) << bits; + tmp = PyNumber_Rshift(stepval, shift); + if (unlikely(!tmp)) goto done; + Py_DECREF(stepval); stepval = tmp; + } + Py_DECREF(shift); shift = NULL; + Py_DECREF(mask); mask = NULL; + { + long idigit = PyLong_AsLong(stepval); + if (unlikely(idigit < 0)) goto done; + remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1); + if (unlikely(idigit >= (1L << remaining_bits))) + goto raise_overflow; + val |= ((int) idigit) << bits; + } + if (!is_unsigned) { + if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1)))) + goto raise_overflow; + if (is_negative) + val = ~val; + } + ret = 0; + done: + Py_XDECREF(shift); + Py_XDECREF(mask); + Py_XDECREF(stepval); +#endif + if (unlikely(ret)) + return (int) -1; + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to int"); + return (int) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to int"); + return (int) -1; +} + /* CIntFromPy */ static CYTHON_INLINE uint64_t __Pyx_PyLong_As_uint64_t(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC @@ -13501,6 +15189,75 @@ raise_neg_overflow: return (uint64_t) -1; } +/* CIntToPy */ +static CYTHON_INLINE PyObject* __Pyx_PyLong_From_unsigned_int(unsigned int value) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(unsigned int) < sizeof(long)) { + return PyLong_FromLong((long) value); + } else if (sizeof(unsigned int) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#if !CYTHON_COMPILING_IN_PYPY + } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(unsigned int) <= sizeof(long)) { + return PyLong_FromLong((long) value); + } else if (sizeof(unsigned int) <= 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(unsigned int), + 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(unsigned int)); + 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 @@ -13859,256 +15616,6 @@ raise_neg_overflow: return (long) -1; } -/* CIntFromPy */ -static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *x) { -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - const int neg_one = (int) -1, const_zero = (int) 0; -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic pop -#endif - const int is_unsigned = neg_one > const_zero; - if (unlikely(!PyLong_Check(x))) { - int val; - PyObject *tmp = __Pyx_PyNumber_Long(x); - if (!tmp) return (int) -1; - val = __Pyx_PyLong_As_int(tmp); - Py_DECREF(tmp); - return val; - } - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - if (unlikely(__Pyx_PyLong_IsNeg(x))) { - goto raise_neg_overflow; - } else if (__Pyx_PyLong_IsCompact(x)) { - __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) - } else { - const digit* digits = __Pyx_PyLong_Digits(x); - assert(__Pyx_PyLong_DigitCount(x) > 1); - switch (__Pyx_PyLong_DigitCount(x)) { - case 2: - if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) { - if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if ((8 * sizeof(int) >= 2 * PyLong_SHIFT)) { - return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - case 3: - if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) { - if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if ((8 * sizeof(int) >= 3 * PyLong_SHIFT)) { - return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - case 4: - if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) { - if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if ((8 * sizeof(int) >= 4 * PyLong_SHIFT)) { - return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - } - } -#endif -#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 - if (unlikely(Py_SIZE(x) < 0)) { - goto raise_neg_overflow; - } -#else - { - int result = PyObject_RichCompareBool(x, Py_False, Py_LT); - if (unlikely(result < 0)) - return (int) -1; - if (unlikely(result == 1)) - goto raise_neg_overflow; - } -#endif - if ((sizeof(int) <= sizeof(unsigned long))) { - __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) - } else if ((sizeof(int) <= sizeof(unsigned PY_LONG_LONG))) { - __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - if (__Pyx_PyLong_IsCompact(x)) { - __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) - } else { - const digit* digits = __Pyx_PyLong_Digits(x); - assert(__Pyx_PyLong_DigitCount(x) > 1); - switch (__Pyx_PyLong_SignedDigitCount(x)) { - case -2: - if ((8 * sizeof(int) - 1 > 1 * PyLong_SHIFT)) { - if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { - return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 2: - if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) { - if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { - return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case -3: - if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { - if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { - return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 3: - if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) { - if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { - return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case -4: - if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { - if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) { - return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 4: - if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) { - if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) { - return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - } - } -#endif - if ((sizeof(int) <= sizeof(long))) { - __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) - } else if ((sizeof(int) <= sizeof(PY_LONG_LONG))) { - __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) - } - } - { - int val; - int ret = -1; -#if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API - Py_ssize_t bytes_copied = PyLong_AsNativeBytes( - x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0)); - if (unlikely(bytes_copied == -1)) { - } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) { - goto raise_overflow; - } else { - ret = 0; - } -#elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - ret = _PyLong_AsByteArray((PyLongObject *)x, - bytes, sizeof(val), - is_little, !is_unsigned); -#else - PyObject *v; - PyObject *stepval = NULL, *mask = NULL, *shift = NULL; - int bits, remaining_bits, is_negative = 0; - int chunk_size = (sizeof(long) < 8) ? 30 : 62; - if (likely(PyLong_CheckExact(x))) { - v = __Pyx_NewRef(x); - } else { - v = PyNumber_Long(x); - if (unlikely(!v)) return (int) -1; - assert(PyLong_CheckExact(v)); - } - { - int result = PyObject_RichCompareBool(v, Py_False, Py_LT); - if (unlikely(result < 0)) { - Py_DECREF(v); - return (int) -1; - } - is_negative = result == 1; - } - if (is_unsigned && unlikely(is_negative)) { - Py_DECREF(v); - goto raise_neg_overflow; - } else if (is_negative) { - stepval = PyNumber_Invert(v); - Py_DECREF(v); - if (unlikely(!stepval)) - return (int) -1; - } else { - stepval = v; - } - v = NULL; - val = (int) 0; - mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; - shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; - for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) { - PyObject *tmp, *digit; - long idigit; - digit = PyNumber_And(stepval, mask); - if (unlikely(!digit)) goto done; - idigit = PyLong_AsLong(digit); - Py_DECREF(digit); - if (unlikely(idigit < 0)) goto done; - val |= ((int) idigit) << bits; - tmp = PyNumber_Rshift(stepval, shift); - if (unlikely(!tmp)) goto done; - Py_DECREF(stepval); stepval = tmp; - } - Py_DECREF(shift); shift = NULL; - Py_DECREF(mask); mask = NULL; - { - long idigit = PyLong_AsLong(stepval); - if (unlikely(idigit < 0)) goto done; - remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1); - if (unlikely(idigit >= (1L << remaining_bits))) - goto raise_overflow; - val |= ((int) idigit) << bits; - } - if (!is_unsigned) { - if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1)))) - goto raise_overflow; - if (is_negative) - val = ~val; - } - ret = 0; - done: - Py_XDECREF(shift); - Py_XDECREF(mask); - Py_XDECREF(stepval); -#endif - if (unlikely(ret)) - return (int) -1; - return val; - } -raise_overflow: - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to int"); - return (int) -1; -raise_neg_overflow: - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to int"); - return (int) -1; -} - /* FastTypeChecks */ #if CYTHON_COMPILING_IN_CPYTHON static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { diff --git a/src/polluck_blockchain/placeholder_native.pyx b/src/polluck_blockchain/placeholder_native.pyx index 8a27b97..3fcac5b 100644 --- a/src/polluck_blockchain/placeholder_native.pyx +++ b/src/polluck_blockchain/placeholder_native.pyx @@ -21,6 +21,7 @@ from libc.stdlib cimport malloc, free from libc.string cimport memcpy from cython.operator import postincrement, dereference cimport polluck_blockchain.openssl_evp as ossl +from cython.parallel cimport prange ctypedef unsigned long ULong @@ -57,14 +58,35 @@ cdef int serialize_uint64(unsigned char* out, unsigned long long v) except -1 no # unsigned char *ptr # size_t size +cdef const size_t NONCE_OFFSET = 16 + +cdef inline bint has_leading_zero_bits(const unsigned char *digest, int num_bits) nogil: + cdef int i, full_bytes = num_bits // 8 + cdef int rem_bits = num_bits % 8 + + for i in range(full_bytes): + if digest[i] != 0: + return False + + if rem_bits: + if digest[full_bytes] >> (8 - rem_bits) != 0: + return False + + return True + +cdef inline bint has_leading_zero_bytes(const unsigned char *digest, int num_bytes) nogil: + cdef int i, full_bytes = num_bytes // 8 + cdef int rem_bits = num_bytes % 8 + + for i in range(num_bytes): + if digest[i] != 0: + return False + + return True + + cdef class PyBlock: cdef: - # ULong _index - # double _timestamp - # string _data - # string _prev_hash - # ULong _nonce - # string _hash Block *BlockC bint ptr_owner @@ -164,7 +186,7 @@ cdef class PyBlock: def hash(self): return self.BlockC.hash.decode("UTF-8") - cdef unsigned char* bytes_serialize_c(self, size_t *size): + cdef unsigned char* bytes_serialize_c(self, size_t *size) nogil: cdef: size_t total_len unsigned char* buf @@ -179,8 +201,8 @@ cdef class PyBlock: buf = malloc(size[0] * sizeof(unsigned char)) if buf == NULL: - raise MemoryError() - + return NULL + serialize_uint64(buf + pos, self.BlockC.index) pos += 8 serialize_uint64(buf + pos, self.BlockC.timestamp) @@ -204,21 +226,13 @@ cdef class PyBlock: return buf - def bytes_serialize(self): - cdef: - unsigned char *serialize_res - size_t serialize_size - try: - serialize_res = self.bytes_serialize_c(&serialize_size) - return serialize_res[:serialize_size] - finally: - free(serialize_res) - - cdef unsigned char* digest(self, unsigned char *data, size_t data_size, size_t *digest_size): + cdef unsigned char* digest(self, unsigned char *data, size_t data_size, size_t *digest_size) nogil: cdef ossl.EVP_MD_CTX *ctx = ossl.EVP_MD_CTX_new() if ctx == NULL: - raise MemoryError() + return NULL cdef const ossl.EVP_MD *algo = ossl.EVP_sha256() + if algo == NULL: + return NULL cdef: unsigned char* digest @@ -236,15 +250,75 @@ cdef class PyBlock: ossl.EVP_MD_CTX_free(ctx) return digest + + def bytes_serialize(self): + cdef: + unsigned char *serialize_res + size_t serialize_size + try: + serialize_res = self.bytes_serialize_c(&serialize_size) + return serialize_res[:serialize_size] + finally: + free(serialize_res) + + cpdef mine(self, unsigned int difficulty, unsigned int max_nonce=0xFFFFFFFF): + cdef: + unsigned char *serial_buf + size_t serialize_size + unsigned char *digest + size_t digest_size + bint nonce_found = False + int nonce, nonce_solution = 0 + bint *p_nonce_found = &nonce_found + int *p_nonce_solution = &nonce_solution - cdef unsigned char* perform_hash_c(self, size_t *digest_size): + serial_buf = self.bytes_serialize_c(&serialize_size) + + # for nonce in prange(max_nonce, nogil=True, schedule="static", num_threads=16): + # if p_nonce_found[0]: + # break + + # serialize_uint64(serial_buf + NONCE_OFFSET, nonce) + # digest = self.digest(serial_buf, serialize_size, &digest_size) + + # if has_leading_zero_bits(digest, difficulty): + # p_nonce_found[0] = True + # p_nonce_solution[0] = nonce + # break + + # free(digest) + + with nogil: + for nonce in range(max_nonce): + serialize_uint64(serial_buf + NONCE_OFFSET, nonce) + digest = self.digest(serial_buf, serialize_size, &digest_size) + + if has_leading_zero_bits(digest, difficulty): + nonce_found = True + nonce_solution = nonce + break + + free(digest) + + if not nonce_found: + raise RuntimeError("No valid nonce found") + + self.BlockC.nonce = nonce_solution + + cdef unsigned char* perform_hash_c(self, size_t *digest_size) nogil: cdef: unsigned char *serialize_res size_t serialize_size unsigned char *digest serialize_res = self.bytes_serialize_c(&serialize_size) + if serialize_res == NULL: + return NULL digest = self.digest(serialize_res, serialize_size, digest_size) + if digest == NULL: + return NULL + + free(serialize_res) return digest @@ -255,6 +329,8 @@ cdef class PyBlock: try: digest = self.perform_hash_c(&digest_size) + if digest == NULL: + raise MemoryError() self.BlockC.hash = bytes(digest[:digest_size]).hex().encode("UTF-8") finally: free(digest)