Skip to content
Snippets Groups Projects
Commit 98fc8298 authored by Roman Khlopkov's avatar Roman Khlopkov 🔜
Browse files

Merge branch 'support-7164' into 'develop'

[*] Transferred changes from the master. In addition to changes in obtaining...

See merge request !193
parents abc34a5f 0cdee0b7
No related branches found
No related tags found
1 merge request!193[*] Transferred changes from the master. In addition to changes in obtaining...
......@@ -54,6 +54,10 @@ PyObject *dap_chain_python_get_atoms(PyObject *self, PyObject *args);
PyObject *dap_chain_python_get_count_tx(PyObject *self, PyObject *args);
PyObject *dap_chain_python_get_txs(PyObject *self, PyObject *args);
PyObject *dap_chain_python_get_cs_name(PyObject *self, PyObject *args);
PyObject *PyDapChain_str(PyObject *self);
extern PyTypeObject DapChainObjectType;
DAP_STATIC_INLINE bool PyDapChain_Check(PyDapChainObject* self){
......
#include "libdap-chain-python.h"
#include "dap_chain_pvt.h"
#define LOG_TAG "libdap-chain-python"
......@@ -29,6 +30,7 @@ static PyMethodDef DapChainMethods[] = {
{"getAtoms", (PyCFunction)dap_chain_python_get_atoms, METH_VARARGS, ""},
{"countTx", (PyCFunction)dap_chain_python_get_count_tx, METH_NOARGS, ""},
{"getTransactions", (PyCFunction)dap_chain_python_get_txs, METH_VARARGS, ""},
{"getCSName", (PyCFunction)dap_chain_python_get_cs_name, METH_NOARGS, ""},
{}
};
......@@ -36,6 +38,7 @@ PyTypeObject DapChainObjectType = {
.ob_base = PyVarObject_HEAD_INIT(NULL,0)
.tp_name = "CellFrame.Chain",
.tp_basicsize = sizeof(PyDapChainObject),
.tp_str = PyDapChain_str,
.tp_dealloc = (destructor)PyDapChainObject_dealloc,
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
.tp_methods = DapChainMethods,
......@@ -463,3 +466,14 @@ PyObject *dap_chain_python_get_txs(PyObject *self, PyObject *args){
}
Py_RETURN_NONE;
}
PyObject *dap_chain_python_get_cs_name(PyObject *self, PyObject *args){
(void)args;
dap_chain_t* l_chain = ((PyDapChainObject*)self)->chain_t;
dap_chain_pvt_t *l_chain_pvt = DAP_CHAIN_PVT(l_chain);
return Py_BuildValue("s", l_chain_pvt->cs_name);
}
PyObject *PyDapChain_str(PyObject *self){
return Py_BuildValue("s", ((PyDapChainObject*)self)->chain_t->name);
}
......@@ -63,6 +63,7 @@ PyObject *dap_chain_net_sync_all_py(PyObject *self, PyObject *args);
PyObject *dap_chain_net_proc_datapool_py(PyObject *self, PyObject *args);
PyObject *dap_chain_net_by_name_py(PyObject *self, PyObject *args);
PyObject *dap_chain_get_nets_py(PyObject *self, PyObject *args);
PyObject *dap_chain_net_by_id_py(PyObject *self, PyObject *args);
PyObject *dap_chain_net_id_by_name_py(PyObject *self, PyObject *args);
PyObject *dap_chain_ledger_by_net_name_py(PyObject *self, PyObject *args);
......@@ -80,6 +81,7 @@ PyObject *dap_chain_net_get_chain_by_chain_type_py(PyObject *self, PyObject *arg
PyObject *dap_chain_net_get_ledger_py(PyObject *self, PyObject *args);
PyObject *dap_chain_net_get_name_py(PyObject *self, PyObject *args);
PyObject *dap_chain_net_python_get_id(PyObject *self, void *closure);
PyObject *dap_chain_net_python_get_chains(PyObject *self, void *closure);
PyObject *dap_chain_net_get_tx_by_hash_py(PyObject *self, PyObject *args);
PyObject *dap_chain_net_add_notify_py(PyObject *self, PyObject *args);
......
......@@ -11,6 +11,7 @@ static PyMethodDef DapChainNetMethods[] = {
{"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, ""},
{"getNets", dap_chain_get_nets_py, METH_NOARGS | METH_STATIC, ""},
{"byId", dap_chain_net_by_id_py, METH_VARARGS | METH_STATIC, ""},
{"idByName", dap_chain_net_id_by_name_py, METH_VARARGS | METH_STATIC, ""},
{"ledgerByNetName", dap_chain_ledger_by_net_name_py, METH_VARARGS | METH_STATIC, ""},
......@@ -30,6 +31,7 @@ static PyMethodDef DapChainNetMethods[] = {
static PyGetSetDef DapChainNetGetsSetsDef[] = {
{"id", (getter)dap_chain_net_python_get_id, NULL, NULL, NULL},
{"chains", (getter)dap_chain_net_python_get_chains, NULL, NULL, NULL},
{}
};
......@@ -111,6 +113,19 @@ PyObject *dap_chain_net_by_name_py(PyObject *self, PyObject *args){
}
return Py_BuildValue("O", obj_chain_net);
}
PyObject *dap_chain_get_nets_py(PyObject *self, PyObject *args){
(void)self;
(void)args;
uint16_t l_net_count = 0;
dap_chain_net_t **l_nets = dap_chain_net_list(&l_net_count);
PyObject *obj_nets = PyList_New(l_net_count);
for (uint16_t i = 0; i < l_net_count; i++) {
PyDapChainNetObject *l_obj_net = PyObject_New(PyDapChainNetObject, &DapChainNetObjectType);
l_obj_net->chain_net = l_nets[i];
PyList_SetItem(obj_nets, i, (PyObject*)l_obj_net);
}
return obj_nets;
}
PyObject *dap_chain_net_by_id_py(PyObject *self, PyObject *args){
PyObject *obj_net_id;
if (!PyArg_ParseTuple(args, "O", &obj_net_id))
......@@ -160,6 +175,17 @@ PyObject *dap_chain_net_python_get_id(PyObject *self, void *closure){
obj_net_id->net_id = ((PyDapChainNetObject*)self)->chain_net->pub.id;
return (PyObject*)obj_net_id;
}
PyObject *dap_chain_net_python_get_chains(PyObject *self, void *closure){
(void)closure;
dap_chain_t *l_chain = NULL;
PyObject *obj_list = PyList_New(0);
DL_FOREACH(((PyDapChainNetObject*)self)->chain_net->pub.chains, l_chain) {
PyDapChainObject *obj_chain = PyObject_New(PyDapChainObject, &DapChainObjectType);
obj_chain->chain_t = l_chain;
PyList_Append(obj_list, (PyObject*)obj_chain);
}
return obj_list;
}
PyObject *dap_chain_net_get_cur_addr_py(PyObject *self, PyObject *args){
PyObject *obj_node_addr = _PyObject_New(&DapChainNodeAddrObjectType);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment