From 9bc4b065f30594feffe2d05a270094de43d59ca2 Mon Sep 17 00:00:00 2001 From: "alexey.stratulat" <alexey.stratulat@demlabs.net> Date: Wed, 6 Nov 2019 21:46:49 +0700 Subject: [PATCH] [+] Added wrapping funtions dap_chain_net_links_establish, dap_chain_net_sync_all, dap_chain_net_sync_gdb, dap_chain_net_sync_all, dap_chain_net_proc_datapool, dap_chain_net_by_name for dap_chain_net. --- include/libdap_chain_net_python.h | 6 ++++++ src/libdap_chain_net_python.c | 22 ++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/include/libdap_chain_net_python.h b/include/libdap_chain_net_python.h index 7ba73125..2626627d 100644 --- a/include/libdap_chain_net_python.h +++ b/include/libdap_chain_net_python.h @@ -47,6 +47,12 @@ static PyMethodDef DapChainNetMethods[] = { {"stateGoTo", dap_chain_net_state_go_to_py, METH_VARARGS, ""}, {"start", dap_chain_net_start_py, METH_VARARGS, ""}, {"stop", dap_chain_net_stop_py, METH_VARARGS, ""}, + {"linksEstablish", dap_chain_net_links_establish_py, METH_VARARGS, ""}, + {"syncChains", dap_chain_net_sync_all_py, METH_VARARGS, ""}, + {"syncGdb", dap_chain_net_sync_gdb_py, METH_VARARGS, ""}, + {"syncAll", dap_chain_net_sync_all_py, METH_VARARGS, ""}, + {"procDatapool", dap_chain_net_proc_datapool_py, METH_VARARGS, ""}, + {"byName", dap_chain_net_by_name_py, METH_VARARGS | METH_STATIC, ""}, /*{"csAdd", (PyCFunction)dap_chain_cs_add_py, METH_VARARGS, ""}, {"csCreate", (PyCFunction)dap_chain_cs_create_py, METH_VARARGS, ""}, {"classAdd", (PyCFunction)dap_chain_class_add_py, METH_VARARGS, ""}, diff --git a/src/libdap_chain_net_python.c b/src/libdap_chain_net_python.c index 88e4954d..cf152210 100644 --- a/src/libdap_chain_net_python.c +++ b/src/libdap_chain_net_python.c @@ -28,24 +28,34 @@ PyObject *dap_chain_net_stop_py(PyObject *self, PyObject *args){ return PyLong_FromLong(res); } PyObject *dap_chain_net_links_establish_py(PyObject *self, PyObject *args){ - return NULL; + int res = dap_chain_net_links_establish(((PyDapChainNetObject*)self)->chain_net); + return PyLong_FromLong(res); } PyObject *dap_chain_net_sync_chains_py(PyObject *self, PyObject *args){ - return NULL; + int res = dap_chain_net_sync_chains(((PyDapChainNetObject*)self)->chain_net); + return PyLong_FromLong(res); } PyObject *dap_chain_net_sync_gdb_py(PyObject *self, PyObject *args){ - return NULL; + int res = dap_chain_net_sync_gdb(((PyDapChainNetObject*)self)->chain_net); + return PyLong_FromLong(res); } PyObject *dap_chain_net_sync_all_py(PyObject *self, PyObject *args){ - return NULL; + int res = dap_chain_net_sync_all(((PyDapChainNetObject*)self)->chain_net); + return PyLong_FromLong(res); } PyObject *dap_chain_net_proc_datapool_py(PyObject *self, PyObject *args){ - return NULL; + dap_chain_net_proc_datapool(((PyDapChainNetObject*)self)->chain_net); + return PyLong_FromLong(0); } PyObject *dap_chain_net_by_name_py(PyObject *self, PyObject *args){ - return NULL; + const char *a_name; + if (!PyArg_ParseTuple(args, "s", &a_name)) + return NULL; + PyObject *obj_chain_net = _PyObject_New(&DapChainNetObject_DapChainNetObjectType); + ((PyDapChainNetObject*)obj_chain_net)->chain_net = dap_chain_net_by_name(a_name); + return Py_BuildValue("O", obj_chain_net); } PyObject *dap_chain_net_by_id_py(PyObject *self, PyObject *args){ return NULL; -- GitLab