From 282e4e027161ba0f31943a6a569472bdb17052b5 Mon Sep 17 00:00:00 2001 From: "alexey.stratulat" <alexey.stratulat@demlabs.net> Date: Mon, 11 Nov 2019 22:09:37 +0700 Subject: [PATCH] [+] Added wrapping for functions dap_chain_ledger_tx_cache_check and dap_chain_node_datum_tx_cache_check. --- include/wrapping_dap_chain_ledger.h | 2 ++ src/wrapping_dap_chain_ledger.c | 36 +++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/include/wrapping_dap_chain_ledger.h b/include/wrapping_dap_chain_ledger.h index da9de64e..616fbc79 100644 --- a/include/wrapping_dap_chain_ledger.h +++ b/include/wrapping_dap_chain_ledger.h @@ -3,6 +3,8 @@ #include "wrapping_dap_chain_common_objects.h" #include "wrapping_dap_chain_datum_tx.h" #include "wrapping_dap_chain_datum_token.h" +#include "libdap-python.h" + #ifdef __cplusplus extern "C" { diff --git a/src/wrapping_dap_chain_ledger.c b/src/wrapping_dap_chain_ledger.c index 2cba8128..76248e83 100644 --- a/src/wrapping_dap_chain_ledger.c +++ b/src/wrapping_dap_chain_ledger.c @@ -95,10 +95,42 @@ PyObject *dap_chain_ledger_addr_get_token_ticker_all_fast_py(PyObject *self, PyO return PyLong_FromLong(0); } PyObject *dap_chain_ledger_tx_cache_check_py(PyObject *self, PyObject *args){ - return NULL; + PyObject *obj_datum_tx; + PyObject *list_bound_items; + PyObject *list_tx_out; + if (!PyArg_ParseTuple(args, "O|O|O", &obj_datum_tx, &list_bound_items, &list_tx_out)) + return NULL; + Py_ssize_t size_list_bound_item = PyList_Size(list_bound_items); + dap_list_t **bound_items = calloc(sizeof(dap_list_t**), (size_t)size_list_bound_item); + for (Py_ssize_t i = 0; i < size_list_bound_item;i++){ + PyObject *obj = PyList_GetItem(list_bound_items, i); + dap_list_t *l = pyListToDapList(obj); + bound_items[i] = l; + } + Py_ssize_t size_tx_out = PyList_Size(list_tx_out); + dap_list_t **tx_out = calloc(sizeof(dap_list_t**), (size_t)size_tx_out); + for (Py_ssize_t i = 0; i < size_tx_out;i++){ + PyObject *obj = PyList_GetItem(list_bound_items, i); + dap_list_t *l = pyListToDapList(obj); + tx_out[i] = l; + } + int res = dap_chain_ledger_tx_cache_check(((PyDapChainLedgerObject*)self)->ledger, ((PyDapChainDatumTxObject*)obj_datum_tx)->datum_tx, bound_items, tx_out); + return PyLong_FromLong(res); } PyObject *dap_chain_node_datum_tx_cache_check_py(PyObject *self, PyObject *args){ - return NULL; + PyObject *obj_datum_tx; + PyObject *list_bound_items; + if (!PyArg_ParseTuple(args, "O|O", &obj_datum_tx, &list_bound_items)) + return NULL; + Py_ssize_t size = PyList_Size(list_bound_items); + dap_list_t **bound_items = calloc(sizeof (dap_list_t**), (size_t)size); + for (int i = 0; i < size ; i++){ + PyObject *obj = PyList_GetItem(list_bound_items, i); + dap_list_t *l = pyListToDapList(obj); + bound_items[i] = l; + } + int res = dap_chain_node_datum_tx_cache_check(((PyDapChainDatumTxObject*)obj_datum_tx)->datum_tx, bound_items); + return PyLong_FromLong(res); } PyObject *dap_chain_ledger_tx_remove_py(PyObject *self, PyObject *args){ PyObject *obj_h_fast; -- GitLab