diff --git a/setup.py b/setup.py index be71987..753aa8d 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ ext_modules = cythonize( compiler_directives={ "language_level": 3, "boundscheck": False, - "wraparound": True, + "wraparound": False, "embedsignature": False, "annotation_typing": True, "linetrace": linetrace_opt, diff --git a/src/polluck_blockchain/placeholder.c b/src/polluck_blockchain/placeholder.c index 9ecde9a..9c50f42 100644 --- a/src/polluck_blockchain/placeholder.c +++ b/src/polluck_blockchain/placeholder.c @@ -1516,6 +1516,7 @@ static const char* const __pyx_f[] = { /*--- Type declarations ---*/ struct __pyx_obj_18polluck_blockchain_11placeholder_StringHolder; struct __pyx_obj_18polluck_blockchain_11placeholder_Block; +struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain; struct __pyx_t_18polluck_blockchain_11placeholder_PyStringC; /* "polluck_blockchain/placeholder.py":15 @@ -1563,11 +1564,51 @@ struct __pyx_obj_18polluck_blockchain_11placeholder_Block { }; +/* "polluck_blockchain/placeholder.py":162 + * + * @cython.cclass + * class Blockchain: # <<<<<<<<<<<<<< + * _difficulty = cython.declare(cython.int, visibility="private") + * _index = cython.declare(cython.Py_ssize_t, visibility="private") +*/ +struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain { + PyObject_HEAD + struct __pyx_vtabstruct_18polluck_blockchain_11placeholder_Blockchain *__pyx_vtab; + int _difficulty; + Py_ssize_t _index; + PyObject *chain; +}; + + + +/* "polluck_blockchain/placeholder.py":85 + * + * @cython.cclass + * class Block: # <<<<<<<<<<<<<< + * _index = cython.declare(cython.ulong, visibility="private") + * _timestamp = cython.declare(cython.double, visibility="private") +*/ struct __pyx_vtabstruct_18polluck_blockchain_11placeholder_Block { PyObject *(*_perform_hash)(struct __pyx_obj_18polluck_blockchain_11placeholder_Block *, int __pyx_skip_dispatch); }; static struct __pyx_vtabstruct_18polluck_blockchain_11placeholder_Block *__pyx_vtabptr_18polluck_blockchain_11placeholder_Block; + + +/* "polluck_blockchain/placeholder.py":162 + * + * @cython.cclass + * class Blockchain: # <<<<<<<<<<<<<< + * _difficulty = cython.declare(cython.int, visibility="private") + * _index = cython.declare(cython.Py_ssize_t, visibility="private") +*/ + +struct __pyx_vtabstruct_18polluck_blockchain_11placeholder_Blockchain { + PyObject *(*create_genesis_block)(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *, int __pyx_skip_dispatch); + PyObject *(*proof_of_work)(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *, struct __pyx_obj_18polluck_blockchain_11placeholder_Block *, int __pyx_skip_dispatch); + struct __pyx_obj_18polluck_blockchain_11placeholder_Block *(*add_block)(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *, PyObject *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_18polluck_blockchain_11placeholder_Blockchain *__pyx_vtabptr_18polluck_blockchain_11placeholder_Blockchain; /* #### Code section: utility_code_proto ### */ /* --- Runtime support code (head) --- */ @@ -2013,22 +2054,6 @@ static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject * /* RaiseUnexpectedTypeError.proto */ static int __Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj); -/* PyObjectDelAttr.proto (used by PyObjectSetAttrStr) */ -#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000 -#define __Pyx_PyObject_DelAttr(o, n) PyObject_SetAttr(o, n, NULL) -#else -#define __Pyx_PyObject_DelAttr(o, n) PyObject_DelAttr(o, n) -#endif - -/* PyObjectSetAttrStr.proto */ -#if CYTHON_USE_TYPE_SLOTS -#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL) -static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value); -#else -#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_DelAttr(o,n) -#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v) -#endif - /* PyObjectVectorCallKwBuilder.proto */ CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n); #if CYTHON_VECTORCALL @@ -2047,7 +2072,23 @@ static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, P #define __Pyx_VectorcallBuilder_AddArgStr(key, value, builder, args, n) PyDict_SetItemString(builder, key, value) #endif -/* ListAppend.proto (used by append) */ +/* PyObjectDelAttr.proto (used by PyObjectSetAttrStr) */ +#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000 +#define __Pyx_PyObject_DelAttr(o, n) PyObject_SetAttr(o, n, NULL) +#else +#define __Pyx_PyObject_DelAttr(o, n) PyObject_DelAttr(o, n) +#endif + +/* PyObjectSetAttrStr.proto */ +#if CYTHON_USE_TYPE_SLOTS +#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL) +static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value); +#else +#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_DelAttr(o,n) +#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v) +#endif + +/* ListAppend.proto */ #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { PyListObject* L = (PyListObject*) list; @@ -2068,25 +2109,17 @@ static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { #define __Pyx_PyList_Append(L,x) PyList_Append(L,x) #endif -/* PyObjectGetMethod.proto (used by PyObjectCallMethod1) */ -#if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000))) -static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method); -#endif - -/* PyObjectCallMethod1.proto (used by append) */ -static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg); - -/* append.proto */ -static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x); - -/* PyLongBinop.proto */ -#if !CYTHON_COMPILING_IN_PYPY -static CYTHON_INLINE PyObject* __Pyx_PyLong_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check); +/* PySequenceMultiply.proto */ +#define __Pyx_PySequence_Multiply_Left(mul, seq) __Pyx_PySequence_Multiply(seq, mul) +#if !CYTHON_USE_TYPE_SLOTS +#define __Pyx_PySequence_Multiply PySequence_Repeat #else -#define __Pyx_PyLong_AddObjC(op1, op2, intval, inplace, zerodivision_check)\ - (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2)) +static CYTHON_INLINE PyObject* __Pyx_PySequence_Multiply(PyObject *seq, Py_ssize_t mul); #endif +/* ExtTypeTest.proto */ +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); + /* GetItemInt.proto */ #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ @@ -2130,9 +2163,6 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, static PyObject* __Pyx_PyUnicode_Join(PyObject** values, Py_ssize_t value_count, Py_ssize_t result_ulength, Py_UCS4 max_char); -/* ExtTypeTest.proto */ -static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); - /* AllocateExtensionType.proto */ static PyObject *__Pyx_AllocateExtensionType(PyTypeObject *t, int is_final); @@ -2158,6 +2188,11 @@ static CYTHON_INLINE int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec /* PyObjectCallNoArg.proto (used by PyObjectCallMethod0) */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); +/* PyObjectGetMethod.proto (used by PyObjectCallMethod0) */ +#if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000))) +static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method); +#endif + /* PyObjectCallMethod0.proto (used by PyType_Ready) */ static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name); @@ -2324,36 +2359,6 @@ static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, PyObject *module, PyObject *globals, PyObject* code); -/* SetNameInClass.proto */ -#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030d0000 -#define __Pyx_SetNameInClass(ns, name, value)\ - (likely(PyDict_CheckExact(ns)) ? _PyDict_SetItem_KnownHash(ns, name, value, ((PyASCIIObject *) name)->hash) : PyObject_SetItem(ns, name, value)) -#elif CYTHON_COMPILING_IN_CPYTHON -#define __Pyx_SetNameInClass(ns, name, value)\ - (likely(PyDict_CheckExact(ns)) ? PyDict_SetItem(ns, name, value) : PyObject_SetItem(ns, name, value)) -#else -#define __Pyx_SetNameInClass(ns, name, value) PyObject_SetItem(ns, name, value) -#endif - -/* CalculateMetaclass.proto (used by Py3ClassCreate) */ -static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases); - -/* PyObjectLookupSpecial.proto (used by Py3ClassCreate) */ -#if CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS -#define __Pyx_PyObject_LookupSpecialNoError(obj, attr_name) __Pyx__PyObject_LookupSpecial(obj, attr_name, 0) -#define __Pyx_PyObject_LookupSpecial(obj, attr_name) __Pyx__PyObject_LookupSpecial(obj, attr_name, 1) -static CYTHON_INLINE PyObject* __Pyx__PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name, int with_error); -#else -#define __Pyx_PyObject_LookupSpecialNoError(o,n) __Pyx_PyObject_GetAttrStrNoError(o,n) -#define __Pyx_PyObject_LookupSpecial(o,n) __Pyx_PyObject_GetAttrStr(o,n) -#endif - -/* Py3ClassCreate.proto */ -static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname, - PyObject *mkw, PyObject *modname, PyObject *doc); -static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict, - PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass); - /* CLineInTraceback.proto (used by AddTraceback) */ #if CYTHON_CLINE_IN_TRACEBACK && CYTHON_CLINE_IN_TRACEBACK_RUNTIME static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); @@ -2406,9 +2411,18 @@ static CYTHON_INLINE unsigned long __Pyx_PyLong_As_unsigned_long(PyObject *); /* CIntFromPy.proto */ static CYTHON_INLINE long __Pyx_PyLong_As_long(PyObject *); +/* CIntFromPy.proto */ +static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *); + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyLong_From_int(int value); + /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value); +/* PyObjectCallMethod1.proto */ +static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg); + /* UpdateUnpickledDict.proto */ static int __Pyx_UpdateUnpickledDict(PyObject *obj, PyObject *state, Py_ssize_t index); @@ -2429,9 +2443,6 @@ typedef const char *__Pyx_TypeName; #define __Pyx_DECREF_TypeName(obj) #endif -/* 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) @@ -2519,6 +2530,9 @@ static int __Pyx_State_RemoveModule(void*); #define __PYX_TYPE_MODULE_PREFIX __PYX_ABI_MODULE_NAME "." static PyObject *__pyx_f_18polluck_blockchain_11placeholder_5Block__perform_hash(struct __pyx_obj_18polluck_blockchain_11placeholder_Block *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_18polluck_blockchain_11placeholder_10Blockchain_create_genesis_block(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_18polluck_blockchain_11placeholder_10Blockchain_proof_of_work(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *__pyx_v_self, struct __pyx_obj_18polluck_blockchain_11placeholder_Block *__pyx_v_block, int __pyx_skip_dispatch); /* proto*/ +static struct __pyx_obj_18polluck_blockchain_11placeholder_Block *__pyx_f_18polluck_blockchain_11placeholder_10Blockchain_add_block(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *__pyx_v_self, PyObject *__pyx_v_data, int __pyx_skip_dispatch); /* proto*/ /* Module declarations from "cython" */ @@ -2560,13 +2574,19 @@ static PyObject *__pyx_pf_18polluck_blockchain_11placeholder_5Block_4hash___get_ static int __pyx_pf_18polluck_blockchain_11placeholder_5Block_4hash_2__set__(struct __pyx_obj_18polluck_blockchain_11placeholder_Block *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_18polluck_blockchain_11placeholder_5Block_8__reduce_cython__(struct __pyx_obj_18polluck_blockchain_11placeholder_Block *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_18polluck_blockchain_11placeholder_5Block_10__setstate_cython__(struct __pyx_obj_18polluck_blockchain_11placeholder_Block *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */ -static PyObject *__pyx_pf_18polluck_blockchain_11placeholder_10Blockchain___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_difficulty); /* proto */ -static PyObject *__pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_2create_genesis_block(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_4proof_of_work(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, struct __pyx_obj_18polluck_blockchain_11placeholder_Block *__pyx_v_block); /* proto */ -static struct __pyx_obj_18polluck_blockchain_11placeholder_Block *__pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_6add_block(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_data); /* proto */ +static int __pyx_pf_18polluck_blockchain_11placeholder_10Blockchain___cinit__(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *__pyx_v_self); /* proto */ +static int __pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_2__init__(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *__pyx_v_self, PyObject *__pyx_v_difficulty); /* proto */ +static PyObject *__pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_5index___get__(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_10difficulty___get__(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_4create_genesis_block(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_6proof_of_work(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *__pyx_v_self, struct __pyx_obj_18polluck_blockchain_11placeholder_Block *__pyx_v_block); /* proto */ +static PyObject *__pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_8add_block(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *__pyx_v_self, PyObject *__pyx_v_data); /* proto */ +static PyObject *__pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_10__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_12__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_pf_18polluck_blockchain_11placeholder___pyx_unpickle_Block(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_tp_new_18polluck_blockchain_11placeholder_StringHolder(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_18polluck_blockchain_11placeholder_Block(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_18polluck_blockchain_11placeholder_Blockchain(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ /* #### Code section: late_includes ### */ /* #### Code section: module_state ### */ /* SmallCodeConfig */ @@ -2589,15 +2609,17 @@ typedef struct { PyObject *__pyx_empty_unicode; PyObject *__pyx_type_18polluck_blockchain_11placeholder_StringHolder; PyObject *__pyx_type_18polluck_blockchain_11placeholder_Block; + PyObject *__pyx_type_18polluck_blockchain_11placeholder_Blockchain; PyTypeObject *__pyx_ptype_18polluck_blockchain_11placeholder_StringHolder; PyTypeObject *__pyx_ptype_18polluck_blockchain_11placeholder_Block; + PyTypeObject *__pyx_ptype_18polluck_blockchain_11placeholder_Blockchain; __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_items; __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_pop; __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_values; __Pyx_CachedCFunction __pyx_umethod_PyByteArray_Type__extend; - PyObject *__pyx_tuple[5]; - PyObject *__pyx_codeobj_tab[12]; - PyObject *__pyx_string_tab[128]; + PyObject *__pyx_tuple[4]; + PyObject *__pyx_codeobj_tab[13]; + PyObject *__pyx_string_tab[115]; PyObject *__pyx_number_tab[6]; /* #### Code section: module_state_contents ### */ /* CommonTypesMetaclass.module_state_decls */ @@ -2665,108 +2687,95 @@ static __pyx_mstatetype * const __pyx_mstate_global = &__pyx_mstate_global_stati #define __pyx_n_u_Block_compute_hash __pyx_string_tab[23] #define __pyx_n_u_Block_compute_hash_bytes __pyx_string_tab[24] #define __pyx_n_u_Blockchain __pyx_string_tab[25] -#define __pyx_n_u_Blockchain___init __pyx_string_tab[26] -#define __pyx_n_u_Blockchain_add_block __pyx_string_tab[27] -#define __pyx_n_u_Blockchain_create_genesis_block __pyx_string_tab[28] -#define __pyx_n_u_Blockchain_proof_of_work __pyx_string_tab[29] -#define __pyx_n_u_None __pyx_string_tab[30] +#define __pyx_n_u_Blockchain___reduce_cython __pyx_string_tab[26] +#define __pyx_n_u_Blockchain___setstate_cython __pyx_string_tab[27] +#define __pyx_n_u_Blockchain_add_block __pyx_string_tab[28] +#define __pyx_n_u_Blockchain_create_genesis_block __pyx_string_tab[29] +#define __pyx_n_u_Blockchain_proof_of_work __pyx_string_tab[30] #define __pyx_n_u_Pyx_PyDict_NextRef __pyx_string_tab[31] #define __pyx_n_u_StringHolder __pyx_string_tab[32] #define __pyx_n_u_StringHolder___reduce_cython __pyx_string_tab[33] #define __pyx_n_u_StringHolder___setstate_cython __pyx_string_tab[34] #define __pyx_n_u_TIMEZONE_UTC __pyx_string_tab[35] #define __pyx_n_u_add_block __pyx_string_tab[36] -#define __pyx_n_u_append __pyx_string_tab[37] -#define __pyx_n_u_asyncio_coroutines __pyx_string_tab[38] -#define __pyx_n_u_big __pyx_string_tab[39] -#define __pyx_n_u_block __pyx_string_tab[40] -#define __pyx_n_u_block_hash __pyx_string_tab[41] -#define __pyx_n_u_chain __pyx_string_tab[42] -#define __pyx_n_u_cline_in_traceback __pyx_string_tab[43] -#define __pyx_n_u_compute_hash __pyx_string_tab[44] -#define __pyx_n_u_compute_hash_bytes __pyx_string_tab[45] -#define __pyx_n_u_create_genesis_block __pyx_string_tab[46] -#define __pyx_n_u_data __pyx_string_tab[47] -#define __pyx_n_u_datetime __pyx_string_tab[48] -#define __pyx_n_u_dict __pyx_string_tab[49] -#define __pyx_n_u_dict_2 __pyx_string_tab[50] -#define __pyx_n_u_difficulty __pyx_string_tab[51] -#define __pyx_n_u_digest __pyx_string_tab[52] -#define __pyx_n_u_doc __pyx_string_tab[53] -#define __pyx_n_u_dopt_basics __pyx_string_tab[54] -#define __pyx_n_u_dopt_basics_datetime __pyx_string_tab[55] -#define __pyx_n_u_extend __pyx_string_tab[56] -#define __pyx_n_u_fromtimestamp __pyx_string_tab[57] -#define __pyx_n_u_func __pyx_string_tab[58] -#define __pyx_n_u_genesis __pyx_string_tab[59] -#define __pyx_n_u_getstate __pyx_string_tab[60] -#define __pyx_n_u_hash __pyx_string_tab[61] -#define __pyx_n_u_hashlib __pyx_string_tab[62] -#define __pyx_n_u_hexdigest __pyx_string_tab[63] -#define __pyx_n_u_index __pyx_string_tab[64] -#define __pyx_n_u_init __pyx_string_tab[65] -#define __pyx_n_u_int __pyx_string_tab[66] -#define __pyx_n_u_is_coroutine __pyx_string_tab[67] -#define __pyx_n_u_items __pyx_string_tab[68] -#define __pyx_n_u_length __pyx_string_tab[69] -#define __pyx_n_u_main __pyx_string_tab[70] -#define __pyx_n_u_metaclass __pyx_string_tab[71] -#define __pyx_n_u_module __pyx_string_tab[72] -#define __pyx_n_u_name __pyx_string_tab[73] -#define __pyx_n_u_new __pyx_string_tab[74] -#define __pyx_n_u_new_block __pyx_string_tab[75] -#define __pyx_n_u_nonce __pyx_string_tab[76] -#define __pyx_n_u_pack __pyx_string_tab[77] -#define __pyx_n_u_perform_hash __pyx_string_tab[78] -#define __pyx_n_u_polluck_blockchain_placeholder __pyx_string_tab[79] -#define __pyx_n_u_pop __pyx_string_tab[80] -#define __pyx_n_u_prefix __pyx_string_tab[81] -#define __pyx_n_u_prepare __pyx_string_tab[82] -#define __pyx_n_u_previous_hash __pyx_string_tab[83] -#define __pyx_n_u_print __pyx_string_tab[84] -#define __pyx_n_u_proof_of_work __pyx_string_tab[85] -#define __pyx_n_u_ptr __pyx_string_tab[86] -#define __pyx_n_u_py_bytes __pyx_string_tab[87] -#define __pyx_n_u_py_string __pyx_string_tab[88] -#define __pyx_n_u_pyx_checksum __pyx_string_tab[89] -#define __pyx_n_u_pyx_result __pyx_string_tab[90] -#define __pyx_n_u_pyx_state __pyx_string_tab[91] -#define __pyx_n_u_pyx_type __pyx_string_tab[92] -#define __pyx_n_u_pyx_unpickle_Block __pyx_string_tab[93] -#define __pyx_n_u_pyx_vtable __pyx_string_tab[94] -#define __pyx_n_u_qualname __pyx_string_tab[95] -#define __pyx_n_u_reduce __pyx_string_tab[96] -#define __pyx_n_u_reduce_cython __pyx_string_tab[97] -#define __pyx_n_u_reduce_ex __pyx_string_tab[98] -#define __pyx_n_u_return __pyx_string_tab[99] -#define __pyx_n_u_self __pyx_string_tab[100] -#define __pyx_n_u_set_name __pyx_string_tab[101] -#define __pyx_n_u_setdefault __pyx_string_tab[102] -#define __pyx_n_u_setstate __pyx_string_tab[103] -#define __pyx_n_u_setstate_cython __pyx_string_tab[104] -#define __pyx_n_u_sha256 __pyx_string_tab[105] -#define __pyx_n_u_startswith __pyx_string_tab[106] -#define __pyx_n_u_state __pyx_string_tab[107] -#define __pyx_n_u_str __pyx_string_tab[108] -#define __pyx_n_u_struct __pyx_string_tab[109] -#define __pyx_n_u_test __pyx_string_tab[110] -#define __pyx_n_u_time __pyx_string_tab[111] -#define __pyx_n_u_timestamp __pyx_string_tab[112] -#define __pyx_n_u_to_bytes __pyx_string_tab[113] -#define __pyx_n_u_update __pyx_string_tab[114] -#define __pyx_n_u_use_setstate __pyx_string_tab[115] -#define __pyx_n_u_values __pyx_string_tab[116] -#define __pyx_kp_b_iso88591_1F __pyx_string_tab[117] -#define __pyx_kp_b_iso88591_A_A_N __pyx_string_tab[118] -#define __pyx_kp_b_iso88591_A_Rt1_m1_z_AQ_q_1 __pyx_string_tab[119] -#define __pyx_kp_b_iso88591_A_WAT_Q_WA_1D_WAT_q_WAT_A_WAT_Q __pyx_string_tab[120] -#define __pyx_kp_b_iso88591_A_q_xwm1_F __pyx_string_tab[121] -#define __pyx_kp_b_iso88591_A_t_7 __pyx_string_tab[122] -#define __pyx_kp_b_iso88591_A_t_Q __pyx_string_tab[123] -#define __pyx_kp_b_iso88591_Q __pyx_string_tab[124] -#define __pyx_kp_b_iso88591_T_XT_it_PTTU_G1F_a_vWE_Q_q_q_d __pyx_string_tab[125] -#define __pyx_kp_b_iso88591_ha_E_Qd_fBb_1A_F_QnAY_9_1_q __pyx_string_tab[126] -#define __pyx_kp_b_iso88591_q_0_kQR_5_7_q_a_1 __pyx_string_tab[127] +#define __pyx_n_u_asyncio_coroutines __pyx_string_tab[37] +#define __pyx_n_u_big __pyx_string_tab[38] +#define __pyx_n_u_block __pyx_string_tab[39] +#define __pyx_n_u_cline_in_traceback __pyx_string_tab[40] +#define __pyx_n_u_compute_hash __pyx_string_tab[41] +#define __pyx_n_u_compute_hash_bytes __pyx_string_tab[42] +#define __pyx_n_u_create_genesis_block __pyx_string_tab[43] +#define __pyx_n_u_data __pyx_string_tab[44] +#define __pyx_n_u_datetime __pyx_string_tab[45] +#define __pyx_n_u_dict __pyx_string_tab[46] +#define __pyx_n_u_dict_2 __pyx_string_tab[47] +#define __pyx_n_u_difficulty __pyx_string_tab[48] +#define __pyx_n_u_digest __pyx_string_tab[49] +#define __pyx_n_u_dopt_basics __pyx_string_tab[50] +#define __pyx_n_u_dopt_basics_datetime __pyx_string_tab[51] +#define __pyx_n_u_extend __pyx_string_tab[52] +#define __pyx_n_u_fromtimestamp __pyx_string_tab[53] +#define __pyx_n_u_func __pyx_string_tab[54] +#define __pyx_n_u_getstate __pyx_string_tab[55] +#define __pyx_n_u_hash __pyx_string_tab[56] +#define __pyx_n_u_hashlib __pyx_string_tab[57] +#define __pyx_n_u_hexdigest __pyx_string_tab[58] +#define __pyx_n_u_index __pyx_string_tab[59] +#define __pyx_n_u_is_coroutine __pyx_string_tab[60] +#define __pyx_n_u_items __pyx_string_tab[61] +#define __pyx_n_u_length __pyx_string_tab[62] +#define __pyx_n_u_main __pyx_string_tab[63] +#define __pyx_n_u_module __pyx_string_tab[64] +#define __pyx_n_u_name __pyx_string_tab[65] +#define __pyx_n_u_new __pyx_string_tab[66] +#define __pyx_n_u_nonce __pyx_string_tab[67] +#define __pyx_n_u_pack __pyx_string_tab[68] +#define __pyx_n_u_perform_hash __pyx_string_tab[69] +#define __pyx_n_u_polluck_blockchain_placeholder __pyx_string_tab[70] +#define __pyx_n_u_pop __pyx_string_tab[71] +#define __pyx_n_u_previous_hash __pyx_string_tab[72] +#define __pyx_n_u_print __pyx_string_tab[73] +#define __pyx_n_u_proof_of_work __pyx_string_tab[74] +#define __pyx_n_u_ptr __pyx_string_tab[75] +#define __pyx_n_u_py_bytes __pyx_string_tab[76] +#define __pyx_n_u_py_string __pyx_string_tab[77] +#define __pyx_n_u_pyx_checksum __pyx_string_tab[78] +#define __pyx_n_u_pyx_result __pyx_string_tab[79] +#define __pyx_n_u_pyx_state __pyx_string_tab[80] +#define __pyx_n_u_pyx_type __pyx_string_tab[81] +#define __pyx_n_u_pyx_unpickle_Block __pyx_string_tab[82] +#define __pyx_n_u_pyx_vtable __pyx_string_tab[83] +#define __pyx_n_u_qualname __pyx_string_tab[84] +#define __pyx_n_u_reduce __pyx_string_tab[85] +#define __pyx_n_u_reduce_cython __pyx_string_tab[86] +#define __pyx_n_u_reduce_ex __pyx_string_tab[87] +#define __pyx_n_u_self __pyx_string_tab[88] +#define __pyx_n_u_set_name __pyx_string_tab[89] +#define __pyx_n_u_setdefault __pyx_string_tab[90] +#define __pyx_n_u_setstate __pyx_string_tab[91] +#define __pyx_n_u_setstate_cython __pyx_string_tab[92] +#define __pyx_n_u_sha256 __pyx_string_tab[93] +#define __pyx_n_u_startswith __pyx_string_tab[94] +#define __pyx_n_u_state __pyx_string_tab[95] +#define __pyx_n_u_str __pyx_string_tab[96] +#define __pyx_n_u_struct __pyx_string_tab[97] +#define __pyx_n_u_test __pyx_string_tab[98] +#define __pyx_n_u_time __pyx_string_tab[99] +#define __pyx_n_u_timestamp __pyx_string_tab[100] +#define __pyx_n_u_to_bytes __pyx_string_tab[101] +#define __pyx_n_u_update __pyx_string_tab[102] +#define __pyx_n_u_use_setstate __pyx_string_tab[103] +#define __pyx_n_u_values __pyx_string_tab[104] +#define __pyx_kp_b_iso88591_1F __pyx_string_tab[105] +#define __pyx_kp_b_iso88591_A_D_at81_E_4xr_1A_F_Kq_QnAY_9_1 __pyx_string_tab[106] +#define __pyx_kp_b_iso88591_A_Rt1_m1_z_AQ_q_A __pyx_string_tab[107] +#define __pyx_kp_b_iso88591_A_WAT_Q_WA_1D_WAT_q_WAT_A_WAT_Q __pyx_string_tab[108] +#define __pyx_kp_b_iso88591_A_q_xwm1_F __pyx_string_tab[109] +#define __pyx_kp_b_iso88591_A_t_7 __pyx_string_tab[110] +#define __pyx_kp_b_iso88591_A_t_Q __pyx_string_tab[111] +#define __pyx_kp_b_iso88591_Q __pyx_string_tab[112] +#define __pyx_kp_b_iso88591_T_XT_it_PTTU_G1F_a_vWE_Q_q_q_d __pyx_string_tab[113] +#define __pyx_kp_b_iso88591_q_0_kQR_5_7_q_a_1 __pyx_string_tab[114] #define __pyx_int_0 __pyx_number_tab[0] #define __pyx_int_1 __pyx_number_tab[1] #define __pyx_int_8 __pyx_number_tab[2] @@ -2791,9 +2800,11 @@ static CYTHON_SMALL_CODE int __pyx_m_clear(PyObject *m) { Py_CLEAR(clear_module_state->__pyx_type_18polluck_blockchain_11placeholder_StringHolder); Py_CLEAR(clear_module_state->__pyx_ptype_18polluck_blockchain_11placeholder_Block); Py_CLEAR(clear_module_state->__pyx_type_18polluck_blockchain_11placeholder_Block); - for (int i=0; i<5; ++i) { Py_CLEAR(clear_module_state->__pyx_tuple[i]); } - for (int i=0; i<12; ++i) { Py_CLEAR(clear_module_state->__pyx_codeobj_tab[i]); } - for (int i=0; i<128; ++i) { Py_CLEAR(clear_module_state->__pyx_string_tab[i]); } + Py_CLEAR(clear_module_state->__pyx_ptype_18polluck_blockchain_11placeholder_Blockchain); + Py_CLEAR(clear_module_state->__pyx_type_18polluck_blockchain_11placeholder_Blockchain); + for (int i=0; i<4; ++i) { Py_CLEAR(clear_module_state->__pyx_tuple[i]); } + for (int i=0; i<13; ++i) { Py_CLEAR(clear_module_state->__pyx_codeobj_tab[i]); } + for (int i=0; i<115; ++i) { Py_CLEAR(clear_module_state->__pyx_string_tab[i]); } for (int i=0; i<6; ++i) { Py_CLEAR(clear_module_state->__pyx_number_tab[i]); } /* #### Code section: module_state_clear_contents ### */ /* CommonTypesMetaclass.module_state_clear */ @@ -2821,9 +2832,11 @@ static CYTHON_SMALL_CODE int __pyx_m_traverse(PyObject *m, visitproc visit, void Py_VISIT(traverse_module_state->__pyx_type_18polluck_blockchain_11placeholder_StringHolder); Py_VISIT(traverse_module_state->__pyx_ptype_18polluck_blockchain_11placeholder_Block); Py_VISIT(traverse_module_state->__pyx_type_18polluck_blockchain_11placeholder_Block); - for (int i=0; i<5; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_tuple[i]); } - for (int i=0; i<12; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_codeobj_tab[i]); } - for (int i=0; i<128; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_string_tab[i]); } + Py_VISIT(traverse_module_state->__pyx_ptype_18polluck_blockchain_11placeholder_Blockchain); + Py_VISIT(traverse_module_state->__pyx_type_18polluck_blockchain_11placeholder_Blockchain); + for (int i=0; i<4; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_tuple[i]); } + for (int i=0; i<13; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_codeobj_tab[i]); } + for (int i=0; i<115; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_string_tab[i]); } for (int i=0; i<6; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_number_tab[i]); } /* #### Code section: module_state_traverse_contents ### */ /* CommonTypesMetaclass.module_state_traverse */ @@ -5500,95 +5513,124 @@ static PyObject *__pyx_pf_18polluck_blockchain_11placeholder_5Block_10__setstate return __pyx_r; } -/* "polluck_blockchain/placeholder.py":162 +/* "polluck_blockchain/placeholder.py":167 + * chain = cython.declare(list[Block]) + * + * def __cinit__(self): # <<<<<<<<<<<<<< + * self._index = 0 + * +*/ + +/* Python wrapper */ +static int __pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + CYTHON_UNUSED Py_ssize_t __pyx_nargs; + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + #if CYTHON_ASSUME_SAFE_SIZE + __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); + #else + __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return -1; + #endif + __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); + if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, __pyx_nargs); return -1; } + const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_VARARGS(__pyx_kwds) : 0; + if (unlikely(__pyx_kwds_len < 0)) return -1; + if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("__cinit__", __pyx_kwds); return -1;} + __pyx_r = __pyx_pf_18polluck_blockchain_11placeholder_10Blockchain___cinit__(((struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_18polluck_blockchain_11placeholder_10Blockchain___cinit__(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *__pyx_v_self) { + int __pyx_r; + + /* "polluck_blockchain/placeholder.py":168 + * + * def __cinit__(self): + * self._index = 0 # <<<<<<<<<<<<<< + * + * def __init__( +*/ + __pyx_v_self->_index = 0; + + /* "polluck_blockchain/placeholder.py":167 + * chain = cython.declare(list[Block]) + * + * def __cinit__(self): # <<<<<<<<<<<<<< + * self._index = 0 + * +*/ + + /* function exit code */ + __pyx_r = 0; + return __pyx_r; +} + +/* "polluck_blockchain/placeholder.py":170 + * self._index = 0 * - * class Blockchain: * def __init__( # <<<<<<<<<<<<<< * self, * difficulty: int = 1, */ /* Python wrapper */ -static PyObject *__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_1__init__(PyObject *__pyx_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_11placeholder_10Blockchain_1__init__ = {"__init__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_1__init__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_1__init__(PyObject *__pyx_self, -#if CYTHON_METH_FASTCALL -PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds -#else -PyObject *__pyx_args, PyObject *__pyx_kwds -#endif -) { - PyObject *__pyx_v_self = 0; +static int __pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_difficulty = 0; - #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; - #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; - PyObject* values[2] = {0,0}; + PyObject* values[1] = {0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - PyObject *__pyx_r = 0; + int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (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; + __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return -1; #endif - #endif - __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); + __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); { - PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_difficulty,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, 162, __pyx_L3_error) + PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_difficulty,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, 170, __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, 162, __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, 162, __pyx_L3_error) + values[0] = __Pyx_ArgRef_VARARGS(__pyx_args, 0); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 170, __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, "__init__", 0) < (0)) __PYX_ERR(0, 162, __pyx_L3_error) - if (!values[1]) values[1] = __Pyx_NewRef(((PyObject*)((PyObject*)__pyx_mstate_global->__pyx_int_1))); - for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { - if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, i); __PYX_ERR(0, 162, __pyx_L3_error) } - } + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "__init__", 0) < (0)) __PYX_ERR(0, 170, __pyx_L3_error) + if (!values[0]) values[0] = __Pyx_NewRef(((PyObject*)__pyx_mstate_global->__pyx_int_1)); } 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, 162, __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, 162, __pyx_L3_error) - break; + values[0] = __Pyx_ArgRef_VARARGS(__pyx_args, 0); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 170, __pyx_L3_error) + CYTHON_FALLTHROUGH; + case 0: break; default: goto __pyx_L5_argtuple_error; } - if (!values[1]) values[1] = __Pyx_NewRef(((PyObject*)((PyObject*)__pyx_mstate_global->__pyx_int_1))); + if (!values[0]) values[0] = __Pyx_NewRef(((PyObject*)__pyx_mstate_global->__pyx_int_1)); } - __pyx_v_self = values[0]; - if (__Pyx_PyInt_FromNumber(&values[1], "difficulty", 0) < (0)) __PYX_ERR(0, 164, __pyx_L3_error) - __pyx_v_difficulty = ((PyObject*)values[1]); + if (__Pyx_PyInt_FromNumber(&values[0], "difficulty", 0) < (0)) __PYX_ERR(0, 172, __pyx_L3_error) + __pyx_v_difficulty = ((PyObject*)values[0]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 162, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 1, __pyx_nargs); __PYX_ERR(0, 170, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -5597,15 +5639,15 @@ PyObject *__pyx_args, PyObject *__pyx_kwds } __Pyx_AddTraceback("polluck_blockchain.placeholder.Blockchain.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); - return NULL; + return -1; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_difficulty), (&PyLong_Type), 0, "difficulty", 2))) __PYX_ERR(0, 164, __pyx_L1_error) - __pyx_r = __pyx_pf_18polluck_blockchain_11placeholder_10Blockchain___init__(__pyx_self, __pyx_v_self, __pyx_v_difficulty); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_difficulty), (&PyLong_Type), 0, "difficulty", 2))) __PYX_ERR(0, 172, __pyx_L1_error) + __pyx_r = __pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_2__init__(((struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *)__pyx_v_self), __pyx_v_difficulty); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; - __pyx_r = NULL; + __pyx_r = -1; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } @@ -5619,50 +5661,119 @@ PyObject *__pyx_args, PyObject *__pyx_kwds return __pyx_r; } -static PyObject *__pyx_pf_18polluck_blockchain_11placeholder_10Blockchain___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_difficulty) { - PyObject *__pyx_r = NULL; +static int __pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_2__init__(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *__pyx_v_self, PyObject *__pyx_v_difficulty) { + int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); - /* "polluck_blockchain/placeholder.py":166 + /* "polluck_blockchain/placeholder.py":174 * difficulty: int = 1, * ) -> None: * self.chain: list[Block] = [] # <<<<<<<<<<<<<< * # self.difficulty = difficulty.to_bytes(8, "big") - * self.difficulty = difficulty + * self._difficulty = difficulty */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error) + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 174, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_chain, __pyx_t_1) < (0)) __PYX_ERR(0, 166, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->chain); + __Pyx_DECREF(__pyx_v_self->chain); + __pyx_v_self->chain = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; - /* "polluck_blockchain/placeholder.py":168 + /* "polluck_blockchain/placeholder.py":176 * self.chain: list[Block] = [] * # self.difficulty = difficulty.to_bytes(8, "big") - * self.difficulty = difficulty # <<<<<<<<<<<<<< + * self._difficulty = difficulty # <<<<<<<<<<<<<< * - * def create_genesis_block(self): + * @property */ - if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_difficulty, __pyx_v_difficulty) < (0)) __PYX_ERR(0, 168, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyLong_As_int(__pyx_v_difficulty); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 176, __pyx_L1_error) + __pyx_v_self->_difficulty = __pyx_t_2; - /* "polluck_blockchain/placeholder.py":162 + /* "polluck_blockchain/placeholder.py":170 + * self._index = 0 * - * class Blockchain: * def __init__( # <<<<<<<<<<<<<< * self, * difficulty: int = 1, */ /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("polluck_blockchain.placeholder.Blockchain.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "polluck_blockchain/placeholder.py":178 + * self._difficulty = difficulty + * + * @property # <<<<<<<<<<<<<< + * def index(self): + * return self._index +*/ + +/* Python wrapper */ +static PyObject *__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_5index_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_5index_1__get__(PyObject *__pyx_v_self) { + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); + __pyx_r = __pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_5index___get__(((struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_5index___get__(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "polluck_blockchain/placeholder.py":180 + * @property + * def index(self): + * return self._index # <<<<<<<<<<<<<< + * + * @property +*/ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyLong_FromSsize_t(__pyx_v_self->_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "polluck_blockchain/placeholder.py":178 + * self._difficulty = difficulty + * + * @property # <<<<<<<<<<<<<< + * def index(self): + * return self._index +*/ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("polluck_blockchain.placeholder.Blockchain.index.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -5670,39 +5781,265 @@ static PyObject *__pyx_pf_18polluck_blockchain_11placeholder_10Blockchain___init return __pyx_r; } -/* "polluck_blockchain/placeholder.py":170 - * self.difficulty = difficulty +/* "polluck_blockchain/placeholder.py":182 + * return self._index * - * def create_genesis_block(self): # <<<<<<<<<<<<<< - * genesis = Block( - * index=0, + * @property # <<<<<<<<<<<<<< + * def difficulty(self): + * return self._difficulty */ /* Python wrapper */ -static PyObject *__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_3create_genesis_block(PyObject *__pyx_self, +static PyObject *__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_10difficulty_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_10difficulty_1__get__(PyObject *__pyx_v_self) { + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); + __pyx_r = __pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_10difficulty___get__(((struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_10difficulty___get__(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "polluck_blockchain/placeholder.py":184 + * @property + * def difficulty(self): + * return self._difficulty # <<<<<<<<<<<<<< + * + * @cython.ccall +*/ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyLong_From_int(__pyx_v_self->_difficulty); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "polluck_blockchain/placeholder.py":182 + * return self._index + * + * @property # <<<<<<<<<<<<<< + * def difficulty(self): + * return self._difficulty +*/ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("polluck_blockchain.placeholder.Blockchain.difficulty.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "polluck_blockchain/placeholder.py":186 + * return self._difficulty + * + * @cython.ccall # <<<<<<<<<<<<<< + * def create_genesis_block(self): + * genesis = Block( +*/ + +static PyObject *__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_5create_genesis_block(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -static PyMethodDef __pyx_mdef_18polluck_blockchain_11placeholder_10Blockchain_3create_genesis_block = {"create_genesis_block", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_3create_genesis_block, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_3create_genesis_block(PyObject *__pyx_self, +static PyObject *__pyx_f_18polluck_blockchain_11placeholder_10Blockchain_create_genesis_block(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *__pyx_v_self, int __pyx_skip_dispatch) { + struct __pyx_obj_18polluck_blockchain_11placeholder_Block *__pyx_v_genesis = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + size_t __pyx_t_5; + int __pyx_t_6; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("create_genesis_block", 0); + /* 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_11placeholder_Blockchain && + __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_create_genesis_block); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 186, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!__Pyx_IsSameCFunction(__pyx_t_1, (void(*)(void)) __pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_5create_genesis_block)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = NULL; + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; + __pyx_t_5 = 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_5 = 0; + } + #endif + { + PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; + __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, 186, __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.py":188 + * @cython.ccall + * def create_genesis_block(self): + * genesis = Block( # <<<<<<<<<<<<<< + * index=0, + * data="Genesis Block", +*/ + __pyx_t_2 = NULL; + __pyx_t_5 = 1; + { + PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 4 : 0)] = {__pyx_t_2, NULL}; + __pyx_t_4 = __Pyx_MakeVectorcallBuilderKwds(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 188, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_index, __pyx_mstate_global->__pyx_int_0, __pyx_t_4, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 188, __pyx_L1_error) + if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_data, __pyx_mstate_global->__pyx_kp_u_Genesis_Block, __pyx_t_4, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 188, __pyx_L1_error) + if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_previous_hash, __pyx_mstate_global->__pyx_kp_u_0, __pyx_t_4, __pyx_callargs+1, 2) < (0)) __PYX_ERR(0, 188, __pyx_L1_error) + if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_nonce, __pyx_mstate_global->__pyx_int_0, __pyx_t_4, __pyx_callargs+1, 3) < (0)) __PYX_ERR(0, 188, __pyx_L1_error) + __pyx_t_1 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_ptype_18polluck_blockchain_11placeholder_Block, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_4); + __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, 188, __pyx_L1_error) + __Pyx_GOTREF((PyObject *)__pyx_t_1); + } + __pyx_v_genesis = ((struct __pyx_obj_18polluck_blockchain_11placeholder_Block *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "polluck_blockchain/placeholder.py":194 + * nonce=0, + * ) + * genesis.hash = genesis.compute_hash() # <<<<<<<<<<<<<< + * self.chain.append(genesis) + * +*/ + __pyx_t_4 = ((PyObject *)__pyx_v_genesis); + __Pyx_INCREF(__pyx_t_4); + __pyx_t_5 = 0; + { + PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; + __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_compute_hash, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 194, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + } + if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_genesis), __pyx_mstate_global->__pyx_n_u_hash, __pyx_t_1) < (0)) __PYX_ERR(0, 194, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "polluck_blockchain/placeholder.py":195 + * ) + * genesis.hash = genesis.compute_hash() + * self.chain.append(genesis) # <<<<<<<<<<<<<< + * + * @cython.ccall +*/ + if (unlikely(__pyx_v_self->chain == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "append"); + __PYX_ERR(0, 195, __pyx_L1_error) + } + __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_self->chain, ((PyObject *)__pyx_v_genesis)); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 195, __pyx_L1_error) + + /* "polluck_blockchain/placeholder.py":186 + * return self._difficulty + * + * @cython.ccall # <<<<<<<<<<<<<< + * def create_genesis_block(self): + * genesis = Block( +*/ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("polluck_blockchain.placeholder.Blockchain.create_genesis_block", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_genesis); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_5create_genesis_block(PyObject *__pyx_v_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +); /*proto*/ +static PyMethodDef __pyx_mdef_18polluck_blockchain_11placeholder_10Blockchain_5create_genesis_block = {"create_genesis_block", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_5create_genesis_block, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_5create_genesis_block(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { - PyObject *__pyx_v_self = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; - PyObject* values[1] = {0}; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("create_genesis_block (wrapper)", 0); @@ -5714,182 +6051,279 @@ PyObject *__pyx_args, PyObject *__pyx_kwds #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); - { - PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,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, 170, __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, 170, __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, "create_genesis_block", 0) < (0)) __PYX_ERR(0, 170, __pyx_L3_error) - for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { - if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("create_genesis_block", 1, 1, 1, i); __PYX_ERR(0, 170, __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, 170, __pyx_L3_error) - } - __pyx_v_self = values[0]; - } - goto __pyx_L6_skip; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("create_genesis_block", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 170, __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.Blockchain.create_genesis_block", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_2create_genesis_block(__pyx_self, __pyx_v_self); + if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("create_genesis_block", 1, 0, 0, __pyx_nargs); return NULL; } + const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; + if (unlikely(__pyx_kwds_len < 0)) return NULL; + if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("create_genesis_block", __pyx_kwds); return NULL;} + __pyx_r = __pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_4create_genesis_block(((struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *)__pyx_v_self)); /* 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_11placeholder_10Blockchain_2create_genesis_block(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) { - struct __pyx_obj_18polluck_blockchain_11placeholder_Block *__pyx_v_genesis = NULL; +static PyObject *__pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_4create_genesis_block(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - size_t __pyx_t_3; - PyObject *__pyx_t_4 = NULL; - int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("create_genesis_block", 0); - - /* "polluck_blockchain/placeholder.py":171 - * - * def create_genesis_block(self): - * genesis = Block( # <<<<<<<<<<<<<< - * index=0, - * data="Genesis Block", -*/ - __pyx_t_2 = NULL; - __pyx_t_3 = 1; - { - PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 4 : 0)] = {__pyx_t_2, NULL}; - __pyx_t_4 = __Pyx_MakeVectorcallBuilderKwds(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 171, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_index, __pyx_mstate_global->__pyx_int_0, __pyx_t_4, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 171, __pyx_L1_error) - if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_data, __pyx_mstate_global->__pyx_kp_u_Genesis_Block, __pyx_t_4, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 171, __pyx_L1_error) - if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_previous_hash, __pyx_mstate_global->__pyx_kp_u_0, __pyx_t_4, __pyx_callargs+1, 2) < (0)) __PYX_ERR(0, 171, __pyx_L1_error) - if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_nonce, __pyx_mstate_global->__pyx_int_0, __pyx_t_4, __pyx_callargs+1, 3) < (0)) __PYX_ERR(0, 171, __pyx_L1_error) - __pyx_t_1 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_ptype_18polluck_blockchain_11placeholder_Block, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_4); - __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, 171, __pyx_L1_error) - __Pyx_GOTREF((PyObject *)__pyx_t_1); - } - __pyx_v_genesis = ((struct __pyx_obj_18polluck_blockchain_11placeholder_Block *)__pyx_t_1); - __pyx_t_1 = 0; - - /* "polluck_blockchain/placeholder.py":177 - * nonce=0, - * ) - * genesis.hash = genesis.compute_hash() # <<<<<<<<<<<<<< - * self.chain.append(genesis) - * -*/ - __pyx_t_4 = ((PyObject *)__pyx_v_genesis); - __Pyx_INCREF(__pyx_t_4); - __pyx_t_3 = 0; - { - PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; - __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_compute_hash, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - } - if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_genesis), __pyx_mstate_global->__pyx_n_u_hash, __pyx_t_1) < (0)) __PYX_ERR(0, 177, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "polluck_blockchain/placeholder.py":178 - * ) - * genesis.hash = genesis.compute_hash() - * self.chain.append(genesis) # <<<<<<<<<<<<<< - * - * def proof_of_work( -*/ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_chain); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 178, __pyx_L1_error) + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_18polluck_blockchain_11placeholder_10Blockchain_create_genesis_block(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 186, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = __Pyx_PyObject_Append(__pyx_t_1, ((PyObject *)__pyx_v_genesis)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 178, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "polluck_blockchain/placeholder.py":170 - * self.difficulty = difficulty - * - * def create_genesis_block(self): # <<<<<<<<<<<<<< - * genesis = Block( - * index=0, -*/ + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("polluck_blockchain.placeholder.Blockchain.create_genesis_block", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_genesis); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "polluck_blockchain/placeholder.py":180 +/* "polluck_blockchain/placeholder.py":197 * self.chain.append(genesis) * - * def proof_of_work( # <<<<<<<<<<<<<< + * @cython.ccall # <<<<<<<<<<<<<< + * def proof_of_work( * self, - * block: Block, */ -/* Python wrapper */ -static PyObject *__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_5proof_of_work(PyObject *__pyx_self, +static PyObject *__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_7proof_of_work(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_11placeholder_10Blockchain_5proof_of_work = {"proof_of_work", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_5proof_of_work, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_5proof_of_work(PyObject *__pyx_self, +static PyObject *__pyx_f_18polluck_blockchain_11placeholder_10Blockchain_proof_of_work(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *__pyx_v_self, struct __pyx_obj_18polluck_blockchain_11placeholder_Block *__pyx_v_block, int __pyx_skip_dispatch) { + PyObject *__pyx_v_prefix = NULL; + PyObject *__pyx_v_block_hash = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + size_t __pyx_t_5; + int __pyx_t_6; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("proof_of_work", 0); + /* 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_11placeholder_Blockchain && + __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_proof_of_work); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 197, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!__Pyx_IsSameCFunction(__pyx_t_1, (void(*)(void)) __pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_7proof_of_work)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = NULL; + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; + __pyx_t_5 = 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_5 = 0; + } + #endif + { + PyObject *__pyx_callargs[2] = {__pyx_t_3, ((PyObject *)__pyx_v_block)}; + __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __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, 197, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + } + if (!(likely(PyUnicode_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None) || __Pyx_RaiseUnexpectedTypeError("str", __pyx_t_2))) __PYX_ERR(0, 197, __pyx_L1_error) + __pyx_r = ((PyObject*)__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.py":202 + * block: Block, + * ) -> str: + * prefix = "0" * self._difficulty # <<<<<<<<<<<<<< + * while True: + * block_hash = block.compute_hash() +*/ + __pyx_t_1 = __Pyx_PySequence_Multiply(__pyx_mstate_global->__pyx_kp_u_0, __pyx_v_self->_difficulty); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 202, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_prefix = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "polluck_blockchain/placeholder.py":203 + * ) -> str: + * prefix = "0" * self._difficulty + * while True: # <<<<<<<<<<<<<< + * block_hash = block.compute_hash() + * if block_hash.startswith(prefix): +*/ + while (1) { + + /* "polluck_blockchain/placeholder.py":204 + * prefix = "0" * self._difficulty + * while True: + * block_hash = block.compute_hash() # <<<<<<<<<<<<<< + * if block_hash.startswith(prefix): + * return block_hash +*/ + __pyx_t_2 = ((PyObject *)__pyx_v_block); + __Pyx_INCREF(__pyx_t_2); + __pyx_t_5 = 0; + { + PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; + __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_compute_hash, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + } + __Pyx_XDECREF_SET(__pyx_v_block_hash, __pyx_t_1); + __pyx_t_1 = 0; + + /* "polluck_blockchain/placeholder.py":205 + * while True: + * block_hash = block.compute_hash() + * if block_hash.startswith(prefix): # <<<<<<<<<<<<<< + * return block_hash + * block._nonce += 1 +*/ + __pyx_t_2 = __pyx_v_block_hash; + __Pyx_INCREF(__pyx_t_2); + __pyx_t_5 = 0; + { + PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_prefix}; + __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_startswith, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + } + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 205, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_6) { + + /* "polluck_blockchain/placeholder.py":206 + * block_hash = block.compute_hash() + * if block_hash.startswith(prefix): + * return block_hash # <<<<<<<<<<<<<< + * block._nonce += 1 + * +*/ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_v_block_hash; + __Pyx_INCREF(__pyx_t_1); + if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("str", __pyx_t_1))) __PYX_ERR(0, 206, __pyx_L1_error) + __pyx_r = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "polluck_blockchain/placeholder.py":205 + * while True: + * block_hash = block.compute_hash() + * if block_hash.startswith(prefix): # <<<<<<<<<<<<<< + * return block_hash + * block._nonce += 1 +*/ + } + + /* "polluck_blockchain/placeholder.py":207 + * if block_hash.startswith(prefix): + * return block_hash + * block._nonce += 1 # <<<<<<<<<<<<<< + * + * @cython.ccall +*/ + __pyx_v_block->_nonce = (__pyx_v_block->_nonce + 1); + } + + /* "polluck_blockchain/placeholder.py":197 + * self.chain.append(genesis) + * + * @cython.ccall # <<<<<<<<<<<<<< + * def proof_of_work( + * self, +*/ + + /* function exit code */ + __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("polluck_blockchain.placeholder.Blockchain.proof_of_work", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_prefix); + __Pyx_XDECREF(__pyx_v_block_hash); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_7proof_of_work(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_11placeholder_10Blockchain_7proof_of_work = {"proof_of_work", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_7proof_of_work, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_7proof_of_work(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { - PyObject *__pyx_v_self = 0; struct __pyx_obj_18polluck_blockchain_11placeholder_Block *__pyx_v_block = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; - PyObject* values[2] = {0,0}; + PyObject* values[1] = {0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -5905,41 +6339,34 @@ PyObject *__pyx_args, PyObject *__pyx_kwds #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { - PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_block,0}; + PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_block,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, 180, __pyx_L3_error) + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 197, __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, 180, __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, 180, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 197, __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, "proof_of_work", 0) < (0)) __PYX_ERR(0, 180, __pyx_L3_error) - for (Py_ssize_t i = __pyx_nargs; i < 2; i++) { - if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("proof_of_work", 1, 2, 2, i); __PYX_ERR(0, 180, __pyx_L3_error) } + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "proof_of_work", 0) < (0)) __PYX_ERR(0, 197, __pyx_L3_error) + for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("proof_of_work", 1, 1, 1, i); __PYX_ERR(0, 197, __pyx_L3_error) } } - } else if (unlikely(__pyx_nargs != 2)) { + } 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, 180, __pyx_L3_error) - values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 180, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 197, __pyx_L3_error) } - __pyx_v_self = values[0]; - __pyx_v_block = ((struct __pyx_obj_18polluck_blockchain_11placeholder_Block *)values[1]); + __pyx_v_block = ((struct __pyx_obj_18polluck_blockchain_11placeholder_Block *)values[0]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("proof_of_work", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 180, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("proof_of_work", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 197, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -5950,8 +6377,8 @@ PyObject *__pyx_args, PyObject *__pyx_kwds __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_block), __pyx_mstate_global->__pyx_ptype_18polluck_blockchain_11placeholder_Block, 0, "block", 0))) __PYX_ERR(0, 182, __pyx_L1_error) - __pyx_r = __pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_4proof_of_work(__pyx_self, __pyx_v_self, __pyx_v_block); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_block), __pyx_mstate_global->__pyx_ptype_18polluck_blockchain_11placeholder_Block, 0, "block", 0))) __PYX_ERR(0, 200, __pyx_L1_error) + __pyx_r = __pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_6proof_of_work(((struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *)__pyx_v_self), __pyx_v_block); /* function exit code */ goto __pyx_L0; @@ -5970,184 +6397,327 @@ PyObject *__pyx_args, PyObject *__pyx_kwds return __pyx_r; } -static PyObject *__pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_4proof_of_work(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, struct __pyx_obj_18polluck_blockchain_11placeholder_Block *__pyx_v_block) { - PyObject *__pyx_v_prefix = NULL; - PyObject *__pyx_v_block_hash = NULL; +static PyObject *__pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_6proof_of_work(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *__pyx_v_self, struct __pyx_obj_18polluck_blockchain_11placeholder_Block *__pyx_v_block) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - size_t __pyx_t_3; - int __pyx_t_4; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("proof_of_work", 0); - - /* "polluck_blockchain/placeholder.py":184 - * block: Block, - * ) -> str: - * prefix = "0" * self.difficulty # <<<<<<<<<<<<<< - * while True: - * block_hash = block.compute_hash() -*/ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_difficulty); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyNumber_Multiply(__pyx_mstate_global->__pyx_kp_u_0, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_prefix = __pyx_t_2; - __pyx_t_2 = 0; - - /* "polluck_blockchain/placeholder.py":185 - * ) -> str: - * prefix = "0" * self.difficulty - * while True: # <<<<<<<<<<<<<< - * block_hash = block.compute_hash() - * if block_hash.startswith(prefix): -*/ - while (1) { - - /* "polluck_blockchain/placeholder.py":186 - * prefix = "0" * self.difficulty - * while True: - * block_hash = block.compute_hash() # <<<<<<<<<<<<<< - * if block_hash.startswith(prefix): - * return block_hash -*/ - __pyx_t_1 = ((PyObject *)__pyx_v_block); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = 0; - { - PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL}; - __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_compute_hash, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 186, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - } - __Pyx_XDECREF_SET(__pyx_v_block_hash, __pyx_t_2); - __pyx_t_2 = 0; - - /* "polluck_blockchain/placeholder.py":187 - * while True: - * block_hash = block.compute_hash() - * if block_hash.startswith(prefix): # <<<<<<<<<<<<<< - * return block_hash - * block.nonce += 1 -*/ - __pyx_t_1 = __pyx_v_block_hash; - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = 0; - { - PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_prefix}; - __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_startswith, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 187, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - } - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 187, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (__pyx_t_4) { - - /* "polluck_blockchain/placeholder.py":188 - * block_hash = block.compute_hash() - * if block_hash.startswith(prefix): - * return block_hash # <<<<<<<<<<<<<< - * block.nonce += 1 - * -*/ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __pyx_v_block_hash; - __Pyx_INCREF(__pyx_t_2); - if (!(likely(PyUnicode_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None) || __Pyx_RaiseUnexpectedTypeError("str", __pyx_t_2))) __PYX_ERR(0, 188, __pyx_L1_error) - __pyx_r = ((PyObject*)__pyx_t_2); - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "polluck_blockchain/placeholder.py":187 - * while True: - * block_hash = block.compute_hash() - * if block_hash.startswith(prefix): # <<<<<<<<<<<<<< - * return block_hash - * block.nonce += 1 -*/ - } - - /* "polluck_blockchain/placeholder.py":189 - * if block_hash.startswith(prefix): - * return block_hash - * block.nonce += 1 # <<<<<<<<<<<<<< - * - * def add_block(self, data: str) -> Block: -*/ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_block), __pyx_mstate_global->__pyx_n_u_nonce); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 189, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyLong_AddObjC(__pyx_t_2, __pyx_mstate_global->__pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 189, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_block), __pyx_mstate_global->__pyx_n_u_nonce, __pyx_t_1) < (0)) __PYX_ERR(0, 189, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_r); + if (unlikely(((PyObject *)__pyx_v_block) == Py_None)) { + PyErr_SetString(PyExc_TypeError, "cannot pass None into a C function argument that is declared 'not None'"); + __PYX_ERR(0, 197, __pyx_L1_error) } - - /* "polluck_blockchain/placeholder.py":180 - * self.chain.append(genesis) - * - * def proof_of_work( # <<<<<<<<<<<<<< - * self, - * block: Block, -*/ + __pyx_t_1 = __pyx_f_18polluck_blockchain_11placeholder_10Blockchain_proof_of_work(__pyx_v_self, __pyx_v_block, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 197, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; /* function exit code */ - __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None); - goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("polluck_blockchain.placeholder.Blockchain.proof_of_work", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; - __Pyx_XDECREF(__pyx_v_prefix); - __Pyx_XDECREF(__pyx_v_block_hash); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "polluck_blockchain/placeholder.py":191 - * block.nonce += 1 +/* "polluck_blockchain/placeholder.py":209 + * block._nonce += 1 * - * def add_block(self, data: str) -> Block: # <<<<<<<<<<<<<< - * new_block = Block( - * index=len(self.chain), + * @cython.ccall # <<<<<<<<<<<<<< + * def add_block(self, data: str) -> Block: + * prev_hash = self.chain[self._index].hash */ -/* Python wrapper */ -static struct __pyx_obj_18polluck_blockchain_11placeholder_Block *__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_7add_block(PyObject *__pyx_self, +static PyObject *__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_9add_block(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ -static PyMethodDef __pyx_mdef_18polluck_blockchain_11placeholder_10Blockchain_7add_block = {"add_block", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_7add_block, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; -static struct __pyx_obj_18polluck_blockchain_11placeholder_Block *__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_7add_block(PyObject *__pyx_self, +static struct __pyx_obj_18polluck_blockchain_11placeholder_Block *__pyx_f_18polluck_blockchain_11placeholder_10Blockchain_add_block(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *__pyx_v_self, PyObject *__pyx_v_data, int __pyx_skip_dispatch) { + PyObject *__pyx_v_prev_hash = NULL; + struct __pyx_obj_18polluck_blockchain_11placeholder_Block *__pyx_v_new_block = NULL; + struct __pyx_obj_18polluck_blockchain_11placeholder_Block *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + size_t __pyx_t_5; + int __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8[4]; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("add_block", 0); + /* 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_11placeholder_Blockchain && + __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_add_block); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 209, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!__Pyx_IsSameCFunction(__pyx_t_1, (void(*)(void)) __pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_9add_block)) { + __Pyx_XDECREF((PyObject *)__pyx_r); + __pyx_t_3 = NULL; + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; + __pyx_t_5 = 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_5 = 0; + } + #endif + { + PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_data}; + __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __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, 209, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + } + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_mstate_global->__pyx_ptype_18polluck_blockchain_11placeholder_Block))))) __PYX_ERR(0, 209, __pyx_L1_error) + __pyx_r = ((struct __pyx_obj_18polluck_blockchain_11placeholder_Block *)__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.py":211 + * @cython.ccall + * def add_block(self, data: str) -> Block: + * prev_hash = self.chain[self._index].hash # <<<<<<<<<<<<<< + * new_block = Block( + * index=(self._index + 1), +*/ + if (unlikely(__pyx_v_self->chain == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + __PYX_ERR(0, 211, __pyx_L1_error) + } + __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_self->chain, __pyx_v_self->_index, Py_ssize_t, 1, PyLong_FromSsize_t, 1, 1, 0, 1, __Pyx_ReferenceSharing_SharedReference); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_hash); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 211, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_prev_hash = __pyx_t_2; + __pyx_t_2 = 0; + + /* "polluck_blockchain/placeholder.py":212 + * def add_block(self, data: str) -> Block: + * prev_hash = self.chain[self._index].hash + * new_block = Block( # <<<<<<<<<<<<<< + * index=(self._index + 1), + * data=data, +*/ + __pyx_t_1 = NULL; + + /* "polluck_blockchain/placeholder.py":213 + * prev_hash = self.chain[self._index].hash + * new_block = Block( + * index=(self._index + 1), # <<<<<<<<<<<<<< + * data=data, + * previous_hash=prev_hash, +*/ + __pyx_t_4 = PyLong_FromSsize_t((__pyx_v_self->_index + 1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 213, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + + /* "polluck_blockchain/placeholder.py":215 + * index=(self._index + 1), + * data=data, + * previous_hash=prev_hash, # <<<<<<<<<<<<<< + * nonce=0, + * ) +*/ + __pyx_t_5 = 1; + { + PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 4 : 0)] = {__pyx_t_1, NULL}; + __pyx_t_3 = __Pyx_MakeVectorcallBuilderKwds(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 212, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_index, __pyx_t_4, __pyx_t_3, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 212, __pyx_L1_error) + if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_data, __pyx_v_data, __pyx_t_3, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 212, __pyx_L1_error) + if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_previous_hash, __pyx_v_prev_hash, __pyx_t_3, __pyx_callargs+1, 2) < (0)) __PYX_ERR(0, 212, __pyx_L1_error) + if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_nonce, __pyx_mstate_global->__pyx_int_0, __pyx_t_3, __pyx_callargs+1, 3) < (0)) __PYX_ERR(0, 212, __pyx_L1_error) + __pyx_t_2 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_ptype_18polluck_blockchain_11placeholder_Block, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_3); + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 212, __pyx_L1_error) + __Pyx_GOTREF((PyObject *)__pyx_t_2); + } + __pyx_v_new_block = ((struct __pyx_obj_18polluck_blockchain_11placeholder_Block *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "polluck_blockchain/placeholder.py":220 + * + * # start = time.perf_counter() + * new_block.hash = self.proof_of_work(new_block) # <<<<<<<<<<<<<< + * # elapsed = time.perf_counter() - start + * +*/ + __pyx_t_2 = ((struct __pyx_vtabstruct_18polluck_blockchain_11placeholder_Blockchain *)__pyx_v_self->__pyx_vtab)->proof_of_work(__pyx_v_self, __pyx_v_new_block, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 220, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_new_block), __pyx_mstate_global->__pyx_n_u_hash, __pyx_t_2) < (0)) __PYX_ERR(0, 220, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "polluck_blockchain/placeholder.py":223 + * # elapsed = time.perf_counter() - start + * + * self.chain.append(new_block) # <<<<<<<<<<<<<< + * self._index += 1 + * print(f"Mined block {new_block.index} with nonce={new_block.nonce}") +*/ + if (unlikely(__pyx_v_self->chain == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "append"); + __PYX_ERR(0, 223, __pyx_L1_error) + } + __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_self->chain, ((PyObject *)__pyx_v_new_block)); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 223, __pyx_L1_error) + + /* "polluck_blockchain/placeholder.py":224 + * + * self.chain.append(new_block) + * self._index += 1 # <<<<<<<<<<<<<< + * print(f"Mined block {new_block.index} with nonce={new_block.nonce}") + * # print(f"Mined block {new_block.index} in {elapsed:.3f}s with nonce={new_block.nonce}") +*/ + __pyx_v_self->_index = (__pyx_v_self->_index + 1); + + /* "polluck_blockchain/placeholder.py":225 + * self.chain.append(new_block) + * self._index += 1 + * print(f"Mined block {new_block.index} with nonce={new_block.nonce}") # <<<<<<<<<<<<<< + * # print(f"Mined block {new_block.index} in {elapsed:.3f}s with nonce={new_block.nonce}") + * +*/ + __pyx_t_3 = NULL; + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_new_block), __pyx_mstate_global->__pyx_n_u_index); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 225, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = __Pyx_PyObject_FormatSimple(__pyx_t_4, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 225, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_new_block), __pyx_mstate_global->__pyx_n_u_nonce); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 225, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_7 = __Pyx_PyObject_FormatSimple(__pyx_t_4, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 225, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_8[0] = __pyx_mstate_global->__pyx_kp_u_Mined_block; + __pyx_t_8[1] = __pyx_t_1; + __pyx_t_8[2] = __pyx_mstate_global->__pyx_kp_u_with_nonce; + __pyx_t_8[3] = __pyx_t_7; + __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_8, 4, 12 * 2 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1) + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7), 127 | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7)); + if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 225, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_5 = 1; + { + PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_4}; + __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, 225, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "polluck_blockchain/placeholder.py":228 + * # print(f"Mined block {new_block.index} in {elapsed:.3f}s with nonce={new_block.nonce}") + * + * return new_block # <<<<<<<<<<<<<< +*/ + __Pyx_XDECREF((PyObject *)__pyx_r); + __Pyx_INCREF((PyObject *)__pyx_v_new_block); + __pyx_r = __pyx_v_new_block; + goto __pyx_L0; + + /* "polluck_blockchain/placeholder.py":209 + * block._nonce += 1 + * + * @cython.ccall # <<<<<<<<<<<<<< + * def add_block(self, data: str) -> Block: + * prev_hash = self.chain[self._index].hash +*/ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_AddTraceback("polluck_blockchain.placeholder.Blockchain.add_block", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_prev_hash); + __Pyx_XDECREF((PyObject *)__pyx_v_new_block); + __Pyx_XGIVEREF((PyObject *)__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_9add_block(PyObject *__pyx_v_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +); /*proto*/ +static PyMethodDef __pyx_mdef_18polluck_blockchain_11placeholder_10Blockchain_9add_block = {"add_block", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_9add_block, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_9add_block(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { - PyObject *__pyx_v_self = 0; PyObject *__pyx_v_data = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; - PyObject* values[2] = {0,0}; + PyObject* values[1] = {0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - struct __pyx_obj_18polluck_blockchain_11placeholder_Block *__pyx_r = 0; + PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("add_block (wrapper)", 0); #if !CYTHON_METH_FASTCALL @@ -6159,41 +6729,34 @@ PyObject *__pyx_args, PyObject *__pyx_kwds #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { - PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_data,0}; + 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, 191, __pyx_L3_error) + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 209, __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, 191, __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, 191, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 209, __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, "add_block", 0) < (0)) __PYX_ERR(0, 191, __pyx_L3_error) - for (Py_ssize_t i = __pyx_nargs; i < 2; i++) { - if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("add_block", 1, 2, 2, i); __PYX_ERR(0, 191, __pyx_L3_error) } + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "add_block", 0) < (0)) __PYX_ERR(0, 209, __pyx_L3_error) + for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("add_block", 1, 1, 1, i); __PYX_ERR(0, 209, __pyx_L3_error) } } - } else if (unlikely(__pyx_nargs != 2)) { + } 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, 191, __pyx_L3_error) - values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); - if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 191, __pyx_L3_error) + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 209, __pyx_L3_error) } - __pyx_v_self = values[0]; - __pyx_v_data = ((PyObject*)values[1]); + __pyx_v_data = ((PyObject*)values[0]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("add_block", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 191, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("add_block", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 209, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -6204,8 +6767,8 @@ PyObject *__pyx_args, PyObject *__pyx_kwds __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_data), (&PyUnicode_Type), 0, "data", 2))) __PYX_ERR(0, 191, __pyx_L1_error) - __pyx_r = __pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_6add_block(__pyx_self, __pyx_v_self, __pyx_v_data); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_data), (&PyUnicode_Type), 0, "data", 2))) __PYX_ERR(0, 210, __pyx_L1_error) + __pyx_r = __pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_8add_block(((struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *)__pyx_v_self), __pyx_v_data); /* function exit code */ goto __pyx_L0; @@ -6224,182 +6787,236 @@ PyObject *__pyx_args, PyObject *__pyx_kwds return __pyx_r; } -static struct __pyx_obj_18polluck_blockchain_11placeholder_Block *__pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_6add_block(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_data) { - struct __pyx_obj_18polluck_blockchain_11placeholder_Block *__pyx_v_new_block = NULL; - struct __pyx_obj_18polluck_blockchain_11placeholder_Block *__pyx_r = NULL; +static PyObject *__pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_8add_block(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *__pyx_v_self, PyObject *__pyx_v_data) { + PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - Py_ssize_t __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - size_t __pyx_t_7; - int __pyx_t_8; - PyObject *__pyx_t_9[4]; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("add_block", 0); - - /* "polluck_blockchain/placeholder.py":192 - * - * def add_block(self, data: str) -> Block: - * new_block = Block( # <<<<<<<<<<<<<< - * index=len(self.chain), - * data=data, -*/ - __pyx_t_2 = NULL; - - /* "polluck_blockchain/placeholder.py":193 - * def add_block(self, data: str) -> Block: - * new_block = Block( - * index=len(self.chain), # <<<<<<<<<<<<<< - * data=data, - * previous_hash=self.chain[-1].hash, -*/ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_chain); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 193, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 193, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyLong_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 193, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - - /* "polluck_blockchain/placeholder.py":195 - * index=len(self.chain), - * data=data, - * previous_hash=self.chain[-1].hash, # <<<<<<<<<<<<<< - * nonce=0, - * ) -*/ - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_chain); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 195, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_5, -1L, long, 1, __Pyx_PyLong_From_long, 0, 1, 0, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 195, __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_hash); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 195, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_7 = 1; - { - PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 4 : 0)] = {__pyx_t_2, NULL}; - __pyx_t_6 = __Pyx_MakeVectorcallBuilderKwds(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 192, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_index, __pyx_t_3, __pyx_t_6, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 192, __pyx_L1_error) - if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_data, __pyx_v_data, __pyx_t_6, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 192, __pyx_L1_error) - if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_previous_hash, __pyx_t_5, __pyx_t_6, __pyx_callargs+1, 2) < (0)) __PYX_ERR(0, 192, __pyx_L1_error) - if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_nonce, __pyx_mstate_global->__pyx_int_0, __pyx_t_6, __pyx_callargs+1, 3) < (0)) __PYX_ERR(0, 192, __pyx_L1_error) - __pyx_t_1 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_ptype_18polluck_blockchain_11placeholder_Block, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_6); - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__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; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 192, __pyx_L1_error) - __Pyx_GOTREF((PyObject *)__pyx_t_1); + __Pyx_XDECREF(__pyx_r); + if (unlikely(__pyx_v_data == Py_None)) { + PyErr_SetString(PyExc_TypeError, "cannot pass None into a C function argument that is declared 'not None'"); + __PYX_ERR(0, 209, __pyx_L1_error) } - __pyx_v_new_block = ((struct __pyx_obj_18polluck_blockchain_11placeholder_Block *)__pyx_t_1); - __pyx_t_1 = 0; - - /* "polluck_blockchain/placeholder.py":200 - * - * # start = time.perf_counter() - * new_block.hash = self.proof_of_work(new_block) # <<<<<<<<<<<<<< - * # elapsed = time.perf_counter() - start - * -*/ - __pyx_t_6 = __pyx_v_self; - __Pyx_INCREF(__pyx_t_6); - __pyx_t_7 = 0; - { - PyObject *__pyx_callargs[2] = {__pyx_t_6, ((PyObject *)__pyx_v_new_block)}; - __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_proof_of_work, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - } - if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_new_block), __pyx_mstate_global->__pyx_n_u_hash, __pyx_t_1) < (0)) __PYX_ERR(0, 200, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "polluck_blockchain/placeholder.py":203 - * # elapsed = time.perf_counter() - start - * - * self.chain.append(new_block) # <<<<<<<<<<<<<< - * print(f"Mined block {new_block.index} with nonce={new_block.nonce}") - * # print(f"Mined block {new_block.index} in {elapsed:.3f}s with nonce={new_block.nonce}") -*/ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_chain); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_18polluck_blockchain_11placeholder_10Blockchain_add_block(__pyx_v_self, __pyx_v_data, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = __Pyx_PyObject_Append(__pyx_t_1, ((PyObject *)__pyx_v_new_block)); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 203, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "polluck_blockchain/placeholder.py":204 - * - * self.chain.append(new_block) - * print(f"Mined block {new_block.index} with nonce={new_block.nonce}") # <<<<<<<<<<<<<< - * # print(f"Mined block {new_block.index} in {elapsed:.3f}s with nonce={new_block.nonce}") - * -*/ - __pyx_t_6 = NULL; - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_new_block), __pyx_mstate_global->__pyx_n_u_index); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 204, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_t_5, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 204, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_new_block), __pyx_mstate_global->__pyx_n_u_nonce); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 204, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_t_5, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 204, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_9[0] = __pyx_mstate_global->__pyx_kp_u_Mined_block; - __pyx_t_9[1] = __pyx_t_3; - __pyx_t_9[2] = __pyx_mstate_global->__pyx_kp_u_with_nonce; - __pyx_t_9[3] = __pyx_t_2; - __pyx_t_5 = __Pyx_PyUnicode_Join(__pyx_t_9, 4, 12 * 2 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3) + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2), 127 | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2)); - if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 204, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_7 = 1; - { - PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_5}; - __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_builtin_print, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "polluck_blockchain/placeholder.py":207 - * # print(f"Mined block {new_block.index} in {elapsed:.3f}s with nonce={new_block.nonce}") - * - * return new_block # <<<<<<<<<<<<<< -*/ - __Pyx_XDECREF((PyObject *)__pyx_r); - __Pyx_INCREF((PyObject *)__pyx_v_new_block); - __pyx_r = __pyx_v_new_block; + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; goto __pyx_L0; - /* "polluck_blockchain/placeholder.py":191 - * block.nonce += 1 - * - * def add_block(self, data: str) -> Block: # <<<<<<<<<<<<<< - * new_block = Block( - * index=len(self.chain), -*/ - /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("polluck_blockchain.placeholder.Blockchain.add_block", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_new_block); - __Pyx_XGIVEREF((PyObject *)__pyx_r); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" + * def __setstate_cython__(self, __pyx_state): +*/ + +/* Python wrapper */ +static PyObject *__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_11__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_11placeholder_10Blockchain_11__reduce_cython__ = {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_11__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_11__reduce_cython__(PyObject *__pyx_v_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +) { + #if !CYTHON_METH_FASTCALL + CYTHON_UNUSED Py_ssize_t __pyx_nargs; + #endif + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); + #if !CYTHON_METH_FASTCALL + #if CYTHON_ASSUME_SAFE_SIZE + __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); + #else + __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; + #endif + #endif + __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); + if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("__reduce_cython__", 1, 0, 0, __pyx_nargs); return NULL; } + const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; + if (unlikely(__pyx_kwds_len < 0)) return NULL; + if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("__reduce_cython__", __pyx_kwds); return NULL;} + __pyx_r = __pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_10__reduce_cython__(((struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_10__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce_cython__", 0); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" +*/ + __Pyx_Raise(((PyObject *)(((PyTypeObject*)PyExc_TypeError))), __pyx_mstate_global->__pyx_kp_u_no_default___reduce___due_to_non, 0, 0); + __PYX_ERR(1, 2, __pyx_L1_error) + + /* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" + * def __setstate_cython__(self, __pyx_state): +*/ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_AddTraceback("polluck_blockchain.placeholder.Blockchain.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" +*/ + +/* Python wrapper */ +static PyObject *__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_13__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_11placeholder_10Blockchain_13__setstate_cython__ = {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_13__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_13__setstate_cython__(PyObject *__pyx_v_self, +#if CYTHON_METH_FASTCALL +PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds +#else +PyObject *__pyx_args, PyObject *__pyx_kwds +#endif +) { + CYTHON_UNUSED PyObject *__pyx_v___pyx_state = 0; + #if !CYTHON_METH_FASTCALL + CYTHON_UNUSED Py_ssize_t __pyx_nargs; + #endif + CYTHON_UNUSED PyObject *const *__pyx_kwvalues; + PyObject* values[1] = {0}; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); + #if !CYTHON_METH_FASTCALL + #if CYTHON_ASSUME_SAFE_SIZE + __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); + #else + __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; + #endif + #endif + __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); + { + PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_pyx_state,0}; + const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; + if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(1, 3, __pyx_L3_error) + if (__pyx_kwds_len > 0) { + switch (__pyx_nargs) { + case 1: + values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(1, 3, __pyx_L3_error) + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + const Py_ssize_t kwd_pos_args = __pyx_nargs; + if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "__setstate_cython__", 0) < (0)) __PYX_ERR(1, 3, __pyx_L3_error) + for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { + if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__setstate_cython__", 1, 1, 1, i); __PYX_ERR(1, 3, __pyx_L3_error) } + } + } else if (unlikely(__pyx_nargs != 1)) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); + if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(1, 3, __pyx_L3_error) + } + __pyx_v___pyx_state = values[0]; + } + goto __pyx_L6_skip; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__setstate_cython__", 1, 1, 1, __pyx_nargs); __PYX_ERR(1, 3, __pyx_L3_error) + __pyx_L6_skip:; + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + Py_XDECREF(values[__pyx_temp]); + } + __Pyx_AddTraceback("polluck_blockchain.placeholder.Blockchain.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_12__setstate_cython__(((struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *)__pyx_v_self), __pyx_v___pyx_state); + + /* function exit code */ + for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { + Py_XDECREF(values[__pyx_temp]); + } + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_18polluck_blockchain_11placeholder_10Blockchain_12__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate_cython__", 0); + + /* "(tree fragment)":4 + * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" + * def __setstate_cython__(self, __pyx_state): + * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" # <<<<<<<<<<<<<< +*/ + __Pyx_Raise(((PyObject *)(((PyTypeObject*)PyExc_TypeError))), __pyx_mstate_global->__pyx_kp_u_no_default___reduce___due_to_non, 0, 0); + __PYX_ERR(1, 4, __pyx_L1_error) + + /* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" +*/ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_AddTraceback("polluck_blockchain.placeholder.Blockchain.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } @@ -7124,6 +7741,181 @@ static PyTypeObject __pyx_type_18polluck_blockchain_11placeholder_Block = { #endif }; #endif +static struct __pyx_vtabstruct_18polluck_blockchain_11placeholder_Blockchain __pyx_vtable_18polluck_blockchain_11placeholder_Blockchain; + +static PyObject *__pyx_tp_new_18polluck_blockchain_11placeholder_Blockchain(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *p; + PyObject *o; + o = __Pyx_AllocateExtensionType(t, 0); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *)o); + p->__pyx_vtab = __pyx_vtabptr_18polluck_blockchain_11placeholder_Blockchain; + p->chain = ((PyObject*)Py_None); Py_INCREF(Py_None); + if (unlikely(__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_1__cinit__(o, __pyx_mstate_global->__pyx_empty_tuple, NULL) < 0)) goto bad; + return o; + bad: + Py_DECREF(o); o = 0; + return NULL; +} + +static void __pyx_tp_dealloc_18polluck_blockchain_11placeholder_Blockchain(PyObject *o) { + struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *p = (struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *)o; + #if CYTHON_USE_TP_FINALIZE + if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) { + if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_18polluck_blockchain_11placeholder_Blockchain) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + } + #endif + PyObject_GC_UnTrack(o); + Py_CLEAR(p->chain); + PyTypeObject *tp = Py_TYPE(o); + #if CYTHON_USE_TYPE_SLOTS + (*tp->tp_free)(o); + #else + { + freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free); + if (tp_free) tp_free(o); + } + #endif + #if CYTHON_USE_TYPE_SPECS + Py_DECREF(tp); + #endif +} + +static int __pyx_tp_traverse_18polluck_blockchain_11placeholder_Blockchain(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *p = (struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *)o; + { + e = __Pyx_call_type_traverse(o, 1, v, a); + if (e) return e; + } + if (p->chain) { + e = (*v)(p->chain, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_18polluck_blockchain_11placeholder_Blockchain(PyObject *o) { + PyObject* tmp; + struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *p = (struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *)o; + tmp = ((PyObject*)p->chain); + p->chain = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyObject *__pyx_getprop_18polluck_blockchain_11placeholder_10Blockchain_index(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_5index_1__get__(o); +} + +static PyObject *__pyx_getprop_18polluck_blockchain_11placeholder_10Blockchain_difficulty(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_10difficulty_1__get__(o); +} + +static PyMethodDef __pyx_methods_18polluck_blockchain_11placeholder_Blockchain[] = { + {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_11__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, + {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_13__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_18polluck_blockchain_11placeholder_Blockchain[] = { + {"index", __pyx_getprop_18polluck_blockchain_11placeholder_10Blockchain_index, 0, 0, 0}, + {"difficulty", __pyx_getprop_18polluck_blockchain_11placeholder_10Blockchain_difficulty, 0, 0, 0}, + {0, 0, 0, 0, 0} +}; +#if CYTHON_USE_TYPE_SPECS +static PyType_Slot __pyx_type_18polluck_blockchain_11placeholder_Blockchain_slots[] = { + {Py_tp_dealloc, (void *)__pyx_tp_dealloc_18polluck_blockchain_11placeholder_Blockchain}, + {Py_tp_traverse, (void *)__pyx_tp_traverse_18polluck_blockchain_11placeholder_Blockchain}, + {Py_tp_clear, (void *)__pyx_tp_clear_18polluck_blockchain_11placeholder_Blockchain}, + {Py_tp_methods, (void *)__pyx_methods_18polluck_blockchain_11placeholder_Blockchain}, + {Py_tp_getset, (void *)__pyx_getsets_18polluck_blockchain_11placeholder_Blockchain}, + {Py_tp_init, (void *)__pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_3__init__}, + {Py_tp_new, (void *)__pyx_tp_new_18polluck_blockchain_11placeholder_Blockchain}, + {0, 0}, +}; +static PyType_Spec __pyx_type_18polluck_blockchain_11placeholder_Blockchain_spec = { + "polluck_blockchain.placeholder.Blockchain", + sizeof(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain), + 0, + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, + __pyx_type_18polluck_blockchain_11placeholder_Blockchain_slots, +}; +#else + +static PyTypeObject __pyx_type_18polluck_blockchain_11placeholder_Blockchain = { + PyVarObject_HEAD_INIT(0, 0) + "polluck_blockchain.placeholder.""Blockchain", /*tp_name*/ + sizeof(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_18polluck_blockchain_11placeholder_Blockchain, /*tp_dealloc*/ + 0, /*tp_vectorcall_offset*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_as_async*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_18polluck_blockchain_11placeholder_Blockchain, /*tp_traverse*/ + __pyx_tp_clear_18polluck_blockchain_11placeholder_Blockchain, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_18polluck_blockchain_11placeholder_Blockchain, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_18polluck_blockchain_11placeholder_Blockchain, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + #if !CYTHON_USE_TYPE_SPECS + 0, /*tp_dictoffset*/ + #endif + __pyx_pw_18polluck_blockchain_11placeholder_10Blockchain_3__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_18polluck_blockchain_11placeholder_Blockchain, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if CYTHON_USE_TP_FINALIZE + 0, /*tp_finalize*/ + #else + NULL, /*tp_finalize*/ + #endif + #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800 + 0, /*tp_vectorcall*/ + #endif + #if __PYX_NEED_TP_PRINT_SLOT == 1 + 0, /*tp_print*/ + #endif + #if PY_VERSION_HEX >= 0x030C0000 + 0, /*tp_watched*/ + #endif + #if PY_VERSION_HEX >= 0x030d00A4 + 0, /*tp_versions_used*/ + #endif + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000 + 0, /*tp_pypy_flags*/ + #endif +}; +#endif static PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} @@ -7224,6 +8016,33 @@ static int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate) { if (__Pyx_MergeVtables(__pyx_mstate->__pyx_ptype_18polluck_blockchain_11placeholder_Block) < (0)) __PYX_ERR(0, 85, __pyx_L1_error) if (PyObject_SetAttr(__pyx_m, __pyx_mstate_global->__pyx_n_u_Block, (PyObject *) __pyx_mstate->__pyx_ptype_18polluck_blockchain_11placeholder_Block) < (0)) __PYX_ERR(0, 85, __pyx_L1_error) if (__Pyx_setup_reduce((PyObject *) __pyx_mstate->__pyx_ptype_18polluck_blockchain_11placeholder_Block) < (0)) __PYX_ERR(0, 85, __pyx_L1_error) + __pyx_vtabptr_18polluck_blockchain_11placeholder_Blockchain = &__pyx_vtable_18polluck_blockchain_11placeholder_Blockchain; + __pyx_vtable_18polluck_blockchain_11placeholder_Blockchain.create_genesis_block = (PyObject *(*)(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *, int __pyx_skip_dispatch))__pyx_f_18polluck_blockchain_11placeholder_10Blockchain_create_genesis_block; + __pyx_vtable_18polluck_blockchain_11placeholder_Blockchain.proof_of_work = (PyObject *(*)(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *, struct __pyx_obj_18polluck_blockchain_11placeholder_Block *, int __pyx_skip_dispatch))__pyx_f_18polluck_blockchain_11placeholder_10Blockchain_proof_of_work; + __pyx_vtable_18polluck_blockchain_11placeholder_Blockchain.add_block = (struct __pyx_obj_18polluck_blockchain_11placeholder_Block *(*)(struct __pyx_obj_18polluck_blockchain_11placeholder_Blockchain *, PyObject *, int __pyx_skip_dispatch))__pyx_f_18polluck_blockchain_11placeholder_10Blockchain_add_block; + #if CYTHON_USE_TYPE_SPECS + __pyx_mstate->__pyx_ptype_18polluck_blockchain_11placeholder_Blockchain = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_18polluck_blockchain_11placeholder_Blockchain_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_18polluck_blockchain_11placeholder_Blockchain)) __PYX_ERR(0, 162, __pyx_L1_error) + if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_18polluck_blockchain_11placeholder_Blockchain_spec, __pyx_mstate->__pyx_ptype_18polluck_blockchain_11placeholder_Blockchain) < (0)) __PYX_ERR(0, 162, __pyx_L1_error) + #else + __pyx_mstate->__pyx_ptype_18polluck_blockchain_11placeholder_Blockchain = &__pyx_type_18polluck_blockchain_11placeholder_Blockchain; + #endif + #if !CYTHON_COMPILING_IN_LIMITED_API + #endif + #if !CYTHON_USE_TYPE_SPECS + if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_18polluck_blockchain_11placeholder_Blockchain) < (0)) __PYX_ERR(0, 162, __pyx_L1_error) + #endif + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 + PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_18polluck_blockchain_11placeholder_Blockchain); + #endif + #if !CYTHON_COMPILING_IN_LIMITED_API + if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_18polluck_blockchain_11placeholder_Blockchain->tp_dictoffset && __pyx_mstate->__pyx_ptype_18polluck_blockchain_11placeholder_Blockchain->tp_getattro == PyObject_GenericGetAttr)) { + __pyx_mstate->__pyx_ptype_18polluck_blockchain_11placeholder_Blockchain->tp_getattro = PyObject_GenericGetAttr; + } + #endif + if (__Pyx_SetVtable(__pyx_mstate->__pyx_ptype_18polluck_blockchain_11placeholder_Blockchain, __pyx_vtabptr_18polluck_blockchain_11placeholder_Blockchain) < (0)) __PYX_ERR(0, 162, __pyx_L1_error) + if (__Pyx_MergeVtables(__pyx_mstate->__pyx_ptype_18polluck_blockchain_11placeholder_Blockchain) < (0)) __PYX_ERR(0, 162, __pyx_L1_error) + if (PyObject_SetAttr(__pyx_m, __pyx_mstate_global->__pyx_n_u_Blockchain, (PyObject *) __pyx_mstate->__pyx_ptype_18polluck_blockchain_11placeholder_Blockchain) < (0)) __PYX_ERR(0, 162, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject *) __pyx_mstate->__pyx_ptype_18polluck_blockchain_11placeholder_Blockchain) < (0)) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -7439,7 +8258,6 @@ static CYTHON_SMALL_CODE int __pyx_pymod_exec_placeholder(PyObject *__pyx_pyinit PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -7690,109 +8508,86 @@ __Pyx_RefNannySetupContext("PyInit_placeholder", 0); if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_18polluck_blockchain_11placeholder_Block, __pyx_mstate_global->__pyx_n_u_setstate_cython, __pyx_t_2) < (0)) __PYX_ERR(1, 16, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "polluck_blockchain/placeholder.py":161 + /* "polluck_blockchain/placeholder.py":186 + * return self._difficulty * - * - * class Blockchain: # <<<<<<<<<<<<<< - * def __init__( - * self, -*/ - __pyx_t_2 = __Pyx_Py3MetaclassPrepare((PyObject *) NULL, __pyx_mstate_global->__pyx_empty_tuple, __pyx_mstate_global->__pyx_n_u_Blockchain, __pyx_mstate_global->__pyx_n_u_Blockchain, (PyObject *) NULL, __pyx_mstate_global->__pyx_n_u_polluck_blockchain_placeholder, (PyObject *) NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 161, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - - /* "polluck_blockchain/placeholder.py":162 - * - * class Blockchain: - * def __init__( # <<<<<<<<<<<<<< - * self, - * difficulty: int = 1, -*/ - __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 162, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_difficulty, __pyx_mstate_global->__pyx_n_u_int) < (0)) __PYX_ERR(0, 162, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_None) < (0)) __PYX_ERR(0, 162, __pyx_L1_error) - __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_11placeholder_10Blockchain_1__init__, 0, __pyx_mstate_global->__pyx_n_u_Blockchain___init, NULL, __pyx_mstate_global->__pyx_n_u_polluck_blockchain_placeholder, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[7])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 162, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 - PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4); - #endif - __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_mstate_global->__pyx_tuple[4]); - __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_3); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_init, __pyx_t_4) < (0)) __PYX_ERR(0, 162, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "polluck_blockchain/placeholder.py":170 - * self.difficulty = difficulty - * - * def create_genesis_block(self): # <<<<<<<<<<<<<< + * @cython.ccall # <<<<<<<<<<<<<< + * def create_genesis_block(self): * genesis = Block( - * index=0, */ - __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_11placeholder_10Blockchain_3create_genesis_block, 0, __pyx_mstate_global->__pyx_n_u_Blockchain_create_genesis_block, NULL, __pyx_mstate_global->__pyx_n_u_polluck_blockchain_placeholder, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[8])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 170, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_11placeholder_10Blockchain_5create_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, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[7])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 186, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 - PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4); + PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_create_genesis_block, __pyx_t_4) < (0)) __PYX_ERR(0, 170, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_18polluck_blockchain_11placeholder_Blockchain, __pyx_mstate_global->__pyx_n_u_create_genesis_block, __pyx_t_2) < (0)) __PYX_ERR(0, 186, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "polluck_blockchain/placeholder.py":180 + /* "polluck_blockchain/placeholder.py":197 * self.chain.append(genesis) * - * def proof_of_work( # <<<<<<<<<<<<<< + * @cython.ccall # <<<<<<<<<<<<<< + * def proof_of_work( * self, - * block: Block, */ - __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 180, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_block, __pyx_mstate_global->__pyx_n_u_Block) < (0)) __PYX_ERR(0, 180, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_str) < (0)) __PYX_ERR(0, 180, __pyx_L1_error) - __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_11placeholder_10Blockchain_5proof_of_work, 0, __pyx_mstate_global->__pyx_n_u_Blockchain_proof_of_work, NULL, __pyx_mstate_global->__pyx_n_u_polluck_blockchain_placeholder, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[9])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 180, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 197, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_block, __pyx_mstate_global->__pyx_n_u_Block) < (0)) __PYX_ERR(0, 197, __pyx_L1_error) + __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_11placeholder_10Blockchain_7proof_of_work, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Blockchain_proof_of_work, NULL, __pyx_mstate_global->__pyx_n_u_polluck_blockchain_placeholder, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[8])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 197, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_3); #endif - __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_3, __pyx_t_4); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_proof_of_work, __pyx_t_3) < (0)) __PYX_ERR(0, 180, __pyx_L1_error) + __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_3, __pyx_t_2); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_18polluck_blockchain_11placeholder_Blockchain, __pyx_mstate_global->__pyx_n_u_proof_of_work, __pyx_t_3) < (0)) __PYX_ERR(0, 197, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "polluck_blockchain/placeholder.py":191 - * block.nonce += 1 + /* "polluck_blockchain/placeholder.py":209 + * block._nonce += 1 * - * def add_block(self, data: str) -> Block: # <<<<<<<<<<<<<< - * new_block = Block( - * index=len(self.chain), + * @cython.ccall # <<<<<<<<<<<<<< + * def add_block(self, data: str) -> Block: + * prev_hash = self.chain[self._index].hash */ - __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 191, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_data, __pyx_mstate_global->__pyx_n_u_str) < (0)) __PYX_ERR(0, 191, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_Block) < (0)) __PYX_ERR(0, 191, __pyx_L1_error) - __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_11placeholder_10Blockchain_7add_block, 0, __pyx_mstate_global->__pyx_n_u_Blockchain_add_block, NULL, __pyx_mstate_global->__pyx_n_u_polluck_blockchain_placeholder, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[10])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 191, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); + if (PyDict_SetItem(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_data, __pyx_mstate_global->__pyx_n_u_str) < (0)) __PYX_ERR(0, 209, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_11placeholder_10Blockchain_9add_block, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Blockchain_add_block, NULL, __pyx_mstate_global->__pyx_n_u_polluck_blockchain_placeholder, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[9])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 209, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 - PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4); + PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_3); + __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_add_block, __pyx_t_4) < (0)) __PYX_ERR(0, 191, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_18polluck_blockchain_11placeholder_Blockchain, __pyx_mstate_global->__pyx_n_u_add_block, __pyx_t_2) < (0)) __PYX_ERR(0, 209, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "polluck_blockchain/placeholder.py":161 - * - * - * class Blockchain: # <<<<<<<<<<<<<< - * def __init__( - * self, + /* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" + * def __setstate_cython__(self, __pyx_state): */ - __pyx_t_4 = __Pyx_Py3ClassCreate(((PyObject*)&PyType_Type), __pyx_mstate_global->__pyx_n_u_Blockchain, __pyx_mstate_global->__pyx_empty_tuple, __pyx_t_2, NULL, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 161, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_11placeholder_10Blockchain_11__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Blockchain___reduce_cython, NULL, __pyx_mstate_global->__pyx_n_u_polluck_blockchain_placeholder, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[10])); 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_4); + PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif - if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_Blockchain, __pyx_t_4) < (0)) __PYX_ERR(0, 161, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_reduce_cython, __pyx_t_2) < (0)) __PYX_ERR(1, 1, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" +*/ + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_11placeholder_10Blockchain_13__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_Blockchain___setstate_cython, NULL, __pyx_mstate_global->__pyx_n_u_polluck_blockchain_placeholder, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[11])); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 + PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); + #endif + if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_setstate_cython, __pyx_t_2) < (0)) __PYX_ERR(1, 3, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":4 @@ -7802,7 +8597,7 @@ __Pyx_RefNannySetupContext("PyInit_placeholder", 0); * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x4ef9a57, 0x0fee400, 0xa9669e9, b'_data, _hash, _index, _nonce, _prev_hash, _timestamp') */ - __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_11placeholder_1__pyx_unpickle_Block, 0, __pyx_mstate_global->__pyx_n_u_pyx_unpickle_Block, NULL, __pyx_mstate_global->__pyx_n_u_polluck_blockchain_placeholder, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[11])); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_18polluck_blockchain_11placeholder_1__pyx_unpickle_Block, 0, __pyx_mstate_global->__pyx_n_u_pyx_unpickle_Block, NULL, __pyx_mstate_global->__pyx_n_u_polluck_blockchain_placeholder, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[12])); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); @@ -7826,7 +8621,6 @@ __Pyx_RefNannySetupContext("PyInit_placeholder", 0); __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); if (__pyx_m) { if (__pyx_mstate->__pyx_d && stringtab_initialized) { __Pyx_AddTraceback("init polluck_blockchain.placeholder", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -7858,7 +8652,7 @@ __Pyx_RefNannySetupContext("PyInit_placeholder", 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, 204, __pyx_L1_error) + __pyx_builtin_print = __Pyx_GetBuiltinName(__pyx_mstate->__pyx_n_u_print); if (!__pyx_builtin_print) __PYX_ERR(0, 225, __pyx_L1_error) /* Cached unbound methods */ __pyx_mstate->__pyx_umethod_PyDict_Type_items.type = (PyObject*)&PyDict_Type; @@ -7923,21 +8717,10 @@ static int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate) { __pyx_mstate_global->__pyx_tuple[3] = PyTuple_Pack(1, __pyx_mstate_global->__pyx_kp_u_self__data_is_not_None_or_self); if (unlikely(!__pyx_mstate_global->__pyx_tuple[3])) __PYX_ERR(1, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[3]); __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[3]); - - /* "polluck_blockchain/placeholder.py":162 - * - * class Blockchain: - * def __init__( # <<<<<<<<<<<<<< - * self, - * difficulty: int = 1, -*/ - __pyx_mstate_global->__pyx_tuple[4] = PyTuple_Pack(1, ((PyObject*)__pyx_mstate_global->__pyx_int_1)); if (unlikely(!__pyx_mstate_global->__pyx_tuple[4])) __PYX_ERR(0, 162, __pyx_L1_error) - __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[4]); - __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[4]); #if CYTHON_IMMORTAL_CONSTANTS { PyObject **table = __pyx_mstate->__pyx_tuple; - for (Py_ssize_t i=0; i<5; ++i) { + for (Py_ssize_t i=0; i<4; ++i) { #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL); #else @@ -7957,31 +8740,31 @@ static int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate) { static int __Pyx_InitConstants(__pyx_mstatetype *__pyx_mstate) { CYTHON_UNUSED_VAR(__pyx_mstate); { - const struct { const unsigned int length: 8; } index[] = {{0},{1},{14},{13},{12},{9},{179},{1},{8},{2},{7},{6},{2},{9},{50},{79},{37},{14},{12},{5},{23},{25},{19},{18},{24},{10},{19},{20},{31},{24},{4},{20},{12},{30},{32},{12},{9},{6},{18},{3},{5},{10},{5},{18},{12},{18},{20},{4},{8},{8},{5},{10},{6},{7},{11},{20},{6},{13},{8},{7},{12},{4},{7},{9},{5},{8},{3},{13},{5},{6},{8},{13},{10},{8},{7},{9},{5},{4},{13},{30},{3},{6},{11},{13},{5},{13},{3},{8},{9},{14},{12},{11},{10},{20},{14},{12},{10},{17},{13},{6},{4},{12},{10},{12},{19},{6},{10},{5},{3},{6},{8},{4},{9},{8},{6},{12},{6},{11},{25},{54},{99},{51},{15},{15},{9},{113},{103},{55}}; - #if (CYTHON_COMPRESS_STRINGS) == 2 /* compression: bz2 (1308 bytes) */ -const char* const cstring = "BZh91AY&SY\352ef\234\000\000\215\377\377\347\377\377\371\377\257\367\377\277\343\376\361\277\377\377\364@@@@@@@@@\000@@@\000@\000P\004\236r\354L\261\262\323M\216\030ji$h\36544i\352=OQ\351\001\352d\032\000\r\032zjh2\006\215\000\315F\200h\304\375D=OMA\246\221\006 \022zjz\221\351=F\206\236\240\032\006\2154\000\000\000\000\000\032\0004\320\032\236\204&EO\324\365'\246C)\351=F\215\003M\000\000\000\000\032\000\000\310\311\243G\2444\3208\000\000\001\240\000\000\006\200\032\000\001\240\000\006\200\000\000\001)\250@\023B6\246\311&h\324\000\000\000\000\000\000\000\000\000\320\3202#\210]\246\r=?\271\371\021\250\315\251\252\351\377\305\306C\310&\004\311&HJY\\F\337\331\312f\276-I\031\212b\202\"C_\216\230\310\005h\226GY\001\312\242\243V\342\212\305\021\210\005\342\264\017\203\205\325@TBD#\010\017\206\032\360\246\257'Q]\253\366N\216\226\235\022\345\355e\363\324\032\321E\210\026\006\236\260\243]\240\032\025\252\010\307>\273y\000\220q\311\"\363\213U\261\021h\303\0263J\377\024\210\317\321\325\230\237\327\225]n\320\245,\003\223\334X\350\321\022\373uj\236j\256\026\260\217\366.\327S\257/`\272Q\265\351\262\374\354\271\310\224d()\220h##T\205\373a\236<\327\027$\274^\247N\031\370\255\203CG\024F\370Hg.c\251\206\215\177+\031\312a\035]\006\315\2108\365\304\335\276\311bp\237\245\274\236\373Q*\252 O!\366\336\035]b\312\022\000;nq6\021\320.\001\262\203\321\002\270\003\224\256\010[\031\036\271\277\263\027\356g\014\275\205}\355x(\277\262\220\213\362`\214)P4g.\0134\343g\2415\221\314\022f\000\244\020WZ\246\244\014L\215\214I\3113\322\035+T\204\017(\222\025\231E,$H\034(-\201\315\322\026\376\343\023\352|\036\211a\325\343\351fT\323\221\333\265\303v(\201\256\217\274\326Ai(\306\264\300\347\2623\014z\374\212L\323\001Y\213\206\030\"2\326\202\007\240\232\356<#\250\032f|\314\331r\217\236VbAH\230\021\230\316\314\"LA\360\203\005/\002\004<\030\202,\247)\025\222\301\327*rl\302r\3208H6\014\020\253e\013\n\0075\255\3068\306\250U~\3359a\254H&\002U\220\3356\325\224\222I\016\204`\032i\374}\223`\345IkZ\017i\010,\300}\"""\225\235M\206\373\251\246o\230\027\350\t0\215Q \023$\254\"Pl\210yP\210\362\003\330\223\001E\314N\035\2277\227\331\351\340\343\036GPO>JF\22283\204\363\025\322\352\022j\300tL\027\220V\202\323k\003\203\021\024\027\337P\303\020\316\244UZ\300\213\240\023\030\002\222\260\337\250\231\341#\025\025V\320\3723@)##\312K2\007>\276DR\004\r!\000'\207]!\211{\033\014\025\205\371\330\262I\t\243\374\014\204&L\222Ht\255\232\254\0373\352+\201\031.\355\222\202`D\336\n\212\364.q\000\220J\007\3122x\314\215\024!g \311C\301\363K\006h&\216\331\014\244\026\311ER\233\233cF\204\035=\346f2Qx\244\3230\245i`]}Hk\216*\010\021\334(3\214\342rV%Xsh\240\275\204\242\271*\254+\316\246\342\305\205\366\271\311\034\227D(\274\200\327W(L\314\314\232\361\247\264I\206\032\010\004\276\334\253K*\251\010\301bx\211\211\331\234\250\t\361@y\024E\nv\036\352\\R\235\000\231<\206|(\244\305$\243\340\305J\201\222\002p\314\330\270x \372TF\233\021n\004\303\360\265\326\t\2641\232c!u\245\316\267h\332G\222\253p[\214\206\355\021\356p\232\305C@\027\000_\010\261\245\221)\002,5\200\324F<\\d\252y\203\340\364\252\250\345?\224)\315\211D\220\ti\232W\234c\026\372\335h\014\360\216\020U\310\266Dh]\214\352\375q\252\260\024(\270\030\366J0J\321\203\005\361\312T!F\327\016!\023\276\n\226\001\243XI$\010\352t\323\275?\270RY\307Q\272\373&\366\220.\3420\210\234\356s\002\236m\352\007 m\320\323o.\0340\242\tDT|\341\204\026\275\220\\[\024\247\355\2123\203\341\361~g\211n\022\374\217P.KI\224\250T\225\256\205\252\326E%\302\033\025\336\306\312\037b\\Q\n\303\235\024)\210\276;\354\345\210\214c\2602\002\235!\221\t\325E8q\240\006\035\201'T35\334\370\3663\24540^\254\334<\331\227g=V\222\\L\302I\374kx'\007\263I$\337\203\360IDA\224\263\010\222\262\032\035\002\"\366\377\213\271\"\234(Hu2\263N\000"; - PyObject *data = __Pyx_DecompressString(cstring, 1308, 2); + const struct { const unsigned int length: 8; } index[] = {{0},{1},{14},{13},{12},{9},{179},{1},{8},{2},{7},{6},{2},{9},{50},{79},{37},{14},{12},{5},{23},{25},{19},{18},{24},{10},{28},{30},{20},{31},{24},{20},{12},{30},{32},{12},{9},{18},{3},{5},{18},{12},{18},{20},{4},{8},{8},{5},{10},{6},{11},{20},{6},{13},{8},{12},{4},{7},{9},{5},{13},{5},{6},{8},{10},{8},{7},{5},{4},{13},{30},{3},{13},{5},{13},{3},{8},{9},{14},{12},{11},{10},{20},{14},{12},{10},{17},{13},{4},{12},{10},{12},{19},{6},{10},{5},{3},{6},{8},{4},{9},{8},{6},{12},{6},{11},{115},{53},{99},{51},{15},{15},{9},{113},{55}}; + #if (CYTHON_COMPRESS_STRINGS) == 2 /* compression: bz2 (1256 bytes) */ +const char* const cstring = "BZh91AY&SY\331\252$\204\000\000\211\377\377\347\377\377\371\357\257\367\377\277\353\376\361\277\377\377\364@@@@@@@@@\000@@@\000@\000P\004S)\351\0331\266\315\026\343\rD\223A\223L\203F\323D\311\221\223M\003#M14\302`F\230\206FFM4b\031\251\372\221\232i\2504\324&\231\032S\310\301L#(\r\000\000\003@\000\006\200\000\000\001\352d\033(5=\020L\201\024\365\0175\032!\3526\204d4\000\000\000\006\200\000\032\0314h\332\206\232\007\000\000\0004\000\000\000\320\003@\0004\000\000\320\000\000\000%\021\032M\244z\"x\232P\336\222z\200d\006\200\365\r\000\000\006\200\000\006\203@\032\003b\004\352 \032\272\271\006\261\032\350\231K\363#`\212\014D\021! \222\204\2626\247\365\342\017\037\347\"\005\254\334!(\2130X\025\221#\243[\0010\020\031`\262f\027\334\347!xJ\224>\014\020T\005C\242B4J\030}\372\365\353\246\267\037UY\255\366N~\236\244\321\344\356#\363\325\030\240\213\000-\006\313\020\233a\257\r}J\202\020\321\252\3560\006\302H\"\362\215\322\336\317\037\211\371\"!\213e\225\342\036\332)\247EpR\225t,\255B\3054\210\217\347\257D\324mEs\224\315\207S\265\016\351\357\030\3142\223\262l\301z\222&\031\225\243\001\200\3411\344Nl\313\030G\223n\266\020\341\217\250\355\033u\325\271\322\370\264C #\363\327\013'z\351U\362\264\340!\255\360\\\347\003{\"\2721\332m'\005\332{\207\350|Yvi\001\366GTbB\005\027\030\340L\212O\374b9P\"\2640\250\324\014\344k\0010\333#\277i\203g\033bg\t\343\226\306\325y\352\326R\200q\262\214BR7\232\023\333t\340\t\324!!6kP\032\216W\266\203EB4\226\206\007\220\004\nP\202\245$@\224\202\3052\333\224\247\364\353\337\rG\201\203[KV\270#\311,\320kQ\013\304'0\305f\252\310\211\210\245\215E+1\233L\222k\312J\215vP\24641\253\024!X\267\021\034\215\300\004c$\306\2108s\004\025_5d\271\245L\231\244$\007\251pX\300e\325\245\033r\017\265I\314\271a\317A(xf\215\025h\337F\253A\205\273\031\211_0\221\271\243\016\224F|\344\352*""\245@2@(Q\221,KSG\215@`\270\250+\210\331\316Q}\217S\013\304\316@\203&\3400\272\361'Ul\037\013AG\265\331\227\363\311_\312\211\302\rT\001W-\020\032bCk\231H\024H\202\330\343\017n@\204\020H\004\222B\234\230\r\241o^p\251\201\244\201\201\004\200\201\315\n\212\344 \002\030H%\003\243\010\270a\232i\232\020^!X\261TF\254v8\225B\306=\333\313#S:&@D2K\001\347\330\255W\021\204*m\345\000\202\204\310\300\332\004\243\010\304$\016@\343e\371e\024Y-q\334\005\347\351\271\272\251*\216\230\233dBm\002\003\035C\302_\275\267\303\263<\245$\005y\304\002d\253<[4\305\010\265U\007\007\261\210d\005\212\0205\243$\327&\006\255((-e%\002\344\266\212A|\002\250eFP\204\242=+\322PZ\024\372\314\032@\274X7\262\010\2622\363\002\260\030\344UJ)u{\312\202\351*\246\300\327\r\261`\010\3665k\014@,\000\276F\342K\221(\201\025t\000\304\001r\213\014s\315\001$\262$\370\332\343\254\205:1(G*%pt\207\030\321\320\340Y\257\001\244\211!:&j\\q\2550T\222\026\255\200\201\005\320]\273K\220h\271r\307\222X\013\025mO\225Ke{\023\000p\357\201$\202>\034w\251\250\237\212\254\360'\207\305\247\343Q|\212\206\336n\366\232\005\260IvN)\004\241#\324(\324$Al\027\310\312\231\020GJ\361\213\331\016\267\325\0179\002\337\200V>\331\221B\2401\"\032\037\371\3250\360y\\\337A\023\031\237\037\316\3104\313!O\335\366%b7F\266T\257\215\267P\235\007\033M\350\007#S\275\022\305\032i\353\214\r7\227\004\223]\032\000\351\246\233xYc\004\024\376\260\325\343\326\007\034h\252\220\027\347Xf/\021\002&\204 \t{\202\004\312!\360\231\034\241\245\346\005\356\377\213\271\"\234(Hl\325\022B\000"; + PyObject *data = __Pyx_DecompressString(cstring, 1256, 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 (1177 bytes) */ -const char* const cstring = "x\332mTMs\3336\020\215g\334VN\224\330r\323\346\2433-\\\247\361t\322(Q'\251\373\025w\234\304Ns\210k\245\312\244\355!\030\210\\\212\250)\200&@\331\352\364\340\243\216<\362\310#\217>\372\350\237\240#\217\376\t\371\t]\200\226,W\236!\201\305\356\002x\357a\201\207\317\231fDHMV\224\216V^\200\000\305\025y\032Hg\347\025\027\340\222\2661\311\226$\030\347\242\263%5\020\3553M\236\365\265/\005\301l\027\002\336\206\210i\010\3726\315\321\020\231$A\2667\266\357?\372\376\021a\302%\021\374\r\216VD\305m'`J\201\"\322#\355\230\007\232\013\242\373!\250:y\351\221\276\214\211\000\334ZK\022b\336\344\004\355\203 \n\2641\310\n\023\210\234i.\005\305\351\210n\205\270<\302Mx\017\314\354M\026(\250\377\302\\\227b\"\254\271.W\254\035\000\010\323v\034\256J\313\025\022Ix,\0164\2414\0027v\200R\342\306v\025!\305}$\325\343,\300\250\303\005\327\224*\010\274:u\215z\250\200\021pK\n 2\"e\304g\312\2778\022F\320\233\n\253\310y\020\312 \210\235\035j\025w|\306\305\2030`\016\3702p!\252\207\375\237\313#P2\216\034X#{\\\373\006\234\003O\354y\331\246>\306\357\330\363\241t\344F\325\024\2125\025\010!\362d\324\265\220J\227#\273a\214\211\027{h\273\257A=\035\203<\263p\223R\234\t\227\321\276=FW\372\234\010\014\216NYlS\3410\222\322\243\370\355\311h\307\210C\351v\177\037\377\347XXt\013\366\365k\360~\267R\374j\245\231\264\247\371\377/:%C\353\345\253\215\277~\333\332\240oZ\317\306hY\030\202p\231\352\013\207K\244\037\311\030\213\024T\233wl\3346V\016\213\331\t0\210\344\251\216\360\300\332\014\251L(6\255\336E\n\230Z\302\0374\357\"c\327p-;\227{\036w\2606\373.\357\200B\267+\035\323\204\232\266\231\342\216\2320\353\243%P&d\340E\262kFH\271\033R\352\305\002g\216\266E\343T\013\013\315\374x\221}\330/\367\341\302\205\375\321\221r\241)N\031+\3015tU\000\242\243}J\273(\001\202\245]\320\314\336T;\220n\034\200\261\004\353\226=\354\225\215\345k+7D\251\316U\340\364%\250O\\\202P\206x}<\216\260\260\017Y\004\326\350q\031\253r:\236\265>W@\241\216\302~\251:\366\345\r\302IXP\216\017\316\216\212\273\345(\002\205\022\227\366\251(\3064\317Ri\305\"\344""\316\0162\262\245Z\372z\332<\037\206\333n\314\202\021\317\321\0032U\212c\207\3215\002\035G\302\274\t\266(OUB\353\364%\232(UzA\331*\237}\373\370;\364EZ\231\227\300F\221\036~\261)\035m+\305\234\375\370\374\265,u\210CS$\261\202\361\252=\026\304\240\016f\212\331\345\254\221m\346K\007\353'\225\353\311z1w\271\250T\207\325/\263\245\223Ju\260\225\232\300\374\202u\327\222\353\311\353D\247\215\2422WTo\245\237\244\335\274QT\347\007\377\244\237e\353Y\263X\270\221\354\026\325Zr;m\230\345\026\222\271\264VT\256\016\336&\353I+\275\221\315\345\265|9o\216\\\357p\347\347\371\314Y\306\247\351\356\331\000\227\274`\356Ie~\260\227t\322f\312\0160\276\230|e\266\\L\226\314\276\265\242z;]\262C\223\267\237\354Y\204\310c3YIk\206K\201~\235\254e\213\331j~n\370c\3364j\\\036\334K\320x_\271\364\301\265A+\271\231^O\377\310Z\371\255\303;\207\374H\037?\031n\267\206\2557\305lu\360\"i$\233\3517\031+f?:\350!\316\r\314m\032HKE\005\2058\251\334LgL\0149\315\017\347\357fn\276\224\257\036\336;z{\214\332\234\3634\207\263\237\247>\256\204'\260\201\222!\201\345\244\231\270\351\031\253;\251\227=\315\332\250\226a\207\360\346\026-\270wy#_\177\377\341\245\271\253#\216F\264\346@\244\353\351\237\303\273?\034\325\216\276>n\230\204\205\301\356\301\314\311\354\027\351\356\220<<\274r\364\323\361\316\260\371\272\230\3758y\234V\262\231\254f\260\376\233\254\232\025V\262\335\274rx\355\010\271]\0314\376\003\035\2244\006"; - PyObject *data = __Pyx_DecompressString(cstring, 1177, 1); + #elif (CYTHON_COMPRESS_STRINGS) != 0 /* compression: zlib (1128 bytes) */ +const char* const cstring = "x\332uT\315n\333F\020\216\0017\225\033%\266\034\267I\032\240Y#m\204\"\215\022\025N\235\376$\205\022\333iP\304\265\\\005i{\310bE\216\304\255\250]\212\273\224\245\242\007\037u\344\221G\036y\364QG?\202\217:\372\021\362\010\235%-Y\216T\200\\\316\316\314\316\314\367\315p\037m1\315\210\220\232\024\225\366\213/A\200\342\212\240\035\020D\2016\002)2\201\2253\315\245\240x\034\253+\022\233\373\230\204w\301\234\336a\256\202\322\317\314\266):\3023\333\346\212\325]\000a\326\246\305U&\331B\"\210\006\013\\M(\365\301\016,\240\224\330A\032EH\361\000Au9s\321jq\3015\245\n\334F\211\332\206=d\300\020\270+\005\020\351\223\314\3420\345\314\267x>tg\314\312\267\036z\322u\003\253ES\306-\207q\361\320s\231\005\216tm\360K^\377\247\254\005J\006\276\005\317\310\001\327\216)\316\202\247i\277\322\2454\251\337J\373C\351X\215\254)$k\306\340\201\337\220~;-)SY\262\355\005\3508_C\353}\r\352\371\244\310s\351\177r\217m\363\013\310\254\246E\365\t\210Lg\371`\274\233\331L\316\230=_\312\006\305\347@\372-J\367\372=|\267p\366\350.\364\364>4~O\331\372%eoZ\236-\363\003\353L\241\265W\257\267\377\372mw\233\276\251\275\230T\312T_X\\\"7\276\014p\202A\325y3\353\235\213;\312q(}l_\235\241f\212\277Y.\347\0015\223\205/h\336\306Q\264\r\254\354c\363F\203[8\251}\2337Ai[z\232\326\231\342\226\232\022K\343\263H\005\010\273\341\313\266\331!\254\266Gi#\020\026\206\303\214g@\323b\314\213?\262\003\275,2\0276\364(\0264A\3105\264\225\013\242\251\035J\333\330\004\023\244-\355\300\005#\t\326\316\276p\200\213\031L\017\261_\030\260\331\031/M\315\270'=\363wp\031\250\314\033\333\242/\364\331\323\276\327\317X\303o\366?P\352a\357-\007\254\226\n\332\331\316\007\205\024e\362\031D#\232K&\223\002\341q\253\205u\247\023\225\351\272\332\\\006\006A'`\356\030\315\370:\230\231\232\211\002YJ\357\203tr\316X@\351""\354F\231\232':g\266\224\303\276}\374\035\352|\255\314\037\235Z\021\030>\201i\272\331\340\212\315\2334P\313\214\201\3003]\016\024L\242v\231\033\200:\\\030-\336\215\313\361N\262~X\031}qg\224[\013\267\242\313\021\213t\374$)\233\355vT\030\345\257\207\033a/\362c\024\013!.\237G\353\243\374j\270\376>wii5\274\031\255E\357\222rRy\177\371\322\322\325\301NX\214\n\350\220\313\017~\r;\243\334\325Au \242J\364\347\311\275\357\207\205\341\327\307e\343\2672\350\034\232\003+\205\323\\!\\\013\367C\035a\302\245Q\376V\364i\324\306\344\371\345\301?\321\355\270\022WG+70\020\246\276\035U\016+\247\271\225p\t\253\302\300o\303JX\213n\304KI!\271\233T\307\252w\010i+Y8\367\370,\352\234o0\344\234\263\247\271\345\301A\330\214\252\0213)V\303\257LJ\304\370\001d\343\327\013\017\322\n\021\341\031Xd\017\365:|\026\257\306\233\311\205\355\017I\325\320\374\311\340~\210\0022\366\321\265A-\345\354\217\270\226\334:\372\362\210\017\365\361\323\223\275\332I\355\315h1?x\031\226\303\235\350\233\230\215\026?>\354b\235\333\350\213\330L-9$\3424w3Z06\304\264|\262|/\266\223\365d\363\350\376\360\3551\026~A\203\tO\027\357D\235\023\362\350\350\312\360\307\343\326Iu\177\264x=|\034\345\342\005\354&\006\3717\3344\275*\306\235$wtm\210I\257\014\312\377\001|\261\030\034"; + PyObject *data = __Pyx_DecompressString(cstring, 1128, 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 (2099 bytes) */ -const char* const bytes = "0Data not 'str'Genesis BlockMined block No stringNote that Cython is deliberately stricter than PEP-484 and rejects subclasses of builtin types. If you need to pass subclasses then set the 'annotation_typing' directive to False.?add_note>ddisableenablegcisenabledno default __reduce__ due to non-trivial __cinit__self._data is not None or self._hash is not None or self._prev_hash is not Nonesrc/polluck_blockchain/placeholder.py with nonce=BlockBlock.__reduce_cython__Block.__setstate_cython__Block._perform_hashBlock.compute_hashBlock.compute_hash_bytesBlockchainBlockchain.__init__Blockchain.add_blockBlockchain.create_genesis_blockBlockchain.proof_of_workNone__Pyx_PyDict_NextRefStringHolderStringHolder.__reduce_cython__StringHolder.__setstate_cython__TIMEZONE_UTCadd_blockappendasyncio.coroutinesbigblockblock_hashchaincline_in_tracebackcompute_hashcompute_hash_bytescreate_genesis_blockdatadatetime__dict___dictdifficultydigest__doc__dopt_basicsdopt_basics.datetimeextendfromtimestamp__func__genesis__getstate__hashhashlibhexdigestindex__init__int_is_coroutineitemslength__main____metaclass____module____name____new__new_blocknoncepack_perform_hashpolluck_blockchain.placeholderpopprefix__prepare__previous_hashprintproof_of_workptrpy_bytespy_string__pyx_checksum__pyx_result__pyx_state__pyx_type__pyx_unpickle_Block__pyx_vtable____qualname____reduce____reduce_cython____reduce_ex__returnself__set_name__setdefault__setstate____setstate_cython__sha256startswithstatestrstruct__test__timetimestampto_bytesupdateuse_setstatevalues\200\001\330\004#\2401\240F\250!\200A\340\010\024\220A\330\t\n\330\010\014\320\014\"\240!\340\010\014\210N\230!\200A\340\017\020\330\t\n\330\010\021\220\024\220R\220t\2301\330\010\t\330\014\031\230\025\230m\2501\330\014\017\210z\230\033\240A\240Q\330\020\027\220q\330\014\021\220\032\2301\200A\340\010\020\220\t\230\021\330\010\r\210W\220A\220T\230\027\240\t\250\021\250#\250Q\330\010\r\210W\220A\220^\2401\240D\250\001\330\010\r\210W\220A\220T\230""\026\230q\330\010\r\210W\220A\220T\230\033\240A\330\010\r\210W\220A\220T\230\027\240\t\250\021\250#\250Q\340\010\017\210w\220g\230Q\230a\200A\330\010\022\220%\220q\330\014\022\220!\330\014\021\220\021\330\014\032\230!\330\014\022\220!\340\010\017\210x\220w\230m\2501\330\010\014\210F\220'\230\021\230!\200A\330\010\017\210t\220>\240\022\2407\250!\200A\330\010\017\210t\220>\240\022\240:\250Q\200\001\330\004\n\210+\220Q\200\001\360\010\000\005\016\210T\220\030\230\024\230X\240T\250\031\260$\260i\270t\300=\320PT\320TU\330\004\014\210G\2201\220F\230,\240a\330\004\007\200v\210W\220E\230\024\230Q\330\010\022\220!\330\010\027\220q\340\010\030\230\001\330\004\007\200q\330\010\017\320\017&\240d\250!\2507\260+\270W\300A\340\010\017\320\017&\240d\250!\2507\260+\270Q\320\004\036\230h\240a\330\010\024\220E\230\021\330\014\022\220#\220Q\220d\230!\330\014\021\220\021\330\014\032\230$\230f\240B\240b\250\001\330\014\022\220!\360\010\000\t\022\220\030\230\024\230^\2501\250A\360\006\000\t\r\210F\220'\230\021\230!\330\010\r\210Q\210n\230A\230Y\320&9\270\021\270)\3001\360\006\000\t\020\210q\200\001\340\004\037\230q\320 0\260\013\270;\300k\320QR\330\004\023\2205\230\010\240\001\240\021\330\004\007\200|\2207\230!\330\010'\240q\250\010\260\016\270a\330\004\013\2101"; + #else /* compression: none (2029 bytes) */ +const char* const bytes = "0Data not 'str'Genesis BlockMined block No stringNote that Cython is deliberately stricter than PEP-484 and rejects subclasses of builtin types. If you need to pass subclasses then set the 'annotation_typing' directive to False.?add_note>ddisableenablegcisenabledno default __reduce__ due to non-trivial __cinit__self._data is not None or self._hash is not None or self._prev_hash is not Nonesrc/polluck_blockchain/placeholder.py with nonce=BlockBlock.__reduce_cython__Block.__setstate_cython__Block._perform_hashBlock.compute_hashBlock.compute_hash_bytesBlockchainBlockchain.__reduce_cython__Blockchain.__setstate_cython__Blockchain.add_blockBlockchain.create_genesis_blockBlockchain.proof_of_work__Pyx_PyDict_NextRefStringHolderStringHolder.__reduce_cython__StringHolder.__setstate_cython__TIMEZONE_UTCadd_blockasyncio.coroutinesbigblockcline_in_tracebackcompute_hashcompute_hash_bytescreate_genesis_blockdatadatetime__dict___dictdifficultydigestdopt_basicsdopt_basics.datetimeextendfromtimestamp__func____getstate__hashhashlibhexdigestindex_is_coroutineitemslength__main____module____name____new__noncepack_perform_hashpolluck_blockchain.placeholderpopprevious_hashprintproof_of_workptrpy_bytespy_string__pyx_checksum__pyx_result__pyx_state__pyx_type__pyx_unpickle_Block__pyx_vtable____qualname____reduce____reduce_cython____reduce_ex__self__set_name__setdefault__setstate____setstate_cython__sha256startswithstatestrstruct__test__timetimestampto_bytesupdateuse_setstatevalues\200\001\330\004#\2401\240F\250!\200A\330\036\037\330\010\024\220D\230\006\230a\230t\2408\2501\330\010\024\220E\230\021\330\014\023\2204\220x\230r\240\021\330\014\021\220\021\330\014\032\230!\330\014\022\220!\360\010\000\t\022\220\030\230\024\230^\2501\250A\360\006\000\t\r\210F\220'\230\021\230!\330\010\014\210K\220q\330\010\r\210Q\210n\230A\230Y\320&9\270\021\270)\3001\360\006\000\t\020\210q\200A\360\006\000\020\021\340\010\021\220\024\220R\220t\2301\330\010\t\330\014\031\230\025\230m\2501\330\014""\017\210z\230\033\240A\240Q\330\020\027\220q\330\014\021\220\033\230A\200A\340\010\020\220\t\230\021\330\010\r\210W\220A\220T\230\027\240\t\250\021\250#\250Q\330\010\r\210W\220A\220^\2401\240D\250\001\330\010\r\210W\220A\220T\230\026\230q\330\010\r\210W\220A\220T\230\033\240A\330\010\r\210W\220A\220T\230\027\240\t\250\021\250#\250Q\340\010\017\210w\220g\230Q\230a\200A\340\010\022\220%\220q\330\014\022\220!\330\014\021\220\021\330\014\032\230!\330\014\022\220!\340\010\017\210x\220w\230m\2501\330\010\014\210F\220'\230\021\230!\200A\330\010\017\210t\220>\240\022\2407\250!\200A\330\010\017\210t\220>\240\022\240:\250Q\200\001\330\004\n\210+\220Q\200\001\360\010\000\005\016\210T\220\030\230\024\230X\240T\250\031\260$\260i\270t\300=\320PT\320TU\330\004\014\210G\2201\220F\230,\240a\330\004\007\200v\210W\220E\230\024\230Q\330\010\022\220!\330\010\027\220q\340\010\030\230\001\330\004\007\200q\330\010\017\320\017&\240d\250!\2507\260+\270W\300A\340\010\017\320\017&\240d\250!\2507\260+\270Q\200\001\340\004\037\230q\320 0\260\013\270;\300k\320QR\330\004\023\2205\230\010\240\001\240\021\330\004\007\200|\2207\230!\330\010'\240q\250\010\260\016\270a\330\004\013\2101"; 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 < 117; i++) { + for (int i = 0; i < 105; i++) { Py_ssize_t bytes_length = index[i].length; PyObject *string = PyUnicode_DecodeUTF8(bytes + pos, bytes_length, NULL); if (likely(string) && i >= 19) PyUnicode_InternInPlace(&string); @@ -7992,7 +8775,7 @@ const char* const bytes = "0Data not 'str'Genesis BlockMined block No stringNote stringtab[i] = string; pos += bytes_length; } - for (int i = 117; i < 128; i++) { + for (int i = 105; i < 115; i++) { Py_ssize_t bytes_length = index[i].length; PyObject *string = PyBytes_FromStringAndSize(bytes + pos, bytes_length); stringtab[i] = string; @@ -8003,15 +8786,15 @@ const char* const bytes = "0Data not 'str'Genesis BlockMined block No stringNote } } Py_XDECREF(data); - for (Py_ssize_t i = 0; i < 128; i++) { + for (Py_ssize_t i = 0; i < 115; i++) { if (unlikely(PyObject_Hash(stringtab[i]) == -1)) { __PYX_ERR(0, 1, __pyx_L1_error) } } #if CYTHON_IMMORTAL_CONSTANTS { - PyObject **table = stringtab + 117; - for (Py_ssize_t i=0; i<11; ++i) { + PyObject **table = stringtab + 105; + for (Py_ssize_t i=0; i<10; ++i) { #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL); #else @@ -8106,29 +8889,34 @@ static int __Pyx_CreateCodeObjects(__pyx_mstatetype *__pyx_mstate) { __pyx_mstate_global->__pyx_codeobj_tab[6] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_setstate_cython, __pyx_mstate->__pyx_kp_b_iso88591_1F, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[6])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 162}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_difficulty}; - __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_init, __pyx_mstate->__pyx_kp_b_iso88591_A_A_N, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[7])) goto bad; + const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 186}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; + __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_q_xwm1_F, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[7])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 170}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_genesis}; - __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_create_genesis_block, __pyx_mstate->__pyx_kp_b_iso88591_A_q_xwm1_F, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[8])) goto bad; + const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 197}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_block}; + __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_proof_of_work, __pyx_mstate->__pyx_kp_b_iso88591_A_Rt1_m1_z_AQ_q_A, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[8])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 180}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_block, __pyx_mstate->__pyx_n_u_prefix, __pyx_mstate->__pyx_n_u_block_hash}; - __pyx_mstate_global->__pyx_codeobj_tab[9] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_src_polluck_blockchain_placehold, __pyx_mstate->__pyx_n_u_proof_of_work, __pyx_mstate->__pyx_kp_b_iso88591_A_Rt1_m1_z_AQ_q_1, 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), 209}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_data}; + __pyx_mstate_global->__pyx_codeobj_tab[9] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_src_polluck_blockchain_placehold, __pyx_mstate->__pyx_n_u_add_block, __pyx_mstate->__pyx_kp_b_iso88591_A_D_at81_E_4xr_1A_F_Kq_QnAY_9_1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[9])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 3, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 191}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_data, __pyx_mstate->__pyx_n_u_new_block}; - __pyx_mstate_global->__pyx_codeobj_tab[10] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_src_polluck_blockchain_placehold, __pyx_mstate->__pyx_n_u_add_block, __pyx_mstate->__pyx_kp_b_iso88591_ha_E_Qd_fBb_1A_F_QnAY_9_1_q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[10])) 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[10] = __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[10])) 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[11] = __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[11])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 4}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_pyx_type, __pyx_mstate->__pyx_n_u_pyx_checksum, __pyx_mstate->__pyx_n_u_pyx_state, __pyx_mstate->__pyx_n_u_pyx_result}; - __pyx_mstate_global->__pyx_codeobj_tab[11] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_pyx_unpickle_Block, __pyx_mstate->__pyx_kp_b_iso88591_q_0_kQR_5_7_q_a_1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[11])) goto bad; + __pyx_mstate_global->__pyx_codeobj_tab[12] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_pyx_unpickle_Block, __pyx_mstate->__pyx_kp_b_iso88591_q_0_kQR_5_7_q_a_1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[12])) goto bad; } Py_DECREF(tuple_dedup_map); return 0; @@ -9818,16 +10606,6 @@ __Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj) return 0; } -/* PyObjectSetAttrStr */ -#if CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) { - PyTypeObject* tp = Py_TYPE(obj); - if (likely(tp->tp_setattro)) - return tp->tp_setattro(obj, attr_name, value); - return PyObject_SetAttr(obj, attr_name, value); -} -#endif - /* PyObjectVectorCallKwBuilder */ #if CYTHON_VECTORCALL static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) { @@ -9860,237 +10638,56 @@ CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyO } #endif -/* PyObjectGetMethod (used by PyObjectCallMethod1) */ -#if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000))) -static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) { - PyObject *attr; -#if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP - __Pyx_TypeName type_name; - PyTypeObject *tp = Py_TYPE(obj); - PyObject *descr; - descrgetfunc f = NULL; - PyObject **dictptr, *dict; - int meth_found = 0; - assert (*method == NULL); - if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) { - attr = __Pyx_PyObject_GetAttrStr(obj, name); - goto try_unpack; - } - if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) { - return 0; - } - descr = _PyType_Lookup(tp, name); - if (likely(descr != NULL)) { - Py_INCREF(descr); -#if defined(Py_TPFLAGS_METHOD_DESCRIPTOR) && Py_TPFLAGS_METHOD_DESCRIPTOR - if (__Pyx_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR)) -#else - #ifdef __Pyx_CyFunction_USED - if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr))) - #else - if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type))) - #endif -#endif - { - meth_found = 1; - } else { - f = Py_TYPE(descr)->tp_descr_get; - if (f != NULL && PyDescr_IsData(descr)) { - attr = f(descr, obj, (PyObject *)Py_TYPE(obj)); - Py_DECREF(descr); - goto try_unpack; - } - } - } - dictptr = _PyObject_GetDictPtr(obj); - if (dictptr != NULL && (dict = *dictptr) != NULL) { - Py_INCREF(dict); - attr = __Pyx_PyDict_GetItemStr(dict, name); - if (attr != NULL) { - Py_INCREF(attr); - Py_DECREF(dict); - Py_XDECREF(descr); - goto try_unpack; - } - Py_DECREF(dict); - } - if (meth_found) { - *method = descr; - return 1; - } - if (f != NULL) { - attr = f(descr, obj, (PyObject *)Py_TYPE(obj)); - Py_DECREF(descr); - goto try_unpack; - } - if (likely(descr != NULL)) { - *method = descr; - return 0; - } - type_name = __Pyx_PyType_GetFullyQualifiedName(tp); - PyErr_Format(PyExc_AttributeError, - "'" __Pyx_FMT_TYPENAME "' object has no attribute '%U'", - type_name, name); - __Pyx_DECREF_TypeName(type_name); - return 0; -#else - attr = __Pyx_PyObject_GetAttrStr(obj, name); - goto try_unpack; -#endif -try_unpack: -#if CYTHON_UNPACK_METHODS - if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) { - PyObject *function = PyMethod_GET_FUNCTION(attr); - Py_INCREF(function); - Py_DECREF(attr); - *method = function; - return 1; - } -#endif - *method = attr; - return 0; +/* PyObjectSetAttrStr */ +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_setattro)) + return tp->tp_setattro(obj, attr_name, value); + return PyObject_SetAttr(obj, attr_name, value); } #endif -/* PyObjectCallMethod1 (used by append) */ -#if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000))) -static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) { - PyObject *result = __Pyx_PyObject_CallOneArg(method, arg); - Py_DECREF(method); +/* PySequenceMultiply */ +#if CYTHON_USE_TYPE_SLOTS +static PyObject* __Pyx_PySequence_Multiply_Generic(PyObject *seq, Py_ssize_t mul) { + PyObject *result, *pymul = PyLong_FromSsize_t(mul); + if (unlikely(!pymul)) + return NULL; + result = PyNumber_Multiply(seq, pymul); + Py_DECREF(pymul); return result; } -#endif -static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) { -#if CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000)) - PyObject *args[2] = {obj, arg}; - (void) __Pyx_PyObject_CallOneArg; - (void) __Pyx_PyObject_Call2Args; - return PyObject_VectorcallMethod(method_name, args, 2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); -#else - PyObject *method = NULL, *result; - int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method); - if (likely(is_method)) { - result = __Pyx_PyObject_Call2Args(method, obj, arg); - Py_DECREF(method); - return result; - } - if (unlikely(!method)) return NULL; - return __Pyx__PyObject_CallMethod1(method, arg); -#endif -} - -/* append */ -static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) { - if (likely(PyList_CheckExact(L))) { - if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1; +static CYTHON_INLINE PyObject* __Pyx_PySequence_Multiply(PyObject *seq, Py_ssize_t mul) { + PyTypeObject *type = Py_TYPE(seq); + if (likely(type->tp_as_sequence && type->tp_as_sequence->sq_repeat)) { + return type->tp_as_sequence->sq_repeat(seq, mul); } else { - PyObject* retval = __Pyx_PyObject_CallMethod1(L, __pyx_mstate_global->__pyx_n_u_append, x); - if (unlikely(!retval)) - return -1; - Py_DECREF(retval); + return __Pyx_PySequence_Multiply_Generic(seq, mul); } +} +#endif + +/* ExtTypeTest */ +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + __Pyx_TypeName obj_type_name; + __Pyx_TypeName type_name; + if (unlikely(!type)) { + PyErr_SetString(PyExc_SystemError, "Missing type object"); + return 0; + } + if (likely(__Pyx_TypeCheck(obj, type))) + return 1; + obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj)); + type_name = __Pyx_PyType_GetFullyQualifiedName(type); + PyErr_Format(PyExc_TypeError, + "Cannot convert " __Pyx_FMT_TYPENAME " to " __Pyx_FMT_TYPENAME, + obj_type_name, type_name); + __Pyx_DECREF_TypeName(obj_type_name); + __Pyx_DECREF_TypeName(type_name); return 0; } -/* PyLongBinop */ -#if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_Fallback___Pyx_PyLong_AddObjC(PyObject *op1, PyObject *op2, int inplace) { - return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2); -} -#if CYTHON_USE_PYLONG_INTERNALS -static PyObject* __Pyx_Unpacked___Pyx_PyLong_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) { - CYTHON_MAYBE_UNUSED_VAR(inplace); - CYTHON_UNUSED_VAR(zerodivision_check); - const long b = intval; - long a; - const PY_LONG_LONG llb = intval; - PY_LONG_LONG lla; - if (unlikely(__Pyx_PyLong_IsZero(op1))) { - return __Pyx_NewRef(op2); - } - const int is_positive = __Pyx_PyLong_IsPos(op1); - const digit* digits = __Pyx_PyLong_Digits(op1); - const Py_ssize_t size = __Pyx_PyLong_DigitCount(op1); - if (likely(size == 1)) { - a = (long) digits[0]; - if (!is_positive) a *= -1; - } else { - switch (size) { - case 2: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - if (!is_positive) a *= -1; - goto calculate_long; - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { - lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - if (!is_positive) lla *= -1; - goto calculate_long_long; - } - break; - case 3: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - if (!is_positive) a *= -1; - goto calculate_long; - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { - lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - if (!is_positive) lla *= -1; - goto calculate_long_long; - } - break; - case 4: - if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - if (!is_positive) a *= -1; - goto calculate_long; - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { - lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - if (!is_positive) lla *= -1; - goto calculate_long_long; - } - break; - } - return PyLong_Type.tp_as_number->nb_add(op1, op2); - } - calculate_long: - { - long x; - x = a + b; - return PyLong_FromLong(x); - } - calculate_long_long: - { - PY_LONG_LONG llx; - llx = lla + llb; - return PyLong_FromLongLong(llx); - } - -} -#endif -static PyObject* __Pyx_Float___Pyx_PyLong_AddObjC(PyObject *float_val, long intval, int zerodivision_check) { - CYTHON_UNUSED_VAR(zerodivision_check); - const long b = intval; - double a = __Pyx_PyFloat_AS_DOUBLE(float_val); - double result; - - result = ((double)a) + (double)b; - return PyFloat_FromDouble(result); -} -static CYTHON_INLINE PyObject* __Pyx_PyLong_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) { - CYTHON_MAYBE_UNUSED_VAR(intval); - CYTHON_UNUSED_VAR(zerodivision_check); - #if CYTHON_USE_PYLONG_INTERNALS - if (likely(PyLong_CheckExact(op1))) { - return __Pyx_Unpacked___Pyx_PyLong_AddObjC(op1, op2, intval, inplace, zerodivision_check); - } - #endif - if (PyFloat_CheckExact(op1)) { - return __Pyx_Float___Pyx_PyLong_AddObjC(op1, intval, zerodivision_check); - } - return __Pyx_Fallback___Pyx_PyLong_AddObjC(op1, op2, inplace); -} -#endif - /* GetItemInt */ static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { PyObject *r; @@ -10272,26 +10869,6 @@ bad: #endif } -/* ExtTypeTest */ -static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { - __Pyx_TypeName obj_type_name; - __Pyx_TypeName type_name; - if (unlikely(!type)) { - PyErr_SetString(PyExc_SystemError, "Missing type object"); - return 0; - } - if (likely(__Pyx_TypeCheck(obj, type))) - return 1; - obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj)); - type_name = __Pyx_PyType_GetFullyQualifiedName(type); - PyErr_Format(PyExc_TypeError, - "Cannot convert " __Pyx_FMT_TYPENAME " to " __Pyx_FMT_TYPENAME, - obj_type_name, type_name); - __Pyx_DECREF_TypeName(obj_type_name); - __Pyx_DECREF_TypeName(type_name); - return 0; -} - /* AllocateExtensionType */ static PyObject *__Pyx_AllocateExtensionType(PyTypeObject *t, int is_final) { if (is_final || likely(!__Pyx_PyType_HasFeature(t, Py_TPFLAGS_IS_ABSTRACT))) { @@ -10498,6 +11075,98 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { return __Pyx_PyObject_FastCall(func, arg + 1, 0 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); } +/* PyObjectGetMethod (used by PyObjectCallMethod0) */ +#if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000))) +static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) { + PyObject *attr; +#if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP + __Pyx_TypeName type_name; + PyTypeObject *tp = Py_TYPE(obj); + PyObject *descr; + descrgetfunc f = NULL; + PyObject **dictptr, *dict; + int meth_found = 0; + assert (*method == NULL); + if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) { + attr = __Pyx_PyObject_GetAttrStr(obj, name); + goto try_unpack; + } + if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) { + return 0; + } + descr = _PyType_Lookup(tp, name); + if (likely(descr != NULL)) { + Py_INCREF(descr); +#if defined(Py_TPFLAGS_METHOD_DESCRIPTOR) && Py_TPFLAGS_METHOD_DESCRIPTOR + if (__Pyx_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR)) +#else + #ifdef __Pyx_CyFunction_USED + if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr))) + #else + if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type))) + #endif +#endif + { + meth_found = 1; + } else { + f = Py_TYPE(descr)->tp_descr_get; + if (f != NULL && PyDescr_IsData(descr)) { + attr = f(descr, obj, (PyObject *)Py_TYPE(obj)); + Py_DECREF(descr); + goto try_unpack; + } + } + } + dictptr = _PyObject_GetDictPtr(obj); + if (dictptr != NULL && (dict = *dictptr) != NULL) { + Py_INCREF(dict); + attr = __Pyx_PyDict_GetItemStr(dict, name); + if (attr != NULL) { + Py_INCREF(attr); + Py_DECREF(dict); + Py_XDECREF(descr); + goto try_unpack; + } + Py_DECREF(dict); + } + if (meth_found) { + *method = descr; + return 1; + } + if (f != NULL) { + attr = f(descr, obj, (PyObject *)Py_TYPE(obj)); + Py_DECREF(descr); + goto try_unpack; + } + if (likely(descr != NULL)) { + *method = descr; + return 0; + } + type_name = __Pyx_PyType_GetFullyQualifiedName(tp); + PyErr_Format(PyExc_AttributeError, + "'" __Pyx_FMT_TYPENAME "' object has no attribute '%U'", + type_name, name); + __Pyx_DECREF_TypeName(type_name); + return 0; +#else + attr = __Pyx_PyObject_GetAttrStr(obj, name); + goto try_unpack; +#endif +try_unpack: +#if CYTHON_UNPACK_METHODS + if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) { + PyObject *function = PyMethod_GET_FUNCTION(attr); + Py_INCREF(function); + Py_DECREF(attr); + *method = function; + return 1; + } +#endif + *method = attr; + return 0; +} +#endif + /* PyObjectCallMethod0 (used by PyType_Ready) */ static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) { #if CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000)) @@ -12446,124 +13115,6 @@ static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qual return op; } -/* CalculateMetaclass (used by Py3ClassCreate) */ -static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) { - Py_ssize_t i, nbases; -#if CYTHON_ASSUME_SAFE_SIZE - nbases = PyTuple_GET_SIZE(bases); -#else - nbases = PyTuple_Size(bases); - if (nbases < 0) return NULL; -#endif - for (i=0; i < nbases; i++) { - PyTypeObject *tmptype; -#if CYTHON_ASSUME_SAFE_MACROS - PyObject *tmp = PyTuple_GET_ITEM(bases, i); -#else - PyObject *tmp = PyTuple_GetItem(bases, i); - if (!tmp) return NULL; -#endif - tmptype = Py_TYPE(tmp); - if (!metaclass) { - metaclass = tmptype; - continue; - } - if (PyType_IsSubtype(metaclass, tmptype)) - continue; - if (PyType_IsSubtype(tmptype, metaclass)) { - metaclass = tmptype; - continue; - } - PyErr_SetString(PyExc_TypeError, - "metaclass conflict: " - "the metaclass of a derived class " - "must be a (non-strict) subclass " - "of the metaclasses of all its bases"); - return NULL; - } - if (!metaclass) { - metaclass = &PyType_Type; - } - Py_INCREF((PyObject*) metaclass); - return (PyObject*) metaclass; -} - -/* PyObjectLookupSpecial (used by Py3ClassCreate) */ -#if CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PyObject* __Pyx__PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name, int with_error) { - PyObject *res; - PyTypeObject *tp = Py_TYPE(obj); - res = _PyType_Lookup(tp, attr_name); - if (likely(res)) { - descrgetfunc f = Py_TYPE(res)->tp_descr_get; - if (!f) { - Py_INCREF(res); - } else { - res = f(res, obj, (PyObject *)tp); - } - } else if (with_error) { - PyErr_SetObject(PyExc_AttributeError, attr_name); - } - return res; -} -#endif - -/* Py3ClassCreate */ -static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, - PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) { - PyObject *ns; - if (metaclass) { - PyObject *prep = __Pyx_PyObject_GetAttrStrNoError(metaclass, __pyx_mstate_global->__pyx_n_u_prepare); - if (prep) { - PyObject *pargs[3] = {NULL, name, bases}; - ns = __Pyx_PyObject_FastCallDict(prep, pargs+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, mkw); - Py_DECREF(prep); - } else { - if (unlikely(PyErr_Occurred())) - return NULL; - ns = PyDict_New(); - } - } else { - ns = PyDict_New(); - } - if (unlikely(!ns)) - return NULL; - if (unlikely(PyObject_SetItem(ns, __pyx_mstate_global->__pyx_n_u_module, modname) < 0)) goto bad; - if (unlikely(PyObject_SetItem(ns, __pyx_mstate_global->__pyx_n_u_qualname, qualname) < 0)) goto bad; - if (unlikely(doc && PyObject_SetItem(ns, __pyx_mstate_global->__pyx_n_u_doc, doc) < 0)) goto bad; - return ns; -bad: - Py_DECREF(ns); - return NULL; -} -static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, - PyObject *dict, PyObject *mkw, - int calculate_metaclass, int allow_py2_metaclass) { - PyObject *result; - PyObject *owned_metaclass = NULL; - PyObject *margs[4] = {NULL, name, bases, dict}; - if (allow_py2_metaclass) { - owned_metaclass = PyObject_GetItem(dict, __pyx_mstate_global->__pyx_n_u_metaclass); - if (owned_metaclass) { - metaclass = owned_metaclass; - } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) { - PyErr_Clear(); - } else { - return NULL; - } - } - if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) { - metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases); - Py_XDECREF(owned_metaclass); - if (unlikely(!metaclass)) - return NULL; - owned_metaclass = metaclass; - } - result = __Pyx_PyObject_FastCallDict(metaclass, margs+1, 3 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, mkw); - Py_XDECREF(owned_metaclass); - return result; -} - /* CLineInTraceback (used by AddTraceback) */ #if CYTHON_CLINE_IN_TRACEBACK && CYTHON_CLINE_IN_TRACEBACK_RUNTIME #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000 @@ -13495,164 +14046,6 @@ raise_neg_overflow: return (long) -1; } -/* CIntToPy */ -static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value) { -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - const long neg_one = (long) -1, const_zero = (long) 0; -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic pop -#endif - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(long) < sizeof(long)) { - return PyLong_FromLong((long) value); - } else if (sizeof(long) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#if !CYTHON_COMPILING_IN_PYPY - } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); -#endif - } - } else { - if (sizeof(long) <= sizeof(long)) { - return PyLong_FromLong((long) value); - } else if (sizeof(long) <= 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(long), - 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(long)); - 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 - } -} - -/* UpdateUnpickledDict */ -static int __Pyx__UpdateUnpickledDict(PyObject *obj, PyObject *state, Py_ssize_t index) { - PyObject *state_dict = __Pyx_PySequence_ITEM(state, index); - if (unlikely(!state_dict)) { - return -1; - } - int non_empty = PyObject_IsTrue(state_dict); - if (non_empty == 0) { - Py_DECREF(state_dict); - return 0; - } else if (unlikely(non_empty == -1)) { - return -1; - } - PyObject *dict; - #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000 - dict = PyObject_GetAttrString(obj, "__dict__"); - #else - dict = PyObject_GenericGetDict(obj, NULL); - #endif - if (unlikely(!dict)) { - Py_DECREF(state_dict); - return -1; - } - int result; - if (likely(PyDict_CheckExact(dict))) { - result = PyDict_Update(dict, state_dict); - } else { - PyObject *obj_result = __Pyx_PyObject_CallMethod1(dict, __pyx_mstate_global->__pyx_n_u_update, state_dict); - if (likely(obj_result)) { - Py_DECREF(obj_result); - result = 0; - } else { - result = -1; - } - } - Py_DECREF(state_dict); - Py_DECREF(dict); - return result; -} -static int __Pyx_UpdateUnpickledDict(PyObject *obj, PyObject *state, Py_ssize_t index) { - Py_ssize_t state_size = __Pyx_PyTuple_GET_SIZE(state); - #if !CYTHON_ASSUME_SAFE_SIZE - if (unlikely(state_size == -1)) return -1; - #endif - if (state_size <= index) { - return 0; - } - return __Pyx__UpdateUnpickledDict(obj, state, index); -} - -/* FormatTypeName */ -#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000 -static __Pyx_TypeName -__Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp) -{ - PyObject *module = NULL, *name = NULL, *result = NULL; - #if __PYX_LIMITED_VERSION_HEX < 0x030b0000 - name = __Pyx_PyObject_GetAttrStr((PyObject *)tp, - __pyx_mstate_global->__pyx_n_u_qualname); - #else - name = PyType_GetQualName(tp); - #endif - if (unlikely(name == NULL) || unlikely(!PyUnicode_Check(name))) goto bad; - module = __Pyx_PyObject_GetAttrStr((PyObject *)tp, - __pyx_mstate_global->__pyx_n_u_module); - if (unlikely(module == NULL) || unlikely(!PyUnicode_Check(module))) goto bad; - if (PyUnicode_CompareWithASCIIString(module, "builtins") == 0) { - result = name; - name = NULL; - goto done; - } - result = PyUnicode_FromFormat("%U.%U", module, name); - if (unlikely(result == NULL)) goto bad; - done: - Py_XDECREF(name); - Py_XDECREF(module); - return result; - bad: - PyErr_Clear(); - if (name) { - result = name; - name = NULL; - } else { - result = __Pyx_NewRef(__pyx_mstate_global->__pyx_kp_u__2); - } - goto done; -} -#endif - /* CIntFromPy */ static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC @@ -13903,6 +14296,260 @@ raise_neg_overflow: return (int) -1; } +/* 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 + } +} + +/* CIntToPy */ +static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const long neg_one = (long) -1, const_zero = (long) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(long) < sizeof(long)) { + return PyLong_FromLong((long) value); + } else if (sizeof(long) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#if !CYTHON_COMPILING_IN_PYPY + } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(long) <= sizeof(long)) { + return PyLong_FromLong((long) value); + } else if (sizeof(long) <= 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(long), + 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(long)); + 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 + } +} + +/* PyObjectCallMethod1 */ +#if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000))) +static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) { + PyObject *result = __Pyx_PyObject_CallOneArg(method, arg); + Py_DECREF(method); + return result; +} +#endif +static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) { +#if CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000)) + PyObject *args[2] = {obj, arg}; + (void) __Pyx_PyObject_CallOneArg; + (void) __Pyx_PyObject_Call2Args; + return PyObject_VectorcallMethod(method_name, args, 2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); +#else + PyObject *method = NULL, *result; + int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method); + if (likely(is_method)) { + result = __Pyx_PyObject_Call2Args(method, obj, arg); + Py_DECREF(method); + return result; + } + if (unlikely(!method)) return NULL; + return __Pyx__PyObject_CallMethod1(method, arg); +#endif +} + +/* UpdateUnpickledDict */ +static int __Pyx__UpdateUnpickledDict(PyObject *obj, PyObject *state, Py_ssize_t index) { + PyObject *state_dict = __Pyx_PySequence_ITEM(state, index); + if (unlikely(!state_dict)) { + return -1; + } + int non_empty = PyObject_IsTrue(state_dict); + if (non_empty == 0) { + Py_DECREF(state_dict); + return 0; + } else if (unlikely(non_empty == -1)) { + return -1; + } + PyObject *dict; + #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000 + dict = PyObject_GetAttrString(obj, "__dict__"); + #else + dict = PyObject_GenericGetDict(obj, NULL); + #endif + if (unlikely(!dict)) { + Py_DECREF(state_dict); + return -1; + } + int result; + if (likely(PyDict_CheckExact(dict))) { + result = PyDict_Update(dict, state_dict); + } else { + PyObject *obj_result = __Pyx_PyObject_CallMethod1(dict, __pyx_mstate_global->__pyx_n_u_update, state_dict); + if (likely(obj_result)) { + Py_DECREF(obj_result); + result = 0; + } else { + result = -1; + } + } + Py_DECREF(state_dict); + Py_DECREF(dict); + return result; +} +static int __Pyx_UpdateUnpickledDict(PyObject *obj, PyObject *state, Py_ssize_t index) { + Py_ssize_t state_size = __Pyx_PyTuple_GET_SIZE(state); + #if !CYTHON_ASSUME_SAFE_SIZE + if (unlikely(state_size == -1)) return -1; + #endif + if (state_size <= index) { + return 0; + } + return __Pyx__UpdateUnpickledDict(obj, state, index); +} + +/* FormatTypeName */ +#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000 +static __Pyx_TypeName +__Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp) +{ + PyObject *module = NULL, *name = NULL, *result = NULL; + #if __PYX_LIMITED_VERSION_HEX < 0x030b0000 + name = __Pyx_PyObject_GetAttrStr((PyObject *)tp, + __pyx_mstate_global->__pyx_n_u_qualname); + #else + name = PyType_GetQualName(tp); + #endif + if (unlikely(name == NULL) || unlikely(!PyUnicode_Check(name))) goto bad; + module = __Pyx_PyObject_GetAttrStr((PyObject *)tp, + __pyx_mstate_global->__pyx_n_u_module); + if (unlikely(module == NULL) || unlikely(!PyUnicode_Check(module))) goto bad; + if (PyUnicode_CompareWithASCIIString(module, "builtins") == 0) { + result = name; + name = NULL; + goto done; + } + result = PyUnicode_FromFormat("%U.%U", module, name); + if (unlikely(result == NULL)) goto bad; + done: + Py_XDECREF(name); + Py_XDECREF(module); + return result; + bad: + PyErr_Clear(); + if (name) { + result = name; + name = NULL; + } else { + result = __Pyx_NewRef(__pyx_mstate_global->__pyx_kp_u__2); + } + goto done; +} +#endif + /* FastTypeChecks */ #if CYTHON_COMPILING_IN_CPYTHON static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { diff --git a/src/polluck_blockchain/placeholder.py b/src/polluck_blockchain/placeholder.py index b478cd6..5c788b2 100644 --- a/src/polluck_blockchain/placeholder.py +++ b/src/polluck_blockchain/placeholder.py @@ -158,15 +158,32 @@ class Block: self._hash = StringHolder.__new__(StringHolder, value) +@cython.cclass class Blockchain: + _difficulty = cython.declare(cython.int, visibility="private") + _index = cython.declare(cython.Py_ssize_t, visibility="private") + chain = cython.declare(list[Block]) + + def __cinit__(self): + self._index = 0 + def __init__( self, difficulty: int = 1, ) -> None: self.chain: list[Block] = [] # self.difficulty = difficulty.to_bytes(8, "big") - self.difficulty = difficulty + self._difficulty = difficulty + @property + def index(self): + return self._index + + @property + def difficulty(self): + return self._difficulty + + @cython.ccall def create_genesis_block(self): genesis = Block( index=0, @@ -177,22 +194,25 @@ class Blockchain: genesis.hash = genesis.compute_hash() self.chain.append(genesis) + @cython.ccall def proof_of_work( self, block: Block, ) -> str: - prefix = "0" * self.difficulty + prefix = "0" * self._difficulty while True: block_hash = block.compute_hash() if block_hash.startswith(prefix): return block_hash - block.nonce += 1 + block._nonce += 1 + @cython.ccall def add_block(self, data: str) -> Block: + prev_hash = self.chain[self._index].hash new_block = Block( - index=len(self.chain), + index=(self._index + 1), data=data, - previous_hash=self.chain[-1].hash, + previous_hash=prev_hash, nonce=0, ) @@ -201,6 +221,7 @@ class Blockchain: # elapsed = time.perf_counter() - start self.chain.append(new_block) + self._index += 1 print(f"Mined block {new_block.index} with nonce={new_block.nonce}") # print(f"Mined block {new_block.index} in {elapsed:.3f}s with nonce={new_block.nonce}") diff --git a/src/polluck_blockchain/python_translate.c b/src/polluck_blockchain/python_translate.c index be1544d..c176534 100644 --- a/src/polluck_blockchain/python_translate.c +++ b/src/polluck_blockchain/python_translate.c @@ -2045,6 +2045,13 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject_Format(s, f)) #endif +/* PyObjectFormat.proto */ +#if CYTHON_USE_UNICODE_WRITER +static PyObject* __Pyx_PyObject_Format(PyObject* s, PyObject* f); +#else +#define __Pyx_PyObject_Format(s, f) PyObject_Format(s, f) +#endif + /* JoinPyUnicode.export */ static PyObject* __Pyx_PyUnicode_Join(PyObject** values, Py_ssize_t value_count, Py_ssize_t result_ulength, Py_UCS4 max_char); @@ -2444,7 +2451,7 @@ typedef struct { __Pyx_CachedCFunction __pyx_umethod_PyByteArray_Type__extend; PyObject *__pyx_tuple[4]; PyObject *__pyx_codeobj_tab[17]; - PyObject *__pyx_string_tab[122]; + PyObject *__pyx_string_tab[127]; PyObject *__pyx_number_tab[5]; /* #### Code section: module_state_contents ### */ /* CommonTypesMetaclass.module_state_decls */ @@ -2488,126 +2495,131 @@ static __pyx_mstatetype * const __pyx_mstate_global = &__pyx_mstate_global_stati /* #### Code section: constant_name_defines ### */ #define __pyx_kp_u_ __pyx_string_tab[0] #define __pyx_kp_u_0 __pyx_string_tab[1] -#define __pyx_kp_u_Genesis_Block __pyx_string_tab[2] -#define __pyx_kp_u_Mined_block __pyx_string_tab[3] -#define __pyx_kp_u_No_string __pyx_string_tab[4] -#define __pyx_kp_u_Note_that_Cython_is_deliberately __pyx_string_tab[5] -#define __pyx_kp_u_UTF_8 __pyx_string_tab[6] -#define __pyx_kp_u__2 __pyx_string_tab[7] -#define __pyx_kp_u_add_note __pyx_string_tab[8] -#define __pyx_kp_u_d __pyx_string_tab[9] -#define __pyx_kp_u_datetime_datetime __pyx_string_tab[10] -#define __pyx_kp_u_src_polluck_blockchain_python_tr __pyx_string_tab[11] -#define __pyx_kp_u_with_nonce __pyx_string_tab[12] -#define __pyx_n_u_Block __pyx_string_tab[13] -#define __pyx_n_u_Block___init __pyx_string_tab[14] -#define __pyx_n_u_Block__perform_hash __pyx_string_tab[15] -#define __pyx_n_u_Block_compute_hash __pyx_string_tab[16] -#define __pyx_n_u_Block_compute_hash_bytes __pyx_string_tab[17] -#define __pyx_n_u_Block_data __pyx_string_tab[18] -#define __pyx_n_u_Block_hash __pyx_string_tab[19] -#define __pyx_n_u_Block_index __pyx_string_tab[20] -#define __pyx_n_u_Block_nonce __pyx_string_tab[21] -#define __pyx_n_u_Block_prev_hash __pyx_string_tab[22] -#define __pyx_n_u_Block_timestamp __pyx_string_tab[23] -#define __pyx_n_u_Blockchain __pyx_string_tab[24] -#define __pyx_n_u_Blockchain___init __pyx_string_tab[25] -#define __pyx_n_u_Blockchain_add_block __pyx_string_tab[26] -#define __pyx_n_u_Blockchain_create_genesis_block __pyx_string_tab[27] -#define __pyx_n_u_Blockchain_proof_of_work __pyx_string_tab[28] -#define __pyx_n_u_None __pyx_string_tab[29] -#define __pyx_n_u_Pyx_PyDict_NextRef __pyx_string_tab[30] -#define __pyx_n_u_add_block __pyx_string_tab[31] -#define __pyx_n_u_append __pyx_string_tab[32] -#define __pyx_n_u_asyncio_coroutines __pyx_string_tab[33] -#define __pyx_n_u_big __pyx_string_tab[34] -#define __pyx_n_u_block __pyx_string_tab[35] -#define __pyx_n_u_block_hash __pyx_string_tab[36] -#define __pyx_n_u_chain __pyx_string_tab[37] -#define __pyx_n_u_cline_in_traceback __pyx_string_tab[38] -#define __pyx_n_u_compute_hash __pyx_string_tab[39] -#define __pyx_n_u_compute_hash_bytes __pyx_string_tab[40] -#define __pyx_n_u_create_genesis_block __pyx_string_tab[41] -#define __pyx_n_u_data __pyx_string_tab[42] -#define __pyx_n_u_data_2 __pyx_string_tab[43] -#define __pyx_n_u_datetime __pyx_string_tab[44] -#define __pyx_n_u_difficulty __pyx_string_tab[45] -#define __pyx_n_u_digest __pyx_string_tab[46] -#define __pyx_n_u_doc __pyx_string_tab[47] -#define __pyx_n_u_dopt_basics __pyx_string_tab[48] -#define __pyx_n_u_dopt_basics_datetime __pyx_string_tab[49] -#define __pyx_n_u_encode __pyx_string_tab[50] -#define __pyx_n_u_extend __pyx_string_tab[51] -#define __pyx_n_u_float __pyx_string_tab[52] -#define __pyx_n_u_float_to_bytes __pyx_string_tab[53] -#define __pyx_n_u_fromtimestamp __pyx_string_tab[54] -#define __pyx_n_u_func __pyx_string_tab[55] -#define __pyx_n_u_genesis __pyx_string_tab[56] -#define __pyx_n_u_hash __pyx_string_tab[57] -#define __pyx_n_u_hash_2 __pyx_string_tab[58] -#define __pyx_n_u_hashlib __pyx_string_tab[59] -#define __pyx_n_u_hexdigest __pyx_string_tab[60] -#define __pyx_n_u_index __pyx_string_tab[61] -#define __pyx_n_u_index_2 __pyx_string_tab[62] -#define __pyx_n_u_init __pyx_string_tab[63] -#define __pyx_n_u_int __pyx_string_tab[64] -#define __pyx_n_u_is_coroutine __pyx_string_tab[65] -#define __pyx_n_u_items __pyx_string_tab[66] -#define __pyx_n_u_main __pyx_string_tab[67] -#define __pyx_n_u_metaclass __pyx_string_tab[68] -#define __pyx_n_u_module __pyx_string_tab[69] -#define __pyx_n_u_name __pyx_string_tab[70] -#define __pyx_n_u_new_block __pyx_string_tab[71] -#define __pyx_n_u_nonce __pyx_string_tab[72] -#define __pyx_n_u_nonce_2 __pyx_string_tab[73] -#define __pyx_n_u_num __pyx_string_tab[74] -#define __pyx_n_u_pack __pyx_string_tab[75] -#define __pyx_n_u_parts __pyx_string_tab[76] -#define __pyx_n_u_perform_hash __pyx_string_tab[77] -#define __pyx_n_u_polluck_blockchain_python_transl __pyx_string_tab[78] -#define __pyx_n_u_pop __pyx_string_tab[79] -#define __pyx_n_u_prefix __pyx_string_tab[80] -#define __pyx_n_u_prepare __pyx_string_tab[81] -#define __pyx_n_u_prev_hash __pyx_string_tab[82] -#define __pyx_n_u_prev_hash_2 __pyx_string_tab[83] -#define __pyx_n_u_previous_hash __pyx_string_tab[84] -#define __pyx_n_u_print __pyx_string_tab[85] -#define __pyx_n_u_proof_of_work __pyx_string_tab[86] -#define __pyx_n_u_property __pyx_string_tab[87] -#define __pyx_n_u_qualname __pyx_string_tab[88] -#define __pyx_n_u_return __pyx_string_tab[89] -#define __pyx_n_u_self __pyx_string_tab[90] -#define __pyx_n_u_set_name __pyx_string_tab[91] -#define __pyx_n_u_setdefault __pyx_string_tab[92] -#define __pyx_n_u_setter __pyx_string_tab[93] -#define __pyx_n_u_sha256 __pyx_string_tab[94] -#define __pyx_n_u_slots __pyx_string_tab[95] -#define __pyx_n_u_startswith __pyx_string_tab[96] -#define __pyx_n_u_str __pyx_string_tab[97] -#define __pyx_n_u_struct __pyx_string_tab[98] -#define __pyx_n_u_test __pyx_string_tab[99] -#define __pyx_n_u_time __pyx_string_tab[100] -#define __pyx_n_u_timestamp __pyx_string_tab[101] -#define __pyx_n_u_timestamp_2 __pyx_string_tab[102] -#define __pyx_n_u_to_bytes __pyx_string_tab[103] -#define __pyx_n_u_value __pyx_string_tab[104] -#define __pyx_n_u_values __pyx_string_tab[105] -#define __pyx_kp_b_iso88591_6_avQ __pyx_string_tab[106] -#define __pyx_kp_b_iso88591_A_4z_1A_IQ __pyx_string_tab[107] -#define __pyx_kp_b_iso88591_A_A_N __pyx_string_tab[108] -#define __pyx_kp_b_iso88591_A_Ja __pyx_string_tab[109] -#define __pyx_kp_b_iso88591_A_Ja_N_1F_c_S_A_IQ_N_Ja_IQ __pyx_string_tab[110] -#define __pyx_kp_b_iso88591_A_Rt1_m1_z_AQ_q_1 __pyx_string_tab[111] -#define __pyx_kp_b_iso88591_A_WAT_Q_WA_1D_WAT_waq_WAT_G1A_WA __pyx_string_tab[112] -#define __pyx_kp_b_iso88591_A_q_xwm1_F __pyx_string_tab[113] -#define __pyx_kp_b_iso88591_A_t1 __pyx_string_tab[114] -#define __pyx_kp_b_iso88591_A_t1_2 __pyx_string_tab[115] -#define __pyx_kp_b_iso88591_A_t1_3 __pyx_string_tab[116] -#define __pyx_kp_b_iso88591_A_t1_4 __pyx_string_tab[117] -#define __pyx_kp_b_iso88591_A_t_7 __pyx_string_tab[118] -#define __pyx_kp_b_iso88591_A_t_Q __pyx_string_tab[119] -#define __pyx_kp_b_iso88591_A_xy_at1 __pyx_string_tab[120] -#define __pyx_kp_b_iso88591_ha_E_Qd_fBb_1A_F_QnAY_9_1_q __pyx_string_tab[121] +#define __pyx_kp_u_3f __pyx_string_tab[2] +#define __pyx_kp_u_Genesis_Block __pyx_string_tab[3] +#define __pyx_kp_u_Mined_block __pyx_string_tab[4] +#define __pyx_kp_u_No_string __pyx_string_tab[5] +#define __pyx_kp_u_Note_that_Cython_is_deliberately __pyx_string_tab[6] +#define __pyx_kp_u_UTF_8 __pyx_string_tab[7] +#define __pyx_kp_u__2 __pyx_string_tab[8] +#define __pyx_kp_u_add_note __pyx_string_tab[9] +#define __pyx_kp_u_d __pyx_string_tab[10] +#define __pyx_kp_u_datetime_datetime __pyx_string_tab[11] +#define __pyx_kp_u_in __pyx_string_tab[12] +#define __pyx_kp_u_s_with_nonce __pyx_string_tab[13] +#define __pyx_kp_u_src_polluck_blockchain_python_tr __pyx_string_tab[14] +#define __pyx_n_u_Block __pyx_string_tab[15] +#define __pyx_n_u_Block___init __pyx_string_tab[16] +#define __pyx_n_u_Block__perform_hash __pyx_string_tab[17] +#define __pyx_n_u_Block_compute_hash __pyx_string_tab[18] +#define __pyx_n_u_Block_compute_hash_bytes __pyx_string_tab[19] +#define __pyx_n_u_Block_data __pyx_string_tab[20] +#define __pyx_n_u_Block_hash __pyx_string_tab[21] +#define __pyx_n_u_Block_index __pyx_string_tab[22] +#define __pyx_n_u_Block_nonce __pyx_string_tab[23] +#define __pyx_n_u_Block_prev_hash __pyx_string_tab[24] +#define __pyx_n_u_Block_timestamp __pyx_string_tab[25] +#define __pyx_n_u_Blockchain __pyx_string_tab[26] +#define __pyx_n_u_Blockchain___init __pyx_string_tab[27] +#define __pyx_n_u_Blockchain_add_block __pyx_string_tab[28] +#define __pyx_n_u_Blockchain_create_genesis_block __pyx_string_tab[29] +#define __pyx_n_u_Blockchain_proof_of_work __pyx_string_tab[30] +#define __pyx_n_u_None __pyx_string_tab[31] +#define __pyx_n_u_Pyx_PyDict_NextRef __pyx_string_tab[32] +#define __pyx_n_u_add_block __pyx_string_tab[33] +#define __pyx_n_u_append __pyx_string_tab[34] +#define __pyx_n_u_asyncio_coroutines __pyx_string_tab[35] +#define __pyx_n_u_big __pyx_string_tab[36] +#define __pyx_n_u_block __pyx_string_tab[37] +#define __pyx_n_u_block_hash __pyx_string_tab[38] +#define __pyx_n_u_chain __pyx_string_tab[39] +#define __pyx_n_u_cline_in_traceback __pyx_string_tab[40] +#define __pyx_n_u_compute_hash __pyx_string_tab[41] +#define __pyx_n_u_compute_hash_bytes __pyx_string_tab[42] +#define __pyx_n_u_create_genesis_block __pyx_string_tab[43] +#define __pyx_n_u_data __pyx_string_tab[44] +#define __pyx_n_u_data_2 __pyx_string_tab[45] +#define __pyx_n_u_datetime __pyx_string_tab[46] +#define __pyx_n_u_difficulty __pyx_string_tab[47] +#define __pyx_n_u_digest __pyx_string_tab[48] +#define __pyx_n_u_doc __pyx_string_tab[49] +#define __pyx_n_u_dopt_basics __pyx_string_tab[50] +#define __pyx_n_u_dopt_basics_datetime __pyx_string_tab[51] +#define __pyx_n_u_elapsed __pyx_string_tab[52] +#define __pyx_n_u_encode __pyx_string_tab[53] +#define __pyx_n_u_extend __pyx_string_tab[54] +#define __pyx_n_u_float __pyx_string_tab[55] +#define __pyx_n_u_float_to_bytes __pyx_string_tab[56] +#define __pyx_n_u_fromtimestamp __pyx_string_tab[57] +#define __pyx_n_u_func __pyx_string_tab[58] +#define __pyx_n_u_genesis __pyx_string_tab[59] +#define __pyx_n_u_hash __pyx_string_tab[60] +#define __pyx_n_u_hash_2 __pyx_string_tab[61] +#define __pyx_n_u_hashlib __pyx_string_tab[62] +#define __pyx_n_u_hexdigest __pyx_string_tab[63] +#define __pyx_n_u_index __pyx_string_tab[64] +#define __pyx_n_u_index_2 __pyx_string_tab[65] +#define __pyx_n_u_init __pyx_string_tab[66] +#define __pyx_n_u_int __pyx_string_tab[67] +#define __pyx_n_u_is_coroutine __pyx_string_tab[68] +#define __pyx_n_u_items __pyx_string_tab[69] +#define __pyx_n_u_main __pyx_string_tab[70] +#define __pyx_n_u_metaclass __pyx_string_tab[71] +#define __pyx_n_u_module __pyx_string_tab[72] +#define __pyx_n_u_name __pyx_string_tab[73] +#define __pyx_n_u_new_block __pyx_string_tab[74] +#define __pyx_n_u_nonce __pyx_string_tab[75] +#define __pyx_n_u_nonce_2 __pyx_string_tab[76] +#define __pyx_n_u_num __pyx_string_tab[77] +#define __pyx_n_u_pack __pyx_string_tab[78] +#define __pyx_n_u_parts __pyx_string_tab[79] +#define __pyx_n_u_perf_counter __pyx_string_tab[80] +#define __pyx_n_u_perform_hash __pyx_string_tab[81] +#define __pyx_n_u_polluck_blockchain_python_transl __pyx_string_tab[82] +#define __pyx_n_u_pop __pyx_string_tab[83] +#define __pyx_n_u_prefix __pyx_string_tab[84] +#define __pyx_n_u_prepare __pyx_string_tab[85] +#define __pyx_n_u_prev_hash __pyx_string_tab[86] +#define __pyx_n_u_prev_hash_2 __pyx_string_tab[87] +#define __pyx_n_u_previous_hash __pyx_string_tab[88] +#define __pyx_n_u_print __pyx_string_tab[89] +#define __pyx_n_u_proof_of_work __pyx_string_tab[90] +#define __pyx_n_u_property __pyx_string_tab[91] +#define __pyx_n_u_qualname __pyx_string_tab[92] +#define __pyx_n_u_return __pyx_string_tab[93] +#define __pyx_n_u_self __pyx_string_tab[94] +#define __pyx_n_u_set_name __pyx_string_tab[95] +#define __pyx_n_u_setdefault __pyx_string_tab[96] +#define __pyx_n_u_setter __pyx_string_tab[97] +#define __pyx_n_u_sha256 __pyx_string_tab[98] +#define __pyx_n_u_slots __pyx_string_tab[99] +#define __pyx_n_u_start __pyx_string_tab[100] +#define __pyx_n_u_startswith __pyx_string_tab[101] +#define __pyx_n_u_str __pyx_string_tab[102] +#define __pyx_n_u_struct __pyx_string_tab[103] +#define __pyx_n_u_test __pyx_string_tab[104] +#define __pyx_n_u_time __pyx_string_tab[105] +#define __pyx_n_u_timestamp __pyx_string_tab[106] +#define __pyx_n_u_timestamp_2 __pyx_string_tab[107] +#define __pyx_n_u_to_bytes __pyx_string_tab[108] +#define __pyx_n_u_value __pyx_string_tab[109] +#define __pyx_n_u_values __pyx_string_tab[110] +#define __pyx_kp_b_iso88591_6_avQ __pyx_string_tab[111] +#define __pyx_kp_b_iso88591_A_4z_1A_IQ __pyx_string_tab[112] +#define __pyx_kp_b_iso88591_A_A_N __pyx_string_tab[113] +#define __pyx_kp_b_iso88591_A_Ja __pyx_string_tab[114] +#define __pyx_kp_b_iso88591_A_Ja_N_1F_c_S_A_IQ_N_Ja_IQ __pyx_string_tab[115] +#define __pyx_kp_b_iso88591_A_Rt1_m1_z_AQ_q_1 __pyx_string_tab[116] +#define __pyx_kp_b_iso88591_A_WAT_Q_WA_1D_WAT_waq_WAT_G1A_WA __pyx_string_tab[117] +#define __pyx_kp_b_iso88591_A_q_xwm1_F __pyx_string_tab[118] +#define __pyx_kp_b_iso88591_A_t1 __pyx_string_tab[119] +#define __pyx_kp_b_iso88591_A_t1_2 __pyx_string_tab[120] +#define __pyx_kp_b_iso88591_A_t1_3 __pyx_string_tab[121] +#define __pyx_kp_b_iso88591_A_t1_4 __pyx_string_tab[122] +#define __pyx_kp_b_iso88591_A_t_7 __pyx_string_tab[123] +#define __pyx_kp_b_iso88591_A_t_Q __pyx_string_tab[124] +#define __pyx_kp_b_iso88591_A_xy_at1 __pyx_string_tab[125] +#define __pyx_kp_b_iso88591_ha_E_Qd_fBb_M_1A_m3b_F_QnAYk_9K __pyx_string_tab[126] #define __pyx_int_0 __pyx_number_tab[0] #define __pyx_int_1 __pyx_number_tab[1] #define __pyx_int_8 __pyx_number_tab[2] @@ -2629,7 +2641,7 @@ static CYTHON_SMALL_CODE int __pyx_m_clear(PyObject *m) { #endif for (int i=0; i<4; ++i) { Py_CLEAR(clear_module_state->__pyx_tuple[i]); } for (int i=0; i<17; ++i) { Py_CLEAR(clear_module_state->__pyx_codeobj_tab[i]); } - for (int i=0; i<122; ++i) { Py_CLEAR(clear_module_state->__pyx_string_tab[i]); } + for (int i=0; i<127; ++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 */ @@ -2655,7 +2667,7 @@ static CYTHON_SMALL_CODE int __pyx_m_traverse(PyObject *m, visitproc visit, void __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_unicode); for (int i=0; i<4; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_tuple[i]); } for (int i=0; i<17; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_codeobj_tab[i]); } - for (int i=0; i<122; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_string_tab[i]); } + for (int i=0; i<127; ++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 */ @@ -5641,6 +5653,8 @@ PyObject *__pyx_args, PyObject *__pyx_kwds static PyObject *__pyx_pf_18polluck_blockchain_16python_translate_10Blockchain_6add_block(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_data) { PyObject *__pyx_v_new_block = NULL; + PyObject *__pyx_v_start = NULL; + PyObject *__pyx_v_elapsed = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -5652,7 +5666,7 @@ static PyObject *__pyx_pf_18polluck_blockchain_16python_translate_10Blockchain_6 PyObject *__pyx_t_7 = NULL; size_t __pyx_t_8; int __pyx_t_9; - PyObject *__pyx_t_10[4]; + PyObject *__pyx_t_10[6]; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -5730,78 +5744,158 @@ static PyObject *__pyx_pf_18polluck_blockchain_16python_translate_10Blockchain_6 __pyx_v_new_block = __pyx_t_1; __pyx_t_1 = 0; + /* "polluck_blockchain/python_translate.py":132 + * ) + * + * start = time.perf_counter() # <<<<<<<<<<<<<< + * new_block.hash = self.proof_of_work(new_block) + * elapsed = time.perf_counter() - start +*/ + __pyx_t_3 = NULL; + __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_time); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 132, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_perf_counter); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 132, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_8 = 1; + #if CYTHON_UNPACK_METHODS + if (unlikely(PyMethod_Check(__pyx_t_6))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6); + assert(__pyx_t_3); + PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(__pyx__function); + __Pyx_DECREF_SET(__pyx_t_6, __pyx__function); + __pyx_t_8 = 0; + } + #endif + { + PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; + __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 132, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + } + __pyx_v_start = __pyx_t_1; + __pyx_t_1 = 0; + /* "polluck_blockchain/python_translate.py":133 * - * # start = time.perf_counter() + * start = time.perf_counter() * new_block.hash = self.proof_of_work(new_block) # <<<<<<<<<<<<<< - * # elapsed = time.perf_counter() - start + * elapsed = time.perf_counter() - start * */ - __pyx_t_3 = __pyx_v_self; - __Pyx_INCREF(__pyx_t_3); + __pyx_t_6 = __pyx_v_self; + __Pyx_INCREF(__pyx_t_6); __pyx_t_8 = 0; { - PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_new_block}; + PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_new_block}; __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_proof_of_work, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } if (__Pyx_PyObject_SetAttrStr(__pyx_v_new_block, __pyx_mstate_global->__pyx_n_u_hash_2, __pyx_t_1) < (0)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + /* "polluck_blockchain/python_translate.py":134 + * start = time.perf_counter() + * new_block.hash = self.proof_of_work(new_block) + * elapsed = time.perf_counter() - start # <<<<<<<<<<<<<< + * + * self.chain.append(new_block) +*/ + __pyx_t_6 = NULL; + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_time); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 134, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_perf_counter); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 134, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_8 = 1; + #if CYTHON_UNPACK_METHODS + if (unlikely(PyMethod_Check(__pyx_t_7))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7); + assert(__pyx_t_6); + PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(__pyx__function); + __Pyx_DECREF_SET(__pyx_t_7, __pyx__function); + __pyx_t_8 = 0; + } + #endif + { + PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL}; + __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 134, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + } + __pyx_t_7 = PyNumber_Subtract(__pyx_t_1, __pyx_v_start); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 134, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_elapsed = __pyx_t_7; + __pyx_t_7 = 0; + /* "polluck_blockchain/python_translate.py":136 - * # elapsed = time.perf_counter() - start + * elapsed = time.perf_counter() - start * * self.chain.append(new_block) # <<<<<<<<<<<<<< - * # print(f"Mined block {new_block.index} in {elapsed:.3f}s with nonce={new_block.nonce}") - * print(f"Mined block {new_block.index} with nonce={new_block.nonce}") + * print(f"Mined block {new_block.index} in {elapsed:.3f}s with nonce={new_block.nonce}") + * */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_chain); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 136, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_9 = __Pyx_PyObject_Append(__pyx_t_1, __pyx_v_new_block); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 136, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_chain); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 136, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_9 = __Pyx_PyObject_Append(__pyx_t_7, __pyx_v_new_block); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 136, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - /* "polluck_blockchain/python_translate.py":138 + /* "polluck_blockchain/python_translate.py":137 + * * self.chain.append(new_block) - * # print(f"Mined block {new_block.index} in {elapsed:.3f}s with nonce={new_block.nonce}") - * print(f"Mined block {new_block.index} with nonce={new_block.nonce}") # <<<<<<<<<<<<<< + * print(f"Mined block {new_block.index} in {elapsed:.3f}s with nonce={new_block.nonce}") # <<<<<<<<<<<<<< * * return new_block */ - __pyx_t_3 = NULL; - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_new_block, __pyx_mstate_global->__pyx_n_u_index); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 138, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_6 = __Pyx_PyObject_FormatSimple(__pyx_t_7, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 138, __pyx_L1_error) + __pyx_t_1 = NULL; + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_new_block, __pyx_mstate_global->__pyx_n_u_index); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_new_block, __pyx_mstate_global->__pyx_n_u_nonce); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 138, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_4 = __Pyx_PyObject_FormatSimple(__pyx_t_7, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 138, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_10[0] = __pyx_mstate_global->__pyx_kp_u_Mined_block; - __pyx_t_10[1] = __pyx_t_6; - __pyx_t_10[2] = __pyx_mstate_global->__pyx_kp_u_with_nonce; - __pyx_t_10[3] = __pyx_t_4; - __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_10, 4, 12 * 2 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6) + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4), 127 | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4)); - if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 138, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); + __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_t_6, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 137, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_PyObject_Format(__pyx_v_elapsed, __pyx_mstate_global->__pyx_kp_u_3f); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 137, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_new_block, __pyx_mstate_global->__pyx_n_u_nonce); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 137, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_t_4, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_10[0] = __pyx_mstate_global->__pyx_kp_u_Mined_block; + __pyx_t_10[1] = __pyx_t_3; + __pyx_t_10[2] = __pyx_mstate_global->__pyx_kp_u_in; + __pyx_t_10[3] = __pyx_t_6; + __pyx_t_10[4] = __pyx_mstate_global->__pyx_kp_u_s_with_nonce; + __pyx_t_10[5] = __pyx_t_2; + __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_10, 6, 12 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3) + 4 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6) + 13 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2), 127 | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2)); + if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 137, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_8 = 1; { - PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_7}; - __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_builtin_print, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__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_1)) __PYX_ERR(0, 138, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); + PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_t_4}; + __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_builtin_print, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 137, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - /* "polluck_blockchain/python_translate.py":140 - * print(f"Mined block {new_block.index} with nonce={new_block.nonce}") + /* "polluck_blockchain/python_translate.py":139 + * print(f"Mined block {new_block.index} in {elapsed:.3f}s with nonce={new_block.nonce}") * * return new_block # <<<<<<<<<<<<<< */ @@ -5830,6 +5924,8 @@ static PyObject *__pyx_pf_18polluck_blockchain_16python_translate_10Blockchain_6 __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_new_block); + __Pyx_XDECREF(__pyx_v_start); + __Pyx_XDECREF(__pyx_v_elapsed); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; @@ -6792,7 +6888,7 @@ __Pyx_RefNannySetupContext("PyInit_python_translate", 0); static int __Pyx_InitCachedBuiltins(__pyx_mstatetype *__pyx_mstate) { CYTHON_UNUSED_VAR(__pyx_mstate); __pyx_builtin_property = __Pyx_GetBuiltinName(__pyx_mstate->__pyx_n_u_property); if (!__pyx_builtin_property) __PYX_ERR(0, 59, __pyx_L1_error) - __pyx_builtin_print = __Pyx_GetBuiltinName(__pyx_mstate->__pyx_n_u_print); if (!__pyx_builtin_print) __PYX_ERR(0, 138, __pyx_L1_error) + __pyx_builtin_print = __Pyx_GetBuiltinName(__pyx_mstate->__pyx_n_u_print); if (!__pyx_builtin_print) __PYX_ERR(0, 137, __pyx_L1_error) /* Cached unbound methods */ __pyx_mstate->__pyx_umethod_PyDict_Type_items.type = (PyObject*)&PyDict_Type; @@ -6880,34 +6976,34 @@ static int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate) { static int __Pyx_InitConstants(__pyx_mstatetype *__pyx_mstate) { CYTHON_UNUSED_VAR(__pyx_mstate); { - const struct { const unsigned int length: 8; } index[] = {{0},{1},{13},{12},{9},{179},{5},{1},{8},{2},{17},{42},{12},{5},{14},{19},{18},{24},{10},{10},{11},{11},{15},{15},{10},{19},{20},{31},{24},{4},{20},{9},{6},{18},{3},{5},{10},{5},{18},{12},{18},{20},{4},{5},{8},{10},{6},{7},{11},{20},{6},{6},{5},{14},{13},{8},{7},{5},{4},{7},{9},{5},{6},{8},{3},{13},{5},{8},{13},{10},{8},{9},{5},{6},{3},{4},{5},{13},{35},{3},{6},{11},{10},{9},{13},{5},{13},{8},{12},{6},{4},{12},{10},{6},{6},{9},{10},{3},{6},{8},{4},{9},{10},{8},{5},{6},{18},{36},{25},{12},{76},{54},{107},{51},{12},{12},{12},{9},{15},{15},{20},{101}}; - #if (CYTHON_COMPRESS_STRINGS) == 2 /* compression: bz2 (1120 bytes) */ -const char* const cstring = "BZh91AY&SY3\223e\276\000\000\201\177\377\365\177\367\375\177\363\367\363\277\263~\241\277\377\377\360@@@@@@@@@@@@@\000@\000P\003\375\331PtQ$\273\235\303T\332\024\320\217!\2420OB\017S@\003L\2004\0324h\320\321\241\240\r\036\246\230\2156PJ\232M\030\010\324\322mI\246\324\323\322\000\032\000\001\240\000\000\000\000\000\001\240\224\321\010\002F\r\024\217\325<\246\365OPh\320\320\320\320\000z\200\000\000\001\246\214\2327\252a\246\251\004\032\030\203\020h\300\203!\204\001\21012\014&\201\202i\221\211\202yF\207\000\000\003@\000\006F\206@\000\000\000\00022\000\000\310^\301n\364\277\204+\372\303\030Q\0062\010(J\002\n\002\010\004\246XU`\311\240-(\rd3\022CD\353\036\0064j\210\326\322\035fl\307\007,\300\272\201R\220A\txD\370\306\021\2103\0052\203\365L\016J<\030\3121b\327\333s\354\267\267\351\352\366\202m\331C\365S\372t\013\213\256rUUp\031`b\033\010\300\214CN)$!\303\343\267@\341 \317\246M\360\257\016\034\230i#'yI\302\035?]\373W\340\231a\235\263\303\230\365\376.~\037\007\302\366\357\237^\256&\234JQ\231\263\021\301\264K'h\324X\360\022\257?{\270\350\364\\{v\032\216\341\320\323#B\346A\010+\343\315\2547*\331\264\274\231\232\361\014M\010\3260\312X\330TN\325A.\023\204\267\246\n[^\366I\202+\335n}\357\010l\26324Ga\236\335\324\344\215\351a\273d\332cJr\022\341\034Tu\247\266\251%lX__,\177]\363ad\215\324\035Z'\271\0100\256\034\035\367P\222\200w\254$\251\203a\376c\247\263\241\302\016M\357\215\227\030l\337\211d26\327Fm@<\316D7\030\202&#[\263\262\002B\205G\336t\271\310g\301\314c\225\331\024\032\245ND\230\367-\311g\331\221\255\"\250\270.\2734Y\336\210L/\311U\256\235\254\221{\024V\2013\230@R\376\220\264\264\346\246_\250\276C\227\2409N\r\027o\237\204\322\330\326f\245Z\315\243|6r5!X\210\344zt%\"\002JF\232\026Jo:(\241\216!Uu8.\350\273\222)\302\204\201\234\233-\360"; - PyObject *data = __Pyx_DecompressString(cstring, 1120, 2); + const struct { const unsigned int length: 8; } index[] = {{0},{1},{3},{13},{12},{9},{179},{5},{1},{8},{2},{17},{4},{13},{42},{5},{14},{19},{18},{24},{10},{10},{11},{11},{15},{15},{10},{19},{20},{31},{24},{4},{20},{9},{6},{18},{3},{5},{10},{5},{18},{12},{18},{20},{4},{5},{8},{10},{6},{7},{11},{20},{7},{6},{6},{5},{14},{13},{8},{7},{5},{4},{7},{9},{5},{6},{8},{3},{13},{5},{8},{13},{10},{8},{9},{5},{6},{3},{4},{5},{12},{13},{35},{3},{6},{11},{10},{9},{13},{5},{13},{8},{12},{6},{4},{12},{10},{6},{6},{9},{5},{10},{3},{6},{8},{4},{9},{10},{8},{5},{6},{18},{36},{25},{12},{76},{54},{107},{51},{12},{12},{12},{9},{15},{15},{20},{128}}; + #if (CYTHON_COMPRESS_STRINGS) == 2 /* compression: bz2 (1150 bytes) */ +const char* const cstring = "BZh91AY&SY\357?\217\017\000\000\205\177\377\365\177\367\375~\363\377\363\277\273\177\241\277\377\377\360@@@@@@@@@@@@@\000@\000P\004\033l5\022\000\245\2105\004I\247\244\031= \364\321\003#L\200\r6\240\365\003C\3244\036\243@=A\221\352=\rA\352~\224\022\204& \0021L\204\332\246\324\3204\0004\032\000\000\000\000\000\036\243A\2104\321\004\320\325Oh$\3654=4\214C@\032\000\000\r\000\006\201\240\001\265\032d\303P\343C@\032\000\032\000\000\000\r\000\000\000\000\310\000\000b\001\306\206\2004\0004\000\000\000\032\000\000\000\001\220\000\000\304\007l\370\323WY66\237\257\215\223\031\004\202\n\000A@A\010JR\355\221j\300l\200\022n\020\032\022\031\302\031ms\263I\300p\267%\307e\251U\260\200P+\206\016\222\014e\nP\261\206\034\204\361\002\227\005\0071\"\t\244U\313V\336\244\353\314\327\261\027UH\217\272\234h\251\215\206p\326\243p\313\030\265X.\r\351\031\004*\215\013\352\360_\224\272\234\345\016qZ8:zS\355\333\335\333$\214\205Vz\200\314WQu\253\231C;i\216\3070\305\206\036]\034~/\"\2775\372\rtZ\022(&\343\370\271\235\0279.\224\322\256S\203f\301>Nx\277]\002\005\213Ts\333\231\211@\337`i \223\315(%\304\300\307\023&\273\334?\237r\330I\364P\351nv\253\362\321\020\352\262\3527k\224\356\307O\232\264\250\035\245\333\"\223\0278+Z\200\023$\264\351\026r^\200]1\274\004\005\214!\261\026%G\335\024K\227\305\360\260+I\2048x\326\233;W\021\"\210\227\216zb\375\031\035\260\2338\037,x\371\016\237M\206\247Si\3317\354y\222\365\024\034\241#\013\263\016E\222&\306z\"V(\204\024S1\347\031Dir\255\226\245+p\276\033MsF\214\346\317\255\225?\013o\334\246\220\016\377-\325Xh\334\334\303VTY\263\t\236\r\323\321\341\034\367\002v\332\312\"\306\366\271\213\214 \351\n\327-\261e$\344\344\301\004S V\242\010\021Y\200\253\202\001\305\200U\220=h\251+\354[\263\243\362\3317\204\016nv\272\252\013x\271\356&\344St\250D\314\006\201\314\242b(:\002\23222(-7\216:,\276\351)\266h\034\213\300\n\326\326u}\2067\327\000\\\037\322\256\372\324\212\355L\373\322X\272\224D\251@\027\250""\347$\214\\f\376#d\315\275\010\202\212\250\240\242\2517\356\244\314qU\206\024\017E\023\325Ud\212\326\021]\373\307\2720Q\006H\3239\274;\232#%dW\261\232\216\010\262\020~\376\352\032\255\324\021\251g\340jp{\027\033\325\020M{\213\360-9H\005\333\322\254\002\307\245\025\234\207\03121[s}4\227\006;p\267v\0065\030\376\223\322\022\216\253\024l\353\214K\020\205+\244\371x\313\n\221n\253#+\361ZT\"\222\032\340\335\253\221\304!J3Lf\251\251Z\225\330B\200\252\005\031\325\244\312m)\225bh\250\203\004HC\370\200@G\275\242/\320\241\235\005'>v\205eVbp\212\022\340\226\330\261\"\300\r\022YQNJZX!\033\001\310\325\006\2314L\256\264\246\312\212/\265\222!\013\347\202T+N:\t\237V^}D\211\251\303\245}\267n\247E\304\024\304+\315\257\\\237\221\2248Q\252\311B\0065tf*\255E\3205`!9\014_S\220W\\\252\222\033\3344Q\007\274#\275!\007t\351\372\t\031(p\021\220Y \220\020y\206\365\203\245?\321\007\335\202\210\364\336\357\263QjA\336!\017\247B_5\210\231eo\002\323p\030\346~[\023\332\252\274\271KZ^ey\201\212\253\266-\207\341j\210\366\251\200i1\371\033\352\206\205m\301D~\344\016\313\351\312\211\004\203LY\273\355b5\t\334\363\321\370\204^\362\227\177%\230\022h\263UBZ'A\343z>\330\365yT\274\023(\250\244\367\253\254T\rq\031\204B\271\310h\220\"_F6\203*\037\370\273\222)\302\204\207y\374xx"; + PyObject *data = __Pyx_DecompressString(cstring, 1150, 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 (1028 bytes) */ -const char* const cstring = "x\332uTAo\3336\024N\207b\260W\267\211\215\264\311\222a`\326nY\006\324\235\207\254\353\006\254\203\2636E\007,\210\273\016\303.%h\211\212\271H\244\"R\261\265\323\216>\362\310\243\216:\346\230c\216;\346\250\243\177B\177\302\036\251\330N\226\326\260\237\037\037\037\371\276\357{O\372\372\005\345T2\211vB\341\035\376\3128\365Q\337\272hO \251\022\306\017\366\204\242H\r\210B?gj 8\202l\237\206\254O\023\242h\230\2714O\321\304&q\264\377|\377\341\366\223mD\270\217\022\372\027\365\224D2\355{!\221\222J$\002\324OY\250\030G*\213\251l\243\227\001\312D\2128\205\322J\240\030\362.\037P\003\312\221\244\312:h\223p.\024QLp\014\307\001\335&\362Y\002E\3301\265\247wI(i\373\367\327\273\017\237\374D|\037C6}\352\373\000T\261\210\266\247\216L\274G\261\010\303\324;\304\216\2567 \214?\212\035A\254\022\302e\010\251\3558CC\246\006\210\013\356\321\037\235F\316\2641f\234)\214/V1M\002\221Dx@\344\240\ny\"\212SE\337\023\301\375LQY\305\001\023\251\274y.\343>\035U\256+]\271qB\217/]\350\210(\022\305;3\006s\357*\302*d\005\351\3178T1/\241@\024\037Tcpm;N\204\0100|\207\"9\334\023\234b\274\237\215\340\367\014Z\216\367\350H\275\242\301\354^\022\307\224\373Df\334c\002\010'\"\205FS\331g\007n\337\031\307\300\335\356\205\260\t0\255\340\036\355\023(zI\243\353z\275\013\253U\017[3m\255\317\202\200yi\2502\237\035\200>\030\373\302\263&V\270O$\363\344%w6\020\224{\302\247@\007\360\007\241 \312\031\254DU9HD4\223\033\343 \345p\345\024\207\0058\375\301c1\240\243\252\262k\"\256\354E3\030W\030N\314\224a\212F\022\343\010\304\300\360\211\250\"n\356\335B\370iH\255\307I\004\377\234\016+\312n\"\260\263<\215b\220-&\211\222W\206\360\372p\267\377?\334\261\210a\240\002\006\340\340\037\256\260\265f#v\305a\"\225\027\013`pe&`\001uU\206\361QJ\302\niBU\232pI\303\000cxr/\360\203\347\303\254@g\300\203\327\205\034\220o\276}\014\361P\000x\014\322\002\t\373\264\301\373\004\276)\314\027V\256\201V\371\271\3723o\332\234c\022\246\324\031y\276\260jn\2247o\215\037\353\273\232\350c\323\373\247[\256}\226o\224\265[\343\355\361\337\246i6\363f\331h\351-\3231""\335\262\326\030\277\324\2203\251-\353nY\377\010\002\347\rH\237\300\306\236\331\200\303\353\237\330\244_4\201\244\305\245\362\316b\271\262Z..M\252`\351\362\276\314\267\212N\261{\362\340\304;]>\375\355\354\203\263\257\376\355N\252\273\253\214\215r\236_\025\204\273l\271\246^\326\257\2642\235\262V/\033\037\233\273&*:ec\021\240\256\347\335\274W.\255\350\243\262\321\324k\246\003hjK\272n\232e\355\366\370\017\335\325\257\315J^/\232\305\375\2427\r\275\311;\371\263\342\306<\343\236\031\346$?\232\007\326\363\027\000\266\373\216;&\265\305\361P\037\230\236!\266TK\177nK\267\364\206\255\017\242\255\001\r\273\264y#=tH\201\317\256\336\004Y\255V\240\014l)m\221\336[\231\373V\303\013\1772\013:\347i\336\312\277+6./\177(z\263##\235\345w\nR\250\223\316\371\315O\315 \007\001\227\365s\343:x_\367\264o\346\340\036\230 \337\311\373@\336\202|[[\250\267\364\252Y6o,\335\267\037.\324oO\241N\200{o\314M\327\374y\376\305\367\247\315\323\255\263\216\005v\364\037\302\362\302\362"; - PyObject *data = __Pyx_DecompressString(cstring, 1028, 1); + #elif (CYTHON_COMPRESS_STRINGS) != 0 /* compression: zlib (1064 bytes) */ +const char* const cstring = "x\332uT1o\0337\024N\n\243\220\0335\266\014'v\355\242\240\033\027n\nD\251\0327M\0134\205\334\304\201[D\260\322\244E\227\020\324\035\317b}G\236\217J\350_\324S\022\311\264\347\205DJ*\221\010P/e\241b\034\251,\246\262\211\366\002\224\211\024q\n\245\225@1\344]<\240\372\224#I\225u\320\026\341\\(\242\230\340\030\216\003\272-\344\263\004\212\260cjO\357\222P\322\346\253\227\273\367\036\375D|\037C6}\354\373\000T\261\2106'\016\202\362\022\r\230\352#.\270G\177\224\211w?\026a\230z\207\330\361\367\372\204\361\373\261c\214UB\270\014\341l3\316\234P\31641f\234)\214\317W1M\002\221D\270Od\277\ny\"\212SE\377'\202{\231\242\262\212\0030Ry\263\\\306}:\254\\\007\262r\343\204\036_\270\320\262\221\212D\361\316\024\365\314\273\214\260\nYUzS\016U\314K(\220\303\007\325,\\\331\216\023!\002\014\237\201H\016;\202S\214\367\263!|\237@\337q\207\016\325\013\032L\357%qL\271Od\306=&\200p\"R\3506\225=v\340\366\235q\014\334\355^\010\233\000\323\212\354\321\036\201\242\0274\272\252\327\373\260Z\365\2605\223\376\372,\010\230\227\206*\363\331\001\350\203\261/JIX\241N\250J\023.i\030`\014/\372\234\013x>\214\0174\013<\300+\373\344\233o\037B<\024\n\310\203\314@\310\031\373^\341\237\r|R\230;\254\\cm+f\355\230z\223n\035\2230\245\316\310\263k\253\346z9wc\364P\337\322D\037\233\356?\355r""\355\363|\243\254\335\030m\217\3766\r\263\2257\312\372\222\276kZ\246]\326\352\243=\r9\343\332\262n\227\363\037A\340\254\016\351c\330\350\230\r8\274\376\251M\372E\023HZX,o.\224+\253\345\302\342\270\n\226.\357\313\374n\321*vO6O\2747\313o~{\373\301\333\257N\333\343\352\356*c\243\234\345W\005\341.[\256\241\227\365\013\255L\253\254\315\227\365O\314-\023\025\255\262\276\000P\327\363v\336-\027W\364QYo\3505\323\0024\265E=o\032e\355\343\321\037\272\255_\232\225|\276h\024w\212\356$\364:o\345O\212\353\263\214\333f\220\223\374h\026X\317\237\001\330\366{\356\030\327\026F\003}`\272\206\330RK\372\013[zIo\330\372 \332\032\320\260K\2337\324\003\207\024\370\354\352-\220\325j\005\312\300\226\322\026\351\355\225\231o5<\367\307\323\240s\036\347K\371w\305\306\305\345\017Ewzd\250\263\374fA\nu\322:\233\373\314\364s\020pY?5\256\203wtW\373f\006n\323\004\371N\336\003\362\026\344\277\037^\233o\3509\375\034\332\r*\257\232e\363\272\342\275\2447u\224?\260\231\343\031|\253Gw\304M\333\374\231\037\2364N\266\316\276\377\365\264u\272w\366\352w\213\371\350?\r@\333\036"; + PyObject *data = __Pyx_DecompressString(cstring, 1064, 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 (1806 bytes) */ -const char* const bytes = "0Genesis BlockMined block No stringNote that Cython is deliberately stricter than PEP-484 and rejects subclasses of builtin types. If you need to pass subclasses then set the 'annotation_typing' directive to False.UTF-8?add_note>ddatetime.datetimesrc/polluck_blockchain/python_translate.py with nonce=BlockBlock.__init__Block._perform_hashBlock.compute_hashBlock.compute_hash_bytesBlock.dataBlock.hashBlock.indexBlock.nonceBlock.prev_hashBlock.timestampBlockchainBlockchain.__init__Blockchain.add_blockBlockchain.create_genesis_blockBlockchain.proof_of_workNone__Pyx_PyDict_NextRefadd_blockappendasyncio.coroutinesbigblockblock_hashchaincline_in_tracebackcompute_hashcompute_hash_bytescreate_genesis_blockdata_datadatetimedifficultydigest__doc__dopt_basicsdopt_basics.datetimeencodeextendfloatfloat_to_bytesfromtimestamp__func__genesis_hashhashhashlibhexdigestindex_index__init__int_is_coroutineitems__main____metaclass____module____name__new_blocknonce_noncenumpackparts_perform_hashpolluck_blockchain.python_translatepopprefix__prepare___prev_hashprev_hashprevious_hashprintproof_of_workproperty__qualname__returnself__set_name__setdefaultsettersha256__slots__startswithstrstruct__test__timetimestamp_timestampto_bytesvaluevalues\320\000\030\230\001\330\004\013\2106\220\025\220a\220v\230Q\200A\330\032\"\240!\330\010\013\2104\210z\230\021\230'\240\021\330\014\022\220)\2301\230A\330\010\014\210I\220Q\200A\340\010\024\220A\330\t\n\330\010\014\320\014\"\240!\340\010\014\210N\230!\200A\330\033\034\330\010\014\210J\220a\200A\340\017\020\330\016\017\330\027\030\330\017\020\340\010\014\210J\220a\330\010\014\210N\230(\240)\2501\250F\260$\260c\270\024\270S\300\002\300*\310A\340\010\014\210I\220Q\330\010\014\210N\230!\330\010\014\210J\220a\330\010\014\210I\220Q\200A\340\017\020\330\t\n\330\010\021\220\024\220R\220t\2301\330\010\t\330\014\031\230\025\230m\2501\330\014\017\210z\230\033\240A\240Q\330\020\027\220q\330\014\021\220\032\2301\200A\330\010\020\220\t\230\021\330\010\r\210W\220A\220T\230""\027\240\t\250\021\250#\250Q\330\010\r\210W\220A\220^\2401\240D\250\001\330\010\r\210W\220A\220T\230\026\230w\240a\240q\330\010\r\210W\220A\220T\230\033\240G\2501\250A\330\010\r\210W\220A\220T\230\027\240\t\250\021\250#\250Q\340\010\017\210w\220g\230Q\230a\200A\330\010\022\220%\220q\330\014\022\220!\330\014\021\220\021\330\014\032\230!\330\014\022\220!\340\010\017\210x\220w\230m\2501\330\010\014\210F\220'\230\021\230!\200A\330\027\030\330\010\017\210t\2201\200A\330\026\027\330\010\017\210t\2201\200A\330\033\034\330\010\017\210t\2201\200A\340\010\017\210t\2201\200A\330\010\017\210t\220>\240\022\2407\250!\200A\330\010\017\210t\220>\240\022\240:\250Q\200A\330\033\034\330\010\017\210x\220y\240\016\250a\250t\2601\320\004\036\230h\240a\330\010\024\220E\230\021\330\014\022\220#\220Q\220d\230!\330\014\021\220\021\330\014\032\230$\230f\240B\240b\250\001\330\014\022\220!\360\010\000\t\022\220\030\230\024\230^\2501\250A\360\006\000\t\r\210F\220'\230\021\230!\340\010\r\210Q\210n\230A\230Y\320&9\270\021\270)\3001\340\010\017\210q"; + #else /* compression: none (1865 bytes) */ +const char* const bytes = "0.3fGenesis BlockMined block No stringNote that Cython is deliberately stricter than PEP-484 and rejects subclasses of builtin types. If you need to pass subclasses then set the 'annotation_typing' directive to False.UTF-8?add_note>ddatetime.datetime in s with nonce=src/polluck_blockchain/python_translate.pyBlockBlock.__init__Block._perform_hashBlock.compute_hashBlock.compute_hash_bytesBlock.dataBlock.hashBlock.indexBlock.nonceBlock.prev_hashBlock.timestampBlockchainBlockchain.__init__Blockchain.add_blockBlockchain.create_genesis_blockBlockchain.proof_of_workNone__Pyx_PyDict_NextRefadd_blockappendasyncio.coroutinesbigblockblock_hashchaincline_in_tracebackcompute_hashcompute_hash_bytescreate_genesis_blockdata_datadatetimedifficultydigest__doc__dopt_basicsdopt_basics.datetimeelapsedencodeextendfloatfloat_to_bytesfromtimestamp__func__genesis_hashhashhashlibhexdigestindex_index__init__int_is_coroutineitems__main____metaclass____module____name__new_blocknonce_noncenumpackpartsperf_counter_perform_hashpolluck_blockchain.python_translatepopprefix__prepare___prev_hashprev_hashprevious_hashprintproof_of_workproperty__qualname__returnself__set_name__setdefaultsettersha256__slots__startstartswithstrstruct__test__timetimestamp_timestampto_bytesvaluevalues\320\000\030\230\001\330\004\013\2106\220\025\220a\220v\230Q\200A\330\032\"\240!\330\010\013\2104\210z\230\021\230'\240\021\330\014\022\220)\2301\230A\330\010\014\210I\220Q\200A\340\010\024\220A\330\t\n\330\010\014\320\014\"\240!\340\010\014\210N\230!\200A\330\033\034\330\010\014\210J\220a\200A\340\017\020\330\016\017\330\027\030\330\017\020\340\010\014\210J\220a\330\010\014\210N\230(\240)\2501\250F\260$\260c\270\024\270S\300\002\300*\310A\340\010\014\210I\220Q\330\010\014\210N\230!\330\010\014\210J\220a\330\010\014\210I\220Q\200A\340\017\020\330\t\n\330\010\021\220\024\220R\220t\2301\330\010\t\330\014\031\230\025\230m\2501\330\014\017\210z\230\033\240A\240Q\330\020\027\220q\330\014\021\220\032\2301\200A\330\010\020\220\t\230""\021\330\010\r\210W\220A\220T\230\027\240\t\250\021\250#\250Q\330\010\r\210W\220A\220^\2401\240D\250\001\330\010\r\210W\220A\220T\230\026\230w\240a\240q\330\010\r\210W\220A\220T\230\033\240G\2501\250A\330\010\r\210W\220A\220T\230\027\240\t\250\021\250#\250Q\340\010\017\210w\220g\230Q\230a\200A\330\010\022\220%\220q\330\014\022\220!\330\014\021\220\021\330\014\032\230!\330\014\022\220!\340\010\017\210x\220w\230m\2501\330\010\014\210F\220'\230\021\230!\200A\330\027\030\330\010\017\210t\2201\200A\330\026\027\330\010\017\210t\2201\200A\330\033\034\330\010\017\210t\2201\200A\340\010\017\210t\2201\200A\330\010\017\210t\220>\240\022\2407\250!\200A\330\010\017\210t\220>\240\022\240:\250Q\200A\330\033\034\330\010\017\210x\220y\240\016\250a\250t\2601\320\004\036\230h\240a\330\010\024\220E\230\021\330\014\022\220#\220Q\220d\230!\330\014\021\220\021\330\014\032\230$\230f\240B\240b\250\001\330\014\022\220!\360\006\000\t\021\220\004\220M\240\021\330\010\021\220\030\230\024\230^\2501\250A\330\010\022\220$\220m\2403\240b\250\001\340\010\014\210F\220'\230\021\230!\330\010\r\210Q\210n\230A\230Y\240k\260\021\260'\3209K\3101\310I\320UV\340\010\017\210q"; 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 < 106; i++) { + for (int i = 0; i < 111; i++) { Py_ssize_t bytes_length = index[i].length; PyObject *string = PyUnicode_DecodeUTF8(bytes + pos, bytes_length, NULL); - if (likely(string) && i >= 13) PyUnicode_InternInPlace(&string); + if (likely(string) && i >= 15) PyUnicode_InternInPlace(&string); if (unlikely(!string)) { Py_XDECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) @@ -6915,7 +7011,7 @@ const char* const bytes = "0Genesis BlockMined block No stringNote that Cython i stringtab[i] = string; pos += bytes_length; } - for (int i = 106; i < 122; i++) { + for (int i = 111; i < 127; i++) { Py_ssize_t bytes_length = index[i].length; PyObject *string = PyBytes_FromStringAndSize(bytes + pos, bytes_length); stringtab[i] = string; @@ -6926,14 +7022,14 @@ const char* const bytes = "0Genesis BlockMined block No stringNote that Cython i } } Py_XDECREF(data); - for (Py_ssize_t i = 0; i < 122; i++) { + for (Py_ssize_t i = 0; i < 127; i++) { if (unlikely(PyObject_Hash(stringtab[i]) == -1)) { __PYX_ERR(0, 1, __pyx_L1_error) } } #if CYTHON_IMMORTAL_CONSTANTS { - PyObject **table = stringtab + 106; + PyObject **table = stringtab + 111; for (Py_ssize_t i=0; i<16; ++i) { #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL); @@ -7073,9 +7169,9 @@ static int __Pyx_CreateCodeObjects(__pyx_mstatetype *__pyx_mstate) { __pyx_mstate_global->__pyx_codeobj_tab[15] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_src_polluck_blockchain_python_tr, __pyx_mstate->__pyx_n_u_proof_of_work, __pyx_mstate->__pyx_kp_b_iso88591_A_Rt1_m1_z_AQ_q_1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[15])) goto bad; } { - const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 3, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 124}; - PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_data, __pyx_mstate->__pyx_n_u_new_block}; - __pyx_mstate_global->__pyx_codeobj_tab[16] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_src_polluck_blockchain_python_tr, __pyx_mstate->__pyx_n_u_add_block, __pyx_mstate->__pyx_kp_b_iso88591_ha_E_Qd_fBb_1A_F_QnAY_9_1_q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[16])) goto bad; + const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 5, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 124}; + PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_data, __pyx_mstate->__pyx_n_u_new_block, __pyx_mstate->__pyx_n_u_start, __pyx_mstate->__pyx_n_u_elapsed}; + __pyx_mstate_global->__pyx_codeobj_tab[16] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_src_polluck_blockchain_python_tr, __pyx_mstate->__pyx_n_u_add_block, __pyx_mstate->__pyx_kp_b_iso88591_ha_E_Qd_fBb_M_1A_m3b_F_QnAYk_9K, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[16])) goto bad; } Py_DECREF(tuple_dedup_map); return 0; @@ -9049,6 +9145,34 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, return __Pyx_GetItemInt_Generic(o, PyLong_FromSsize_t(i)); } +/* PyObjectFormat */ +#if CYTHON_USE_UNICODE_WRITER +static PyObject* __Pyx_PyObject_Format(PyObject* obj, PyObject* format_spec) { + int ret; + _PyUnicodeWriter writer; + if (likely(PyFloat_CheckExact(obj))) { + _PyUnicodeWriter_Init(&writer); + ret = _PyFloat_FormatAdvancedWriter( + &writer, + obj, + format_spec, 0, PyUnicode_GET_LENGTH(format_spec)); + } else if (likely(PyLong_CheckExact(obj))) { + _PyUnicodeWriter_Init(&writer); + ret = _PyLong_FormatAdvancedWriter( + &writer, + obj, + format_spec, 0, PyUnicode_GET_LENGTH(format_spec)); + } else { + return PyObject_Format(obj, format_spec); + } + if (unlikely(ret == -1)) { + _PyUnicodeWriter_Dealloc(&writer); + return NULL; + } + return _PyUnicodeWriter_Finish(&writer); +} +#endif + /* JoinPyUnicode */ static PyObject* __Pyx_PyUnicode_Join(PyObject** values, Py_ssize_t value_count, Py_ssize_t result_ulength, Py_UCS4 max_char) { diff --git a/src/polluck_blockchain/python_translate.py b/src/polluck_blockchain/python_translate.py index c53d1cb..6d15a0e 100644 --- a/src/polluck_blockchain/python_translate.py +++ b/src/polluck_blockchain/python_translate.py @@ -129,12 +129,11 @@ class Blockchain: nonce=0, ) - # start = time.perf_counter() + start = time.perf_counter() new_block.hash = self.proof_of_work(new_block) - # elapsed = time.perf_counter() - start + elapsed = time.perf_counter() - start self.chain.append(new_block) - # print(f"Mined block {new_block.index} in {elapsed:.3f}s with nonce={new_block.nonce}") - print(f"Mined block {new_block.index} with nonce={new_block.nonce}") + print(f"Mined block {new_block.index} in {elapsed:.3f}s with nonce={new_block.nonce}") return new_block