Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • cellframe/python-cellframe
1 result
Show changes
Commits on Source (2)
Showing
with 1870 additions and 33 deletions
......@@ -40,7 +40,9 @@ add_subdirectory(modules/dap-sdk/net/server/http)
add_subdirectory(modules/dap-sdk/net/server/json_rpc)
add_subdirectory(modules/cellframe-sdk/common)
add_subdirectory(modules/cellframe-sdk/net)
add_subdirectory(modules/cellframe-sdk/net/srv)
add_subdirectory(modules/cellframe-sdk/gdb)
add_subdirectory(modules/cellframe-sdk/global-db)
add_subdirectory(modules/cellframe-sdk/chain)
add_subdirectory(modules/cellframe-sdk/app-cli)
add_subdirectory(modules/cellframe-sdk/wallet)
......@@ -50,6 +52,7 @@ add_subdirectory(modules/cellframe-sdk/type/dag)
target_compile_options(dap_python_module PRIVATE "-fpic" )
target_compile_options(dap_crypto_python_module PRIVATE "-fpic" )
target_compile_options(dap_chain_net_python_module PRIVATE "-fpic")
target_compile_options(dap_chain_net_srv_python_module PRIVATE "-fpic")
target_compile_options(dap_chain_gdb_python_module PRIVATE "-fpic")
target_compile_options(dap_chain_python_module PRIVATE "-fpic")
target_compile_options(dap_app_cli_python_module PRIVATE "-fpic")
......@@ -179,7 +182,9 @@ target_link_libraries(${PROJECT_NAME} cellframe-sdk dap_python_module
dap_server_http_python_module
dap_chain_python_module
dap_chain_net_python_module
dap_chain_net_srv_python_module
dap_chain_gdb_python_module
dap_chain_global_db_python_module
dap_app_cli_python_module
dap_chain_wallet_python_module
dap_server_json_rpc_python_module
......
project(dap_chain_global_db_python_module C)
cmake_minimum_required(VERSION 3.0)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_COLOR_MAKEFILE ON)
set(CMAKE_C_STANDARD 11)
add_definitions("-fpic")
add_definitions ("-DNODE_NETNAME=\"cellframe\"")
add_definitions("-DDAP_LOG_MT")
if(UNIX)
add_definitions("-DDAP_OS_UNIX")
endif()
if(NOT (${SUBMODULES_NO_BUILD} MATCHES ON))
set (SUBMODULES_NO_BUILD ON)
if (NOT (TARGET dap_core))
add_subdirectory(libdap)
target_compile_options(
dap_core PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_crypto))
add_subdirectory(libdap-crypto)
target_compile_options(
dap_crypto PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_chain))
add_subdirectory(libdap-chain)
target_compile_options(
dap_chain PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_chain_crypto))
add_subdirectory(libdap-chain-crypto)
target_compile_options(
dap_chain_crypto PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_chain_mempool))
add_subdirectory(libdap-chain-mempool)
target_compile_options(
dap_chain_mempool PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_chain_net))
add_subdirectory(libdap-chain-net)
target_compile_options(
dap_chain_net PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_server_core))
add_subdirectory(libdap-server-core)
target_compile_options(
dap_server_core PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_chain_global_db))
add_subdirectory(libdap-chain-global-db)
target_compile_options(
dap_chain_global_db PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_client))
add_subdirectory(libdap-client)
target_compile_options(
dap_client PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET libdap-server))
add_subdirectory(libdap-server)
# target_compile_options(
# libdap-server PRIVATE
# "-fpic"
# )
endif()
if (NOT (TARGET dap_stream))
add_subdirectory(libdap-stream)
target_compile_options(
dap_stream PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_stream_ch))
add_subdirectory(libdap-stream-ch)
target_compile_options(
dap_stream_ch PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_stream_ch_chain))
add_subdirectory(libdap-stream-ch-chain)
target_compile_options(
dap_stream_ch_chain PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_stream_ch_chain_net))
add_subdirectory(libdap-stream-ch-chain-net)
target_compile_options(
dap_stream_ch_chain_net PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_udp_server))
add_subdirectory(libdap-server-udp)
target_compile_options(
dap_udp_server PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_chain_net_srv))
add_subdirectory(libdap-chain-net-srv)
target_compile_options(
dap_chain_net_srv PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_chain_wallet))
add_subdirectory(libdap-chain-wallet)
target_compile_options(
dap_chain_wallet PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_server_http_db))
add_subdirectory(libdap-server-http-db)
target_compile_options(
dap_server_http_db PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_server_http_db_auth))
add_subdirectory(libdap-server-http-db-auth)
target_compile_options(
dap_server_http_db_auth PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_chain_gdb))
add_subdirectory(libdap-chain-gdb)
target_compile_options(
dap_chain_gdb PRIVATE
"-fpic"
)
endif()
#if (NOT (TARGET dap_python_module))
# add_subdirectory(libdap-python)
# target_compile_options(
# dap_python_module PRIVATE
# "-fpic"
# )
#endif()
#if (NOT (TARGET dap_crypto_python_module))
# add_subdirectory(libdap-crypto-python)
# target_compile_options(
# dap_crypto_python_module PRIVATE
# "-fpic"
# )
#endif()
if (NOT (TARGET dap_chain_net_srv_vpn))
add_subdirectory(libdap-chain-net-srv-vpn)
target_compile_options(
dap_chain_net_srv_vpn PRIVATE
"-fpic"
)
endif()
endif()
#add_definitions("-DDAP_APP_NAME=\"TestPRJ\" -DSYSTEM_CONFIGS_DIR=\"${CMAKE_CURRENT_BINARY_DIR}\"")
file(GLOB CHAIN_GLOBAL_DB_PYTHON_SRCS src/*.c)
file(GLOB CHAIN_GLOBAL_DB_PYTHON_HEADERS include/*.h)
set(Python_ADDITIONAL_VERSIONS 3.7)
find_package (PythonLibs REQUIRED)
include_directories(${PYTHON_INCLUDE_DIR} include/)
add_library(${PROJECT_NAME} STATIC ${CHAIN_GLOBAL_DB_PYTHON_SRCS} ${CHAIN_GLOBAL_DB_PYTHON_HEADERS})
target_link_libraries(${PROJECT_NAME})
target_include_directories(${PROJECT_NAME} PUBLIC include/ )
#target_compile_options(
# dap_core PRIVATE
# "-fpic"
#)
#target_compile_options(
# dap_crypto PRIVATE
# "-fpic"
#)
target_link_libraries(${PROJECT_NAME} dap_core dap_crypto dap_chain dap_chain_crypto dap_server_core dap_chain_net dap_chain_global_db dap_chain_common_python_module)
#target_link_libraries(${PROJECT_NAME} dap_core dap_crypto dap_chain dap_chain_global_db dap_chain_crypto dap_chain_mempool
#
# ) #dap_chain_crypto dap_chain_mempool dap_chain_global_db )
#target_link_libraries(${PROJECT_NAME} dap_core dap_crypto)
target_include_directories(${PROJECT_NAME} PUBLIC include/ )
#if(BUILD_DAP_CRYPTO_PYTHON_TESTS)
# add_subdirectory(test)
# file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test/test_b58.py
# DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test/)
# file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test/test_b64.py
# DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test/)
# file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test/test_iaes256_cbc.py
# DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test/)
# file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test/test_iaes256_cbc.py
# DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test/)
# file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test/test_oaes.py
# DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test/)
#endif()
#pragma once
#include "Python.h"
#include "dap_chain_global_db.h"
#include "dap_strfuncs.h"
typedef struct PyDapChainGlobalDB{
PyObject_HEAD
}PyDapChainGlobalDBObject;
PyObject *wrapping_dap_chain_global_db_gr_get(PyObject *self, PyObject *args);
PyObject *wrapping_dap_chain_global_db_gr_set(PyObject *self, PyObject *args);
PyObject *wrapping_dap_chain_global_db_gr_del(PyObject *self, PyObject *args);
PyObject *wrapping_dap_chain_global_db_gr_pin(PyObject *self, PyObject *args);
static PyMethodDef DapChainGlobalDB_Methods[] = {
{"get", (PyCFunction)wrapping_dap_chain_global_db_gr_get, METH_VARARGS | METH_STATIC, ""},
{"set", (PyCFunction)wrapping_dap_chain_global_db_gr_set, METH_VARARGS | METH_STATIC, ""},
{"delete", (PyCFunction)wrapping_dap_chain_global_db_gr_del, METH_VARARGS | METH_STATIC, ""},
{"pin", (PyCFunction)wrapping_dap_chain_global_db_gr_pin, METH_VARARGS | METH_STATIC, ""},
{NULL, NULL, 0, NULL}
};
static PyTypeObject DapChainGlobalDBObject_DapChainDlobalDBType = {
PyVarObject_HEAD_INIT(NULL, 0)
"CellFrame.ChainGlobalDB", /* tp_name */
sizeof(PyDapChainGlobalDBObject), /* tp_basicsize */
0, /* tp_itemsize */
0, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
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_BASETYPE, /* tp_flags */
"Chain global db object", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
DapChainGlobalDB_Methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
PyType_GenericNew, /* tp_new */
};
#include "wrapping_dap_chain_global_db.h"
PyObject *wrapping_dap_chain_global_db_gr_get(PyObject *self, PyObject *args){
(void)self;
const char *l_key;
const char *l_group;
if (!PyArg_ParseTuple(args, "ss", &l_key, &l_group)){
return NULL;
}
size_t l_size_data = 0;
void *l_bytes = dap_chain_global_db_gr_get(l_key, &l_size_data, l_group);
if (l_size_data == 0)
return Py_None;
PyObject *l_obj_bytes = PyBytes_FromStringAndSize(l_bytes, (Py_ssize_t)l_size_data);
return l_obj_bytes;
}
PyObject *wrapping_dap_chain_global_db_gr_set(PyObject *self, PyObject *args){
(void)self;
char *l_key;
char *l_group;
PyObject *obj_byte;
if (!PyArg_ParseTuple(args, "ssO", &l_key, &l_group, &obj_byte)){
return NULL;
}
if (!PyBytes_Check(obj_byte)){
return NULL;
}
char *l_key_dup = dap_strdup(l_key);
void *l_bytes = PyBytes_AsString(obj_byte);
size_t l_bytes_size = PyBytes_Size(obj_byte);
void *l_bytes_dup = dap_strdup(l_bytes);
bool ret = dap_chain_global_db_gr_set(l_key_dup, l_bytes_dup, l_bytes_size, l_group);
if (ret == true){
return Py_True;
} else {
return Py_False;
}
}
PyObject *wrapping_dap_chain_global_db_gr_del(PyObject *self, PyObject *args){
(void)self;
const char *l_key;
const char *l_group;
if (!PyArg_ParseTuple(args, "ss",&l_key, &l_group)){
return NULL;
}
char *l_key_dup = dap_strdup(l_key);
char *l_group_dup = dap_strdup(l_group);
bool ret = dap_chain_global_db_gr_del(l_key_dup, l_group_dup);
if (ret == true)
return Py_True;
else
return Py_False;
}
PyObject *wrapping_dap_chain_global_db_gr_pin(PyObject *self, PyObject *args){
return Py_None;
}
......@@ -76,8 +76,6 @@ PyObject *dap_chain_net_links_connect_py(PyObject *self, PyObject *args);
PyObject *dap_chain_net_get_chain_by_chain_type_py(PyObject *self, PyObject *args);
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_get_tx_by_hash_py(PyObject *self, PyObject *args);
PyObject *dap_chain_net_python_get_id(PyObject *self, void *closure);
static PyMethodDef DapChainNetMethods[] = {
{"loadAll", dap_chain_net_load_all_py, METH_NOARGS | METH_STATIC, ""},
......@@ -102,12 +100,13 @@ static PyMethodDef DapChainNetMethods[] = {
{"getChainByChainType", dap_chain_net_get_chain_by_chain_type_py, METH_VARARGS, ""},
{"getLedger", dap_chain_net_get_ledger_py, METH_NOARGS, ""},
{"getName", dap_chain_net_get_name_py, METH_NOARGS, ""},
{"getTxByHash", dap_chain_net_get_tx_by_hash_py, METH_VARARGS, ""},
{NULL, NULL, 0, NULL}
};
PyObject *dap_chain_net_python_get_id(PyObject *self, void *closure);
static PyGetSetDef DapChainNetGetsSetsDef[] = {
{"id", (getter)dap_chain_net_python_get_id, NULL, NULL, NULL},
{"id", (getter)dap_chain_net_python_get_id, NULL, NULL, NULL},
{NULL}
};
......@@ -140,9 +139,9 @@ static PyTypeObject DapChainNetObject_DapChainNetObjectType = {
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
DapChainNetMethods, /* tp_methods */
0, /* tp_members */
DapChainNetGetsSetsDef, /* tp_getset */
DapChainNetMethods, /* tp_methods */
0, /* tp_members */
DapChainNetGetsSetsDef, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
......@@ -153,6 +152,10 @@ static PyTypeObject DapChainNetObject_DapChainNetObjectType = {
PyType_GenericNew, /* tp_new */
};
static bool PyDapChainNet_Check(PyObject *a_obj){
return PyObject_TypeCheck(a_obj, &DapChainNetObject_DapChainNetObjectType);
}
#ifdef __cplusplus
}
#endif
......
......@@ -107,6 +107,14 @@ PyObject *dap_chain_net_get_chain_by_name_py(PyObject *self, PyObject *args){
return Py_BuildValue("O", obj_chain);
}
PyObject *dap_chain_net_python_get_id(PyObject *self, void *closure){
(void)closure;
PyDapChainNetIdObject *obj_net_id = PyObject_New(PyDapChainNetIdObject, &DapChainNetIdObject_DapChainNetIdObjectType);
PyObject_Dir((PyObject*)obj_net_id);
obj_net_id->net_id = ((PyDapChainNetObject*)self)->chain_net->pub.id;
return (PyObject*)obj_net_id;
}
PyObject *dap_chain_net_get_cur_addr_py(PyObject *self, PyObject *args){
PyObject *obj_node_addr = _PyObject_New(&DapChainNodeAddrObject_DapChainNodeAddrObjectType);
((PyDapChainNodeAddrObject*)obj_node_addr)->node_addr = dap_chain_net_get_cur_addr(((PyDapChainNetObject*)self)->chain_net);
......@@ -167,27 +175,3 @@ PyObject *dap_chain_net_get_name_py(PyObject *self, PyObject *args){
PyObject *obj_name = PyUnicode_FromString(((PyDapChainNetObject*)self)->chain_net->pub.name);
return obj_name;
}
PyObject *dap_chain_net_get_tx_by_hash_py(PyObject *self, PyObject *args){
PyObject *obj_hash;
if (!PyArg_ParseTuple(args, "O", &obj_hash)){
return NULL;
}
PyDapChainDatumTxObject *obj_tx = PyObject_New(PyDapChainDatumTxObject, &DapChainDatumTx_DapChainDatumTxObjectType);
PyObject_Dir((PyObject*)obj_tx);
obj_tx->datum_tx = dap_chain_net_get_tx_by_hash(((PyDapChainNetObject*)self)->chain_net,
((PyDapHashFastObject*)obj_hash)->hash_fast, TX_SEARCH_TYPE_LOCAL);
if(obj_tx->datum_tx == NULL){
Py_XDECREF(obj_tx);
return Py_None;
}
return (PyObject*)obj_tx;
}
PyObject *dap_chain_net_python_get_id(PyObject *self, void *closure){
(void)closure;
PyDapChainNetIdObject *obj_net_id = PyObject_New(PyDapChainNetObject, &DapChainNetIdObject_DapChainNetIdObjectType);
PyObject_Dir((PyObject*)obj_net_id);
obj_net_id->net_id = ((PyDapChainNetObject*)self)->chain_net->pub.id;
return (PyObject*)obj_net_id;
}
......@@ -100,7 +100,6 @@ void element_py_func_del_all(){
}
static int wrapping_cmdfunc(int argc, char **argv, char **str_reply){
PyGILState_STATE state = PyGILState_Ensure();
size_t id_str_replay = elements_str_reply_add(str_reply);
PyObject *obj_argv = stringToPyList(argc, argv);
PyObject *obj_id_str_replay = PyLong_FromSize_t(id_str_replay);
......@@ -115,7 +114,6 @@ static int wrapping_cmdfunc(int argc, char **argv, char **str_reply){
Py_XDECREF(arglist);
Py_XDECREF(obj_argv);
elements_str_reply_delete(id_str_replay);
PyGILState_Release(state);
return 0;
}
......
project(dap_chain_net_srv_python_module C)
cmake_minimum_required(VERSION 3.0)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_COLOR_MAKEFILE ON)
set(CMAKE_C_STANDARD 11)
add_definitions("-fpic")
if(UNIX)
add_definitions("-DDAP_OS_UNIX")
endif()
if(NOT (${SUBMODULES_NO_BUILD} MATCHES ON))
set (SUBMODULES_NO_BUILD ON)
if (NOT (TARGET dap_core))
add_subdirectory(libdap)
target_compile_options(
dap_core PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_crypto))
add_subdirectory(libdap-crypto)
target_compile_options(
dap_crypto PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_chain))
add_subdirectory(libdap-chain)
target_compile_options(
dap_chain PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_chain_crypto))
add_subdirectory(libdap-chain-crypto)
target_compile_options(
dap_chain_crypto PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_chain_mempool))
add_subdirectory(libdap-chain-mempool)
target_compile_options(
dap_chain_mempool PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_chain_net))
add_subdirectory(libdap-chain-net)
target_compile_options(
dap_chain_net PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_server_core))
add_subdirectory(libdap-server-core)
target_compile_options(
dap_server_core PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_chain_global_db))
add_subdirectory(libdap-chain-global-db)
target_compile_options(
dap_chain_global_db PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_client))
add_subdirectory(libdap-client)
target_compile_options(
dap_client PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET libdap-server))
add_subdirectory(libdap-server)
# target_compile_options(
# libdap-server PRIVATE
# "-fpic"
# )
endif()
if (NOT (TARGET dap_stream))
add_subdirectory(libdap-stream)
target_compile_options(
dap_stream PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_stream_ch))
add_subdirectory(libdap-stream-ch)
target_compile_options(
dap_stream_ch PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_stream_ch_chain))
add_subdirectory(libdap-stream-ch-chain)
target_compile_options(
dap_stream_ch_chain PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_stream_ch_chain_net))
add_subdirectory(libdap-stream-ch-chain-net)
target_compile_options(
dap_stream_ch_chain_net PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_udp_server))
add_subdirectory(libdap-server-udp)
target_compile_options(
dap_udp_server PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_chain_net_srv))
add_subdirectory(libdap-chain-net-srv)
target_compile_options(
dap_chain_net_srv PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_chain_wallet))
add_subdirectory(libdap-chain-wallet)
target_compile_options(
dap_chain_wallet PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_chain_gdb))
add_subdirectory(libdap-chain-gdb)
target_compile_options(
dap_chain_gdb PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_python_module))
add_subdirectory(libdap-python)
target_compile_options(
dap_python_module PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_crypto_python_module))
add_subdirectory(libdap-crypto-python)
target_compile_options(
dap_crypto_python_module PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_chain_net_srv_vpn))
add_subdirectory(libdap-chain-net-srv-vpn)
target_compile_options(
dap_chain_net_srv_vpn PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_chain_python_module))
add_subdirectory(libdap-chain-python)
target_compile_options(
dap_chain_python_module PRIVATE
"-fpic"
)
endif()
if (NOT (TARGET dap_client_python_module))
add_subdirectory(libdap-client-python)
target_compile_options(
dap_client_python_module PRIVATE
"-fpic"
)
endif()
endif()
#add_definitions("-DDAP_APP_NAME=\"TestPRJ\" -DSYSTEM_CONFIGS_DIR=\"${CMAKE_CURRENT_BINARY_DIR}\"")
file(GLOB CHAIN_NET_SRV_PYTHON_SRCS src/*.c)
file(GLOB CHAIN_NET_SRV_PYTHON_HEADERS include/*.h)
set(Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.4)
find_package (PythonLibs REQUIRED)
include_directories(${PYTHON_INCLUDE_DIR} include/)
add_library(${PROJECT_NAME} STATIC ${CHAIN_NET_SRV_PYTHON_SRCS} ${CHAIN_NET_SRV_PYTHON_HEADERS})
target_link_libraries(${PROJECT_NAME})
target_include_directories(${PROJECT_NAME} PUBLIC include/ )
target_link_libraries(${PROJECT_NAME} dap_core
dap_crypto
dap_chain
dap_server_core
dap_chain_net
dap_chain_net_srv
dap_chain_python_module
dap_chain_net_python_module
dap_client_python_module)
#pragma once
#include "Python.h"
#include "dap_chain_net_srv.h"
#include "uthash.h"
#include "wrapping_dap_chain_net_srv_client_remote.h"
#include "wrapping_dap_chain_common.h"
//#include "wrapping_dap_chain_net_srv_common.h"
typedef struct PyDapChainNetSrv{
PyObject_HEAD
dap_chain_net_srv_t *srv;
bool original;
}PyDapChainNetSrvObject;
int PyDapChainNetSrv_init(PyDapChainNetSrvObject* self, PyObject *args, PyObject *kwds);
void PyDapChainNetSrv_dealloc(PyDapChainNetSrvObject* self);
PyObject *wrapping_dap_chain_net_srv_get_uid(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_get_abstract(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_get_price_list(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_get_ban_list(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_get_grace_period(PyObject *self, void *closure);
//Function
//PyObject *wrapping_dap_chain_net_srv_issue_receipt(PyObject *self, PyObject *args);
static PyMethodDef DapChainNetSrvMethods[]={
{NULL, NULL, 0, NULL}
};
static PyGetSetDef DapChaiNetSrvGetsSets[] = {
{"uid", (getter)wrapping_dap_chain_net_srv_get_uid, NULL, NULL, NULL},
{"gracePeriod", (getter)wrapping_dap_chain_net_srv_get_grace_period, NULL, NULL, NULL},
{NULL}
};
static PyTypeObject DapChainNetSrvObject_DapChainNetSrvObjectType = {
PyVarObject_HEAD_INIT(NULL, 0)
"CellFrame.ChainNetSrv", /* tp_name */
sizeof(PyDapChainNetSrvObject), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)PyDapChainNetSrv_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
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_BASETYPE, /* tp_flags */
"Chain net srv object", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
DapChainNetSrvMethods, /* tp_methods */
0, /* tp_members */
DapChaiNetSrvGetsSets, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)PyDapChainNetSrv_init, /* tp_init */
0, /* tp_alloc */
PyType_GenericNew, /* tp_new */
};
#pragma once
#include "Python.h"
#include "dap_chain_net_srv_client.h"
#include "libdap_chain_net_python.h"
typedef struct PyDapChainNetSrvClient{
PyObject_HEAD
dap_chain_net_srv_client_t *srv_client;
}PyDapChainNetSrvClientObject;
int PyDapChainNetSrvClient_init(PyDapChainNetSrvClientObject* self, PyObject *args, PyObject *kwds);
PyObject *wrapping_dap_chain_net_srv_client_write(PyObject *self, PyObject *args);
static PyMethodDef DapChainNetSrvClientMethods[]={
{NULL, NULL, 0, NULL}
};
static PyGetSetDef DapChaiNetSrvClientGetsSets[] = {
// {"uid", (getter)wrapping_dap_chain_net_srv_get_uid, NULL, NULL, NULL},
// {"gracePeriod", (getter)wrapping_dap_chain_net_srv_get_grace_period, NULL, NULL, NULL},
{NULL}
};
static PyTypeObject DapChainNetSrvClientObject_DapChainNetSrvClientObjectType = {
PyVarObject_HEAD_INIT(NULL, 0)
"CellFrame.ChainNetSrv", /* tp_name */
sizeof(PyDapChainNetSrvClientObject), /* tp_basicsize */
0, /* tp_itemsize */
0, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
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_BASETYPE, /* tp_flags */
"Chain net srv client object", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
DapChainNetSrvClientMethods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)PyDapChainNetSrvClient_init, /* tp_init */
0, /* tp_alloc */
PyType_GenericNew, /* tp_new */
};
//
// Created by blus on 05.02.2022.
//
#include "Python.h"
#include "datetime.h"
#include "dap_chain_net_srv.h"
#ifndef WRAPPING_DAP_CHAIN_NET_SRV_CLIENT_REMOTE_H
#define WRAPPING_DAP_CHAIN_NET_SRV_CLIENT_REMOTE_H
typedef struct PyDapChainNetSrvClientRemote{
PyObject_HEAD
dap_chain_net_srv_client_remote_t *srv_client_remote;
}PyDapChainNetSrvClientRemoteObject;
PyObject *wrapping_dap_chain_net_srv_client_remote_get_ch(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_client_remote_get_ts_created(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_client_remote_get_created(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_client_remote_get_stream_worker(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_client_remote_get_session_id(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_client_remote_get_bytes_received(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_client_remote_get_bytes_send(PyObject *self, void *closure);
//PyObject *wrapping_dap_chain_net_srv_client_remote_get_bytes_prev(PyObject *self, void *closure);
//PyObject *wrapping_dap_chain_net_srv_client_remote_get_bytes_next(PyObject *self, void *closure);
static PyMethodDef DapChainNetSrvClientMethods[]={
{NULL, NULL, 0, NULL}
};
static PyGetSetDef DapChaiNetSrvClientGetsSets[] = {
{"ch", (getter)wrapping_dap_chain_net_srv_client_remote_get_ch, NULL, NULL, NULL},
{"tsCreated", (getter)wrapping_dap_chain_net_srv_client_remote_get_ts_created, NULL, NULL, NULL},
{"created", (getter)wrapping_dap_chain_net_srv_client_remote_get_created, NULL, NULL, NULL},
{"streamWorker", (getter)wrapping_dap_chain_net_srv_client_remote_get_stream_worker, NULL, NULL, NULL},
{"sessionId", (getter)wrapping_dap_chain_net_srv_client_remote_get_session_id, NULL, NULL, NULL},
{"bytesReceived", (getter)wrapping_dap_chain_net_srv_client_remote_get_bytes_received, NULL, NULL, NULL},
{"bytesSend", (getter)wrapping_dap_chain_net_srv_client_remote_get_bytes_send, NULL, NULL, NULL},
{NULL}
};
static PyTypeObject DapChainNetSrvClientObject_DapChainNetSrvClientObjectType = {
PyVarObject_HEAD_INIT(NULL, 0)
"CellFrame.ChainNetSrvClientRemote", /* tp_name */
sizeof(PyDapChainNetSrvClientRemoteObject), /* tp_basicsize */
0, /* tp_itemsize */
0, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
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_BASETYPE, /* tp_flags */
"Chain net srv client object", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
DapChainNetSrvClientMethods, /* tp_methods */
0, /* tp_members */
DapChaiNetSrvClientGetsSets, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
PyType_GenericNew, /* tp_new */
};
#endif //WRAPPING_DAP_CHAIN_NET_SRV_CLIENT_REMOTE_H
#pragma once
#include "Python.h"
#include "dap_chain_net_srv_common.h"
#include "wrapping_dap_chain_common.h"
#include "libdap_chain_net_python.h"
/*wrapping dap_chain_net_srv_price*/
typedef struct PyDapChainNetSrvPrice{
PyObject_HEAD
dap_chain_net_srv_price_t price;
}PyDapChainNetSrvPriceObject;
PyObject *wrapping_dap_chain_net_srv_get_wallet(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_get_net_name(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_get_net(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_get_value_datoshi(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_get_token(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_get_units(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_get_units_uid(PyObject *self, void *closure);
static PyGetSetDef DapChainNetSrvPrice_GetsSetsDef[] = {
{"wallet", (getter)wrapping_dap_chain_net_srv_get_wallet, NULL, NULL, NULL},
{"netName", (getter)wrapping_dap_chain_net_srv_get_net_name, NULL, NULL, NULL},
{"net", (getter)wrapping_dap_chain_net_srv_get_net, NULL, NULL, NULL},
{"valueDatoshi", (getter)wrapping_dap_chain_net_srv_get_value_datoshi, NULL, NULL, NULL},
{"token", (getter)wrapping_dap_chain_net_srv_get_token, NULL, NULL, NULL},
{"units", (getter)wrapping_dap_chain_net_srv_get_units, NULL, NULL, NULL},
{"unitsUid", (getter)wrapping_dap_chain_net_srv_get_units_uid, NULL, NULL, NULL},
{NULL}
};
static PyTypeObject DapChainNetSrvPriceObject_DapChainNetSrvPriceObjectType = {
PyVarObject_HEAD_INIT(NULL, 0)
"CellFrame.ChainNetSrvPrice", /* tp_name */
sizeof(PyDapChainNetSrvPriceObject), /* tp_basicsize */
0, /* tp_itemsize */
0, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
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_BASETYPE, /* tp_flags */
"Chain net srv price object", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
DapChainNetSrvPrice_GetsSetsDef, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
PyType_GenericNew, /* tp_new */
};
/*wrapping dap_chain_net_srv_order_direction*/
typedef struct PyDapChainNetSrvOrderDirection{
PyObject_HEAD
dap_chain_net_srv_order_direction_t direction;
}PyDapChainNetSrvOrderDirectionObject;
PyObject *DapChainNetSrvOrderDirection_str(PyObject *self);
PyObject *wrapping_dap_chain_net_srv_order_direction_get_serv_dir_buy(PyObject *self, PyObject *args);
PyObject *wrapping_dap_chain_net_srv_order_direction_get_serv_dir_sell(PyObject *self, PyObject *args);
PyObject *wrapping_dap_chain_net_srv_order_direction_get_serv_dir_undefined(PyObject *self, PyObject *args);
static PyMethodDef DapChainNetSrvOrderDirection_Methods[] = {
{"getDirBuy", (PyCFunction)wrapping_dap_chain_net_srv_order_direction_get_serv_dir_buy, METH_NOARGS | METH_STATIC, ""},
{"getDirSell", (PyCFunction)wrapping_dap_chain_net_srv_order_direction_get_serv_dir_sell, METH_NOARGS | METH_STATIC, ""},
{"getDirUndefined", (PyCFunction)wrapping_dap_chain_net_srv_order_direction_get_serv_dir_undefined, METH_NOARGS | METH_STATIC, ""},
{NULL, NULL, 0, NULL}
};
static PyTypeObject DapChainNetSrvOrderDirectionObject_DapChainNetSrvOrderDirectionObjectType = {
PyVarObject_HEAD_INIT(NULL, 0)
"CellFrame.ChainNetSrvOrderDirection", /* tp_name */
sizeof(PyDapChainNetSrvOrderDirectionObject), /* tp_basicsize */
0, /* tp_itemsize */
0, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
DapChainNetSrvOrderDirection_str, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT |
Py_TPFLAGS_BASETYPE, /* tp_flags */
"Chain net srv order direction object", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
DapChainNetSrvOrderDirection_Methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
PyType_GenericNew, /* tp_new */
};
\ No newline at end of file
#pragma once
#include "Python.h"
#include "dap_chain_net_srv_order.h"
#include "wrapping_dap_chain_common.h"
#include "libdap_chain_net_python.h"
#include "wrapping_dap_chain_net_srv_common.h"
#include "datetime.h"
#include "libdap_crypto_key_python.h"
typedef struct PyDapChainNetSrvOrder{
PyObject_HEAD
dap_chain_net_srv_order_t *order;
//dap_chain_net_srv_order_old_t *order_old;
}PyDapChainNetSrvOrderObject;
//constructor
int PyDapChainNetSrvOrder_init(PyDapChainNetSrvOrderObject *self, PyObject *args, PyObject *kwds);
//Attributes
PyObject *wrapping_dap_chain_net_srv_order_get_version(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_order_get_srv_uid(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_order_get_srv_direction(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_order_get_srv_node_addr(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_order_get_srv_tx_cond_hash(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_order_get_srv_price_unit(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_order_get_srv_ts_created(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_order_get_srv_ts_expires(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_order_get_srv_price(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_order_get_srv_price_ticker(PyObject *self, void *closure);
//PyObject *wrapping_dap_chain_net_srv_order_get_srv_free_space(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_order_get_srv_ext_size(PyObject *self, void *closure);
PyObject *wrapping_dap_chain_net_srv_order_get_srv_ext_n_sign(PyObject *self, void *closure);
//Functions
PyObject *wrapping_dap_chain_net_srv_order_get_size(PyObject *self, PyObject *args);
//PyObject *wrapping_dap_chain_net_srv_order_set_continent_region(PyObject *self, PyObject *args);
//PyObject *wrapping_dap_chain_net_srv_order_get_continent_region(PyObject *self, PyObject *args);
//PyObject *wrapping_dap_chain_net_srv_order_get_country_code(PyObject *self, PyObject *args);
//PyObject *wrapping_dap_chain_net_srv_order_continents_count(PyObject *self, PyObject *args);
//PyObject *wrapping_dap_chain_net_srv_order_continent_to_str(PyObject *self, PyObject *args);
//PyObject *wrapping_dap_chain_net_srv_order_continent_to_num(PyObject *self, PyObject *args);
PyObject *wrapping_dap_chain_net_srv_order_find(PyObject *self, PyObject *args);
PyObject *wrapping_dap_chain_net_srv_order_delete(PyObject *self, PyObject *args);
PyObject *wrapping_dap_chain_net_srv_order_find_all_by(PyObject *self, PyObject *args);
PyObject *wrapping_dap_chain_net_srv_order_save(PyObject *self, PyObject *args);
PyObject *wrapping_dap_chain_net_srv_order_get_gdb_group(PyObject *self, PyObject *args);
PyObject *wrapping_dap_chain_net_srv_order_get_nodelist_group(PyObject *self, PyObject *args);
static PyMethodDef DapChainNetSrvOrderMethods[]={
{"size", (PyCFunction)wrapping_dap_chain_net_srv_order_get_size, METH_VARARGS, ""},
{"find", (PyCFunction)wrapping_dap_chain_net_srv_order_find, METH_VARARGS | METH_STATIC, ""},
{"delete", (PyCFunction)wrapping_dap_chain_net_srv_order_delete, METH_VARARGS | METH_STATIC, ""},
{"save", (PyCFunction)wrapping_dap_chain_net_srv_order_save, METH_VARARGS, ""},
{"getGdbGroup", (PyCFunction)wrapping_dap_chain_net_srv_order_get_gdb_group, METH_VARARGS | METH_STATIC, ""},
{"getNodelistGroup", (PyCFunction)wrapping_dap_chain_net_srv_order_get_nodelist_group, METH_VARARGS | METH_STATIC, ""},
{NULL, NULL, 0, NULL}
};
static PyGetSetDef DapChaiNetSrvOrderGetsSets[] = {
{"version", (getter)wrapping_dap_chain_net_srv_order_get_version, NULL, NULL, NULL},
{"uid", (getter)wrapping_dap_chain_net_srv_order_get_srv_uid, NULL, NULL, NULL},
{"direction", (getter)wrapping_dap_chain_net_srv_order_get_srv_direction, NULL, NULL, NULL},
{"nodeAddr", (getter)wrapping_dap_chain_net_srv_order_get_srv_node_addr, NULL, NULL, NULL},
{"condHash", (getter)wrapping_dap_chain_net_srv_order_get_srv_tx_cond_hash, NULL, NULL, NULL},
{"priceUnit", (getter)wrapping_dap_chain_net_srv_order_get_srv_price_unit, NULL, NULL, NULL},
{"tsCreated", (getter)wrapping_dap_chain_net_srv_order_get_srv_ts_created, NULL, NULL, NULL},
{"tsExpires", (getter)wrapping_dap_chain_net_srv_order_get_srv_ts_expires, NULL, NULL, NULL},
{"srvPrice", (getter)wrapping_dap_chain_net_srv_order_get_srv_price, NULL, NULL, NULL},
{"srvPriceTicker", (getter)wrapping_dap_chain_net_srv_order_get_srv_price_ticker, NULL, NULL, NULL},
{"extSize", (getter)wrapping_dap_chain_net_srv_order_get_srv_ext_size, NULL, NULL, NULL},
{"extSign", (getter)wrapping_dap_chain_net_srv_order_get_srv_ext_n_sign, NULL, NULL, NULL},
{NULL}
};
static PyTypeObject DapChainNetSrvOrderObject_DapChainNetSrvOrderObjectType = {
PyVarObject_HEAD_INIT(NULL, 0)
"CellFrame.ChainNetSrvOrder", /* tp_name */
sizeof(PyDapChainNetSrvOrderObject), /* tp_basicsize */
0, /* tp_itemsize */
0, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
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_BASETYPE, /* tp_flags */
"Chain net srv client object", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
DapChainNetSrvOrderMethods, /* tp_methods */
0, /* tp_members */
DapChaiNetSrvOrderGetsSets, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)PyDapChainNetSrvOrder_init, /* tp_init */
0, /* tp_alloc */
PyType_GenericNew, /* tp_new */
};
#include "wrapping_dap_chain_net_srv.h"
enum _wrapping_dap_chain_net_srv_type_callbacks{
WRAPPING_DAP_CHAIN_NET_SERV_CALLBACK_DATA_REQUESTED,
WRAPPING_DAP_CHAIN_NET_SERV_CALLBACK_DATA_RESPONSE_SUCCESS,
WRAPPING_DAP_CHAIN_NET_SERV_CALLBACK_DATA_RESPONSE_ERROR,
WRAPPING_DAP_CHAIN_NET_SERV_CALLBACK_DATA_RECEIPT_NEXT_SUCCESS,
WRAPPING_DAP_CHAIN_NET_SERV_CALLBACK_DATA_STREAM_CH_READ,
WRAPPING_DAP_CHAIN_NET_SERV_CALLBACK_DATA_CLIENT_SUCCESS
};
typedef struct _wrapping_dap_chain_net_srv_callbacks_key{
enum _wrapping_dap_chain_net_srv_type_callbacks type;
dap_chain_net_srv_t *srv;
}_wrapping_dap_chain_net_srv_callbacks_key_t;
typedef struct _wrapping_dap_chain_net_srv_callbacks{
_wrapping_dap_chain_net_srv_callbacks_key_t *key;
dap_chain_net_srv_uid_t uid;
PyObject *func;
UT_hash_handle hh;
}_wrapping_dap_chain_net_srv_callbacks_t;
static _wrapping_dap_chain_net_srv_callbacks_t *_s_callbacks = NULL;
void _wrapping_dap_chain_net_srv_del(_wrapping_dap_chain_net_srv_callbacks_t *a_callback){
if (a_callback != NULL) {
HASH_DEL(_s_callbacks, a_callback);
Py_XINCREF(a_callback->func);
}
}
PyObject* _wrapping_dap_chain_net_srv_search(_wrapping_dap_chain_net_srv_callbacks_key_t *a_key){
_wrapping_dap_chain_net_srv_callbacks_t *callbacks = NULL;
HASH_FIND(hh, _s_callbacks, a_key, sizeof(_wrapping_dap_chain_net_srv_callbacks_key_t), callbacks);
if (callbacks == NULL){
return Py_None;
} else {
return callbacks->func;
}
}
_wrapping_dap_chain_net_srv_callbacks_t* _wrapping_dap_chain_net_srv_search_el(_wrapping_dap_chain_net_srv_callbacks_key_t *a_key){
_wrapping_dap_chain_net_srv_callbacks_t *callbacks = NULL;
HASH_FIND(hh, _s_callbacks, a_key, sizeof(_wrapping_dap_chain_net_srv_callbacks_key_t), callbacks);
return callbacks;
}
int _wrapping_dap_chain_net_srv_add(
enum _wrapping_dap_chain_net_srv_type_callbacks a_type,
dap_chain_net_srv_t *a_srv,
dap_chain_net_srv_uid_t a_uid,
PyObject *a_obj_func){
if (PyCallable_Check(a_obj_func)){
_wrapping_dap_chain_net_srv_callbacks_t *callbacks = DAP_NEW(_wrapping_dap_chain_net_srv_callbacks_t);
_wrapping_dap_chain_net_srv_callbacks_key_t *l_key = DAP_NEW(_wrapping_dap_chain_net_srv_callbacks_key_t);
l_key->type = a_type;
l_key->srv = a_srv;
callbacks->key = l_key;
callbacks->uid = a_uid;
callbacks->func = a_obj_func;
Py_XINCREF(a_obj_func);
HASH_ADD(hh, _s_callbacks, key, sizeof(_wrapping_dap_chain_net_srv_callbacks_key_t), callbacks);
return 0;
}
return -1;
}
PyObject *_wrapping_dac_chain_callback_data_t_get_tuple(
dap_chain_net_srv_t *a_srv, //NOT USAGE
uint32_t a_usage_id,
dap_chain_net_srv_client_remote_t * a_srv_client,
const void *a_custom_data,
size_t a_custom_data_size){
PyDapChainNetSrvClientRemoteObject *l_obj_srv_client = NULL;
if (a_srv_client == NULL){
l_obj_srv_client = (PyDapChainNetSrvClientRemoteObject *)Py_None;
} else {
l_obj_srv_client = PyObject_New(PyDapChainNetSrvClientRemoteObject,
&DapChainNetSrvClientObject_DapChainNetSrvClientObjectType);
PyObject_Dir((PyObject *) l_obj_srv_client);
l_obj_srv_client->srv_client_remote = a_srv_client;
}
PyObject *l_obj_custom_data = NULL;
if (a_custom_data == NULL || a_custom_data_size == 0){
l_obj_custom_data = Py_None;
}else{
l_obj_custom_data = PyBytes_FromStringAndSize((char*)a_custom_data_size, (Py_ssize_t)a_custom_data_size);
}
return Py_BuildValue("iOO", l_obj_srv_client, l_obj_custom_data);
}
int _w_dap_chain_callback_data_t_requested(
dap_chain_net_srv_t *a_srv,
uint32_t a_usage_id,
dap_chain_net_srv_client_remote_t * a_srv_client,
const void *a_custom_data,
size_t a_custom_data_size){
_wrapping_dap_chain_net_srv_callbacks_key_t *l_key = DAP_NEW(_wrapping_dap_chain_net_srv_callbacks_key_t);
l_key->srv = a_srv;
l_key->type = WRAPPING_DAP_CHAIN_NET_SERV_CALLBACK_DATA_REQUESTED;
PyObject *l_func = _wrapping_dap_chain_net_srv_search(l_key);
Py_INCREF(l_func);
PyObject *l_arg = _wrapping_dac_chain_callback_data_t_get_tuple(a_srv, a_usage_id, a_srv_client, a_custom_data, a_custom_data_size);
PyObject *result = PyObject_CallObject(l_func, l_arg);
if(result == NULL){
PyErr_Print();
return -1;
}
Py_XINCREF(l_func);
Py_XINCREF(l_arg);
if (!PyLong_Check(result)){
return -1;
}
int res_int = _PyLong_AsInt(result);
return res_int;
}
int _w_dap_chain_callback_data_t_response_success(
dap_chain_net_srv_t *a_srv,
uint32_t a_usage_id,
dap_chain_net_srv_client_remote_t * a_srv_client,
const void *a_custom_data,
size_t a_custom_data_size){
_wrapping_dap_chain_net_srv_callbacks_key_t *l_key = DAP_NEW(_wrapping_dap_chain_net_srv_callbacks_key_t);
l_key->srv = a_srv;
l_key->type = WRAPPING_DAP_CHAIN_NET_SERV_CALLBACK_DATA_RESPONSE_SUCCESS;
PyObject *l_func = _wrapping_dap_chain_net_srv_search(l_key);
Py_INCREF(l_func);
PyObject *l_arg = _wrapping_dac_chain_callback_data_t_get_tuple(a_srv, a_usage_id, a_srv_client, a_custom_data, a_custom_data_size);
PyObject *result = PyObject_CallObject(l_func, l_arg);
if(result == NULL){
PyErr_Print();
return -1;
}
Py_XINCREF(l_func);
Py_XINCREF(l_arg);
if (!PyLong_Check(result)){
return -1;
}
int res_int = _PyLong_AsInt(result);
return res_int;
return 0;
}
int _w_dap_chain_callback_data_t_response_error(
dap_chain_net_srv_t *a_srv,
uint32_t a_usage_id,
dap_chain_net_srv_client_remote_t * a_srv_client,
const void *a_custom_data,
size_t a_custom_data_size){
_wrapping_dap_chain_net_srv_callbacks_key_t *l_key = DAP_NEW(_wrapping_dap_chain_net_srv_callbacks_key_t);
l_key->srv = a_srv;
l_key->type = WRAPPING_DAP_CHAIN_NET_SERV_CALLBACK_DATA_RESPONSE_ERROR;
PyObject *l_func = _wrapping_dap_chain_net_srv_search(l_key);
Py_INCREF(l_func);
PyObject *l_arg = _wrapping_dac_chain_callback_data_t_get_tuple(a_srv, a_usage_id, a_srv_client, a_custom_data, a_custom_data_size);
PyObject *result = PyObject_CallObject(l_func, l_arg);
if(result == NULL){
PyErr_Print();
return -1;
}
Py_XINCREF(l_func);
Py_XINCREF(l_arg);
if (!PyLong_Check(result)){
return -1;
}
int res_int = _PyLong_AsInt(result);
return res_int;
return 0;
}
int _w_dap_chain_callback_data_t_receipt_next_success(
dap_chain_net_srv_t *a_srv,
uint32_t a_usage_id,
dap_chain_net_srv_client_remote_t * a_srv_client,
const void *a_custom_data,
size_t a_custom_data_size){
_wrapping_dap_chain_net_srv_callbacks_key_t *l_key = DAP_NEW(_wrapping_dap_chain_net_srv_callbacks_key_t);
l_key->srv = a_srv;
l_key->type = WRAPPING_DAP_CHAIN_NET_SERV_CALLBACK_DATA_RECEIPT_NEXT_SUCCESS;
PyObject *l_func = _wrapping_dap_chain_net_srv_search(l_key);
Py_INCREF(l_func);
PyObject *l_arg = _wrapping_dac_chain_callback_data_t_get_tuple(a_srv, a_usage_id, a_srv_client, a_custom_data, a_custom_data_size);
PyObject *result = PyObject_CallObject(l_func, l_arg);
if(result == NULL){
PyErr_Print();
return -1;
}
Py_XINCREF(l_func);
Py_XINCREF(l_arg);
if (!PyLong_Check(result)){
return -1;
}
int res_int = _PyLong_AsInt(result);
return res_int;
return 0;
}
int _w_dap_chain_callback_data_t_stream_ch_read(
dap_chain_net_srv_t *a_srv,
uint32_t a_usage_id,
dap_chain_net_srv_client_remote_t * a_srv_client,
const void *a_custom_data,
size_t a_custom_data_size){
return 0;
}
int _w_dap_chain_callback_data_t_client_success(
dap_chain_net_srv_t *a_srv,
uint32_t a_usage_id,
dap_chain_net_srv_client_remote_t * a_srv_client,
const void *a_custom_data,
size_t a_custom_data_size){
return 0;
}
//Conructor
int PyDapChainNetSrv_init(PyDapChainNetSrvObject* self, PyObject *args, PyObject *kwds){
const char *kwlist[] = {
"uid",
"callbackRequested",
"callbackResponseSuccess",
"callbackResponseError",
"callbackReceiptNextSuccess",
NULL};
PyObject *obj_uid;
PyObject *obj_callback_requested;
PyObject *obj_callback_response_success;
PyObject *obj_callback_response_error;
PyObject *obj_callback_receipt_next_success;
if(!PyArg_ParseTupleAndKeywords(args, kwds, "OOOOO", (char **)kwlist,
&obj_uid,
&obj_callback_requested,
&obj_callback_response_success,
&obj_callback_response_error,
&obj_callback_receipt_next_success)) {
return -1;
}
if (
PyDapChainNetSrvUid_Check(obj_uid)||
PyCallable_Check(obj_callback_requested)||
PyCallable_Check(obj_callback_response_success)||
PyCallable_Check(obj_callback_response_error)||
PyCallable_Check(obj_callback_receipt_next_success)) {
self->srv = dap_chain_net_srv_add(
((PyDapChainNetSrvUIDObject*)obj_uid)->net_srv_uid,
_w_dap_chain_callback_data_t_requested,
_w_dap_chain_callback_data_t_response_success,
_w_dap_chain_callback_data_t_response_error,
_w_dap_chain_callback_data_t_receipt_next_success
);
if (self->srv == NULL){
return -3;
}
_wrapping_dap_chain_net_srv_add(
WRAPPING_DAP_CHAIN_NET_SERV_CALLBACK_DATA_REQUESTED,
self->srv,
((PyDapChainNetSrvUIDObject*)self)->net_srv_uid,
obj_callback_requested);
_wrapping_dap_chain_net_srv_add(
WRAPPING_DAP_CHAIN_NET_SERV_CALLBACK_DATA_RESPONSE_SUCCESS,
self->srv,
((PyDapChainNetSrvUIDObject*)self)->net_srv_uid,
obj_callback_response_success);
_wrapping_dap_chain_net_srv_add(
WRAPPING_DAP_CHAIN_NET_SERV_CALLBACK_DATA_RESPONSE_ERROR,
self->srv,
((PyDapChainNetSrvUIDObject*)self)->net_srv_uid,
obj_callback_response_error);
_wrapping_dap_chain_net_srv_add(
WRAPPING_DAP_CHAIN_NET_SERV_CALLBACK_DATA_RECEIPT_NEXT_SUCCESS,
self->srv,
((PyDapChainNetSrvUIDObject*)self)->net_srv_uid,
obj_callback_receipt_next_success);
self->original = true;
return 0;
}
return -2;
}
void PyDapChainNetSrv_dealloc(PyDapChainNetSrvObject* self){
if(self->original == true){
_wrapping_dap_chain_net_srv_callbacks_t *callback = NULL;
_wrapping_dap_chain_net_srv_callbacks_key_t *l_key_requested = DAP_NEW(_wrapping_dap_chain_net_srv_callbacks_key_t);
l_key_requested->type = WRAPPING_DAP_CHAIN_NET_SERV_CALLBACK_DATA_REQUESTED;
l_key_requested->srv = self->srv;
callback = _wrapping_dap_chain_net_srv_search_el(l_key_requested);
_wrapping_dap_chain_net_srv_del(callback);
DAP_FREE(callback);
DAP_FREE(l_key_requested);
_wrapping_dap_chain_net_srv_callbacks_key_t *l_key_success = DAP_NEW(_wrapping_dap_chain_net_srv_callbacks_key_t);;
l_key_success->type = WRAPPING_DAP_CHAIN_NET_SERV_CALLBACK_DATA_RESPONSE_SUCCESS;
l_key_success->srv = self->srv;
callback = _wrapping_dap_chain_net_srv_search_el(l_key_success);
_wrapping_dap_chain_net_srv_del(callback);
DAP_FREE(callback);
DAP_FREE(l_key_requested);
_wrapping_dap_chain_net_srv_callbacks_key_t *l_key_error = DAP_NEW(_wrapping_dap_chain_net_srv_callbacks_key_t);;
l_key_error->type = WRAPPING_DAP_CHAIN_NET_SERV_CALLBACK_DATA_RESPONSE_ERROR;
l_key_error->srv = self->srv;
callback = _wrapping_dap_chain_net_srv_search_el(l_key_error);
_wrapping_dap_chain_net_srv_del(callback);
DAP_FREE(callback);
DAP_FREE(l_key_error);
_wrapping_dap_chain_net_srv_callbacks_key_t *l_key_receipt_new_success = DAP_NEW(_wrapping_dap_chain_net_srv_callbacks_key_t);;
l_key_receipt_new_success->type = WRAPPING_DAP_CHAIN_NET_SERV_CALLBACK_DATA_RECEIPT_NEXT_SUCCESS;
l_key_error->srv = self->srv;
callback = _wrapping_dap_chain_net_srv_search_el(l_key_receipt_new_success);
_wrapping_dap_chain_net_srv_del(callback);
DAP_FREE(callback);
DAP_FREE(l_key_receipt_new_success);
dap_chain_net_srv_del(self->srv);
}
Py_TYPE(self)->tp_free((PyObject*)self);
}
PyObject *wrapping_dap_chain_net_srv_get_uid(PyObject *self, void *closure){
(void)closure;
PyDapChainNetSrvUIDObject *l_obj_srv_uid = PyObject_New(PyDapChainNetSrvUIDObject, &DapChainNetSrvUIDObject_DapChainNetSrvUIDObjectType);
PyObject_Dir((PyObject*)l_obj_srv_uid);
l_obj_srv_uid->net_srv_uid = ((PyDapChainNetSrvObject *)self)->srv->uid;
return (PyObject*)l_obj_srv_uid;
}
PyObject *wrapping_dap_chain_net_srv_get_grace_period(PyObject *self, void *closure){
(void)closure;
return Py_BuildValue("I", ((PyDapChainNetSrvObject*)self)->srv->grace_period);
}
#include "wrapping_dap_chain_net_srv_client.h"
#define LOG_TAG "wrapping_dap_chain_net_srv_client"
#define _TYPE_CALLBACK_CONNECTED 0
#define _TYPE_CALLBACK_DISCONNECTED 1
#define _TYPE_CALLBACK_DELETE 2
void _wrapping_dap_chain_net_srv_client_callback_connected(dap_chain_net_srv_client_t* a_client, void *a_arg){
if(PyCallable_Check(a_arg)) {
PyGILState_STATE state = PyGILState_Ensure();
PyObject *l_call = (PyObject*)a_arg;
PyDapChainNetSrvClientObject *client = PyObject_New(PyDapChainNetSrvClientObject,
&DapChainNetSrvClientObject_DapChainNetSrvClientObjectType);
PyObject_Dir((PyObject *) client);
client->srv_client = a_client;
PyObject *l_args = Py_BuildValue("Oi", client, _TYPE_CALLBACK_CONNECTED);
Py_INCREF(l_args);
Py_INCREF(l_call);
PyEval_CallObject(l_call, l_args);
Py_XDECREF(l_args);
Py_XDECREF(l_call);
PyGILState_Release(state);
}else{
log_it(L_ERROR, "Can't called handler Python in callback connected");
}
}
void _wrapping_dap_chain_net_srv_client_callback_disconnected(dap_chain_net_srv_client_t* a_client, void *a_arg){
if(PyCallable_Check(a_arg)) {
PyGILState_STATE state = PyGILState_Ensure();
PyObject *l_call = (PyObject*)a_arg;
PyDapChainNetSrvClientObject *client = PyObject_New(PyDapChainNetSrvClientObject,
&DapChainNetSrvClientObject_DapChainNetSrvClientObjectType);
PyObject_Dir((PyObject *) client);
client->srv_client = a_client;
PyObject *l_args = Py_BuildValue("Oi", client, _TYPE_CALLBACK_DISCONNECTED);
Py_INCREF(l_args);
Py_INCREF(l_call);
PyEval_CallObject(l_call, l_args);
Py_XDECREF(l_args);
Py_XDECREF(l_call);
PyGILState_Release(state);
}else{
log_it(L_ERROR, "Can't called handler Python in callback disconnected");
}
}
void _wrapping_dap_chain_net_srv_client_callback_deleted(dap_chain_net_srv_client_t* a_client, void *a_arg){
if(PyCallable_Check(a_arg)) {
PyGILState_STATE state = PyGILState_Ensure();
PyObject *l_call = (PyObject*)a_arg;
PyDapChainNetSrvClientObject *client = PyObject_New(PyDapChainNetSrvClientObject,
&DapChainNetSrvClientObject_DapChainNetSrvClientObjectType);
PyObject_Dir((PyObject *) client);
client->srv_client = a_client;
PyObject *l_args = Py_BuildValue("Oi", client, _TYPE_CALLBACK_DELETE);
Py_INCREF(l_args);
Py_INCREF(l_call);
PyEval_CallObject(l_call, l_args);
Py_XDECREF(l_args);
Py_XDECREF(l_call);
PyGILState_Release(state);
}else{
log_it(L_ERROR, "Can't called handler Python in callback delete");
}
}
void _wrapping_dap_chain_net_srv_client_callback_pkt_it(dap_chain_net_srv_client_t* a_client, void *a_arg){}
int PyDapChainNetSrvClient_init(PyDapChainNetSrvClientObject* self, PyObject *args, PyObject *kwds){
const char *kwlist[] = {
"net",
"addr",
"port",
"handler",
NULL
};
PyObject *obj_net, *obj_hander;
const char *addr;
uint16_t port;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "OsH", (char *)kwlist, &obj_net, &addr, &port, &obj_hander)){
return -1;
}
if (!PyCallable_Check(obj_hander)){
return -1;
}
dap_chain_net_srv_client_callbacks_t callbacks = {0};
callbacks.connected = _wrapping_dap_chain_net_srv_client_callback_connected;
callbacks.disconnected = _wrapping_dap_chain_net_srv_client_callback_disconnected;
callbacks.deleted = _wrapping_dap_chain_net_srv_client_callback_deleted;
// callbacks.
dap_chain_net_srv_client_create_n_connect(((PyDapChainNetObject*)obj_net)->chain_net, (char *)addr, port, &callbacks, obj_hander);
return 0;
}
PyObject *wrapping_dap_chain_net_srv_client_write(PyObject *self, PyObject *args){
return Py_None;
}
//#include "wrapping_dap_chain_net_"
#include "wrapping_dap_chain_net_srv_client_remote.h"
#define WRAPPING_DAP_CHAIN_NET_SRV_CLIENT(a) ((dap_chain_net_srv_client_remote_t*)((PyDapPyDapChainNetSrvClientObject*)a)->srv_client)
#define _PyDapChainNetSrvClient(a) ((PyDapChainNetSrvClient*)a)
PyObject *wrapping_dap_chain_net_srv_client_remote_get_ch(PyObject *self, void *closure){
(void)closure;
//TODO
return Py_None;
}
PyObject *wrapping_dap_chain_net_srv_client_remote_get_ts_created(PyObject *self, void *closure){
(void)closure;
return Py_BuildValue("k", ((PyDapChainNetSrvClientRemoteObject*)self)->srv_client_remote->ts_created);
}
PyObject *wrapping_dap_chain_net_srv_client_remote_get_created(PyObject *self, void *closure){
(void)closure;
PyDateTime_IMPORT;
PyObject *l_obj_long_ts = PyLong_FromDouble(((PyDapChainNetSrvClientRemoteObject*)self)->srv_client_remote->ts_created);
PyObject *l_obj_tuple = Py_BuildValue("(O)", l_obj_long_ts);
PyObject *l_obj_dateTime = PyDateTime_FromTimestamp(l_obj_tuple);
return l_obj_dateTime;
}
PyObject *wrapping_dap_chain_net_srv_client_remote_get_stream_worker(PyObject *self, void *closure){
(void)closure;
//TODO
return Py_None;
}
PyObject *wrapping_dap_chain_net_srv_client_remote_get_session_id(PyObject *self, void *closure){
(void)closure;
return Py_BuildValue("i", ((PyDapChainNetSrvClientRemoteObject*)self)->srv_client_remote->session_id);
}
PyObject *wrapping_dap_chain_net_srv_client_remote_get_bytes_received(PyObject *self, void *closure){
(void)closure;
dap_chain_net_srv_client_remote_t *l_client = ((PyDapChainNetSrvClientRemoteObject*)self)->srv_client_remote;
return Py_BuildValue("k", l_client->bytes_received);
}
PyObject *wrapping_dap_chain_net_srv_client_remote_get_bytes_send(PyObject *self, void *closure){
(void)closure;
dap_chain_net_srv_client_remote_t *l_client = ((PyDapChainNetSrvClientRemoteObject*)self)->srv_client_remote;
return Py_BuildValue("k", l_client->bytes_sent);
}
//PyObject *wrapping_dap_chain_net_srv_client_remote_get_bytes_prev(PyObject *self, void *closure){
// (void)closure;
//}
//PyObject *wrapping_dap_chain_net_srv_client_remote_get_bytes_next(PyObject *self, void *closure){
// (void)closure;
// PyDapChain
//}
#include "wrapping_dap_chain_net_srv_common.h"
/* Attribute for ChainNetSrvPrice */
#define WRAPPING_DAP_CHAIN_NET_SRV_PRICE(a) ((PyDapChainNetSrvPriceObject*) a)
PyObject *wrapping_dap_chain_net_srv_get_wallet(PyObject *self, void *closure){
(void)closure;
}
PyObject *wrapping_dap_chain_net_srv_get_net_name(PyObject *self, void *closure){
(void)closure;
return Py_BuildValue("s", WRAPPING_DAP_CHAIN_NET_SRV_PRICE(self)->price.net_name);
}
PyObject *wrapping_dap_chain_net_srv_get_net(PyObject *self, void *closure){
(void)closure;
PyDapChainNetObject *l_obj_net = PyObject_New(PyDapChainNetObject, &DapChainNetObject_DapChainNetObjectType);
PyObject_Dir((PyObject*)l_obj_net);
l_obj_net->chain_net = WRAPPING_DAP_CHAIN_NET_SRV_PRICE(self)->price.net;
return (PyObject*)l_obj_net;
}
PyObject *wrapping_dap_chain_net_srv_get_value_datoshi(PyObject *self, void *closure){
(void)closure;
return Py_BuildValue("k", WRAPPING_DAP_CHAIN_NET_SRV_PRICE(self)->price.value_datoshi);
}
PyObject *wrapping_dap_chain_net_srv_get_token(PyObject *self, void *closure){
(void)closure;
return Py_BuildValue("s", WRAPPING_DAP_CHAIN_NET_SRV_PRICE(self)->price.token);
}
PyObject *wrapping_dap_chain_net_srv_get_units(PyObject *self, void *closure){
(void)closure;
return Py_BuildValue("k", WRAPPING_DAP_CHAIN_NET_SRV_PRICE(self)->price.units);
}
PyObject *wrapping_dap_chain_net_srv_get_units_uid(PyObject *self, void *closure){
(void)closure;
PyDapChainNetSrvPriceUnitUIDObject *l_price_unit_uid = PyObject_New(PyDapChainNetSrvPriceUnitUIDObject, &DapChainNetSrvPriceUnitUIDObject_DapChainNetSrvPriceUnitUIDObjectType);
PyObject_Dir((PyObject*)l_price_unit_uid);
l_price_unit_uid->price_unit_uid = WRAPPING_DAP_CHAIN_NET_SRV_PRICE(self)->price.units_uid;
return (PyObject*)l_price_unit_uid;
}
/* wrapping dap_chain_net_srv_order_direction */
PyObject *DapChainNetSrvOrderDirection_str(PyObject *self){
char *ret;
switch (((PyDapChainNetSrvOrderDirectionObject*)self)->direction) {
case 1:
ret = "SERV_DIR_BUY";
break;
case 2:
ret = "SERV_DIR_SELL";
break;
default:
ret = "SERV_DIR_UNDEFINED";
break;
}
return Py_BuildValue("s", ret);
}
PyObject *wrapping_dap_chain_net_srv_order_direction_get_serv_dir_buy(PyObject *self, PyObject *args){
(void)self;
(void)args;
PyDapChainNetSrvOrderDirectionObject *l_obj = PyObject_New(
PyDapChainNetSrvOrderDirectionObject,
&DapChainNetSrvOrderDirectionObject_DapChainNetSrvOrderDirectionObjectType);
PyObject_Dir((PyObject*)l_obj);
l_obj->direction = SERV_DIR_BUY;
return (PyObject*)l_obj;
}
PyObject *wrapping_dap_chain_net_srv_order_direction_get_serv_dir_sell(PyObject *self, PyObject *args){
(void)self;
(void)args;
PyDapChainNetSrvOrderDirectionObject *l_obj = PyObject_New(
PyDapChainNetSrvOrderDirectionObject,
&DapChainNetSrvOrderDirectionObject_DapChainNetSrvOrderDirectionObjectType);
PyObject_Dir((PyObject*)l_obj);
l_obj->direction = SERV_DIR_SELL;
return (PyObject*)l_obj;
}
PyObject *wrapping_dap_chain_net_srv_order_direction_get_serv_dir_undefined(PyObject *self, PyObject *args){
(void)self;
(void)args;
PyDapChainNetSrvOrderDirectionObject *l_obj = PyObject_New(
PyDapChainNetSrvOrderDirectionObject,
&DapChainNetSrvOrderDirectionObject_DapChainNetSrvOrderDirectionObjectType);
PyObject_Dir((PyObject*)l_obj);
l_obj->direction = SERV_DIR_UNDEFINED;
return (PyObject*)l_obj;
}
#include "wrapping_dap_chain_net_srv_order.h"
#define WRAPPING_DAP_CHAIN_NET_SRV_ORDER(a) ((PyDapChainNetSrvOrderObject*)a)
int PyDapChainNetSrvOrder_init(PyDapChainNetSrvOrderObject *self, PyObject *args, PyObject *kwds){
const char *kwlist[] = {
"net",
"direction",
"srvUID",
"nodeAddr",
"txCondHash",
"price",
"priceUnit",
"priceTicker",
"expires",
"ext",
// "extSize",
// "region",
// "continentNum",
"key",
NULL
};
PyObject *obj_net, *obj_direction, *obj_srv_uid, *obj_node_addr, *obj_tx_cond_hash, *obj_price_unit;
uint64_t price;
char *price_ticker;
unsigned long expires;
PyObject *obj_ext, *obj_key;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "OOOOOkOOO", kwlist, &obj_net, &obj_direction, &obj_srv_uid,
&obj_node_addr, &obj_tx_cond_hash, &price, &obj_price_unit, &price_ticker,
&expires, &obj_ext, &obj_key)){
return -1;
}
void* l_ext = (void*)PyBytes_AsString(obj_ext);
size_t l_ext_size = PyBytes_Size(obj_ext);
dap_chain_net_srv_order_create(
((PyDapChainNetObject*)obj_net)->chain_net,
((PyDapChainNetSrvOrderDirectionObject*)obj_direction)->direction,
((PyDapChainNetSrvUIDObject*)obj_srv_uid)->net_srv_uid,
*((PyDapChainNodeAddrObject*)obj_node_addr)->node_addr,
*((PyDapHashFastObject*)obj_tx_cond_hash)->hash_fast,
price,
((PyDapChainNetSrvPriceUnitUIDObject*)obj_price_unit)->price_unit_uid,
price_ticker,
(time_t)expires,
l_ext,
l_ext_size,
"",
0,
((PyCryptoKeyObject*)obj_key)->key
);
return 0;
}
PyObject *wrapping_dap_chain_net_srv_order_get_version(PyObject *self, void *closure){
(void)closure;
return Py_BuildValue("H", WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order->version);
}
PyObject *wrapping_dap_chain_net_srv_order_get_srv_uid(PyObject *self, void *closure){
(void)closure;
PyDapChainNetSrvUIDObject *obj_srv_uid = PyObject_New(PyDapChainNetSrvUIDObject, &DapChainNetSrvUIDObject_DapChainNetSrvUIDObjectType);
PyObject_Dir((PyObject*)obj_srv_uid);
obj_srv_uid->net_srv_uid = WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order->srv_uid;
return (PyObject*)obj_srv_uid;
}
PyObject *wrapping_dap_chain_net_srv_order_get_srv_direction(PyObject *self, void *closure){
(void)closure;
PyDapChainNetSrvOrderDirectionObject *srv_direction = PyObject_New(PyDapChainNetSrvOrderDirectionObject, &DapChainNetSrvOrderDirectionObject_DapChainNetSrvOrderDirectionObjectType);
PyObject_Dir((PyObject*)srv_direction);
srv_direction->direction = WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order->direction;
return (PyObject*)srv_direction;
}
PyObject *wrapping_dap_chain_net_srv_order_get_srv_node_addr(PyObject *self, void *closure){
(void)closure;
PyDapChainNodeAddrObject *l_obj_node_addr = PyObject_New(PyDapChainNodeAddrObject, &DapChainNodeAddrObject_DapChainNodeAddrObjectType);
PyObject_Dir((PyObject*)l_obj_node_addr);
l_obj_node_addr->node_addr = &WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order->node_addr;
return (PyObject*)l_obj_node_addr;
}
PyObject *wrapping_dap_chain_net_srv_order_get_srv_tx_cond_hash(PyObject *self, void *closure){
(void)closure;
PyDapHashFastObject *l_obj_hf = PyObject_New(PyDapHashFastObject, &DapHashFastObject_DapHashFastObjectType);
PyObject_Dir((PyObject*)l_obj_hf);
l_obj_hf->hash_fast = &WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order->tx_cond_hash;
return (PyObject*)l_obj_hf;
}
PyObject *wrapping_dap_chain_net_srv_order_get_srv_price_unit(PyObject *self, void *closure){
(void)closure;
PyDapChainNetSrvPriceUnitUIDObject *l_obj_srv_price_uid = PyObject_New(PyDapChainNetSrvPriceUnitUIDObject, &DapChainNetSrvPriceUnitUIDObject_DapChainNetSrvPriceUnitUIDObjectType);
PyObject_Dir((PyObject*)l_obj_srv_price_uid);
l_obj_srv_price_uid->price_unit_uid = WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order->price_unit;
return (PyObject*)l_obj_srv_price_uid;
}
PyObject *wrapping_dap_chain_net_srv_order_get_srv_ts_created(PyObject *self, void *closure){
(void)closure;
return Py_BuildValue("k", WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order->ts_created);
}
PyObject *wrapping_dap_chain_net_srv_order_get_srv_ts_expires(PyObject *self, void *closure){
(void)closure;
return Py_BuildValue("k", WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order->ts_expires);
}
PyObject *wrapping_dap_chain_net_srv_order_get_srv_price(PyObject *self, void *closure){
(void)closure;
return Py_BuildValue("k", WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order->price);
}
PyObject *wrapping_dap_chain_net_srv_order_get_srv_price_ticker(PyObject *self, void *closure){
(void)closure;
return Py_BuildValue("s", WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order->price_ticker);
}
//PyObject *wrapping_dap_chain_net_srv_order_get_srv_free_space(PyObject *self, void *closure){}
PyObject *wrapping_dap_chain_net_srv_order_get_srv_ext_size(PyObject *self, void *closure){
(void)closure;
if(WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order == NULL){
return Py_BuildValue("I", 0);
}else{
return Py_BuildValue("I", WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order->ext_size);
}
}
PyObject *wrapping_dap_chain_net_srv_order_get_srv_ext_n_sign(PyObject *self, void *closure) {
(void) closure;
if (WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order != NULL) {
dap_sign_t *l_sign = WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order->ext[WRAPPING_DAP_CHAIN_NET_SRV_ORDER(
self)->order->ext_size];
if (dap_sign_verify_size(l_sign, WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order->ext_size)) {
PyDapSignObject *obj_sign = PyObject_New(PyDapSignObject, &DapSignObject_DapSignObjectType);
PyObject_Dir((PyObject *) obj_sign);
obj_sign->sign = l_sign;
return (PyObject *) obj_sign;
}
return Py_None;
}
return Py_None;
}
//Functions
PyObject *wrapping_dap_chain_net_srv_order_get_size(PyObject *self, PyObject *args){
(void)args;
return Py_BuildValue("n", dap_chain_net_srv_order_get_size(WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order));
}
//PyObject *wrapping_dap_chain_net_srv_order_set_continent_region(PyObject *self, PyObject *args){}
//PyObject *wrapping_dap_chain_net_srv_order_get_continent_region(PyObject *self, PyObject *args){}
//PyObject *wrapping_dap_chain_net_srv_order_get_country_code(PyObject *self, PyObject *args){}
//PyObject *wrapping_dap_chain_net_srv_order_continents_count(PyObject *self, PyObject *args){}
//PyObject *wrapping_dap_chain_net_srv_order_continent_to_str(PyObject *self, PyObject *args){}
//PyObject *wrapping_dap_chain_net_srv_order_continent_to_num(PyObject *self, PyObject *args){}
PyObject *wrapping_dap_chain_net_srv_order_find(PyObject *self, PyObject *args){
(void)self;
PyObject *obj_net;
PyObject *obj_order_hash;
if (!PyArg_ParseTuple(args, "OO", &obj_net, &obj_order_hash)){
PyErr_SetString(PyExc_ValueError, "This function must take two arguments. ");
return NULL;
}
dap_chain_net_srv_order_t *l_order = NULL;
if(!PyDapChainNet_Check(obj_net)){
PyErr_SetString(PyExc_ValueError, "As the first argument, this function takes "
"an instance of an object of type ChainNet.");
return NULL;
}
if (PyUnicode_Check(obj_order_hash)){
const char *l_str = PyUnicode_AsUTF8(obj_order_hash);
l_order = dap_chain_net_srv_order_find_by_hash_str(((PyDapChainNetObject*)obj_net)->chain_net, l_str);
if (l_order == NULL){
return Py_None;
}
PyDapChainNetSrvOrderObject *l_obj_order = PyObject_New(PyDapChainNetSrvOrderObject, &DapChainNetSrvOrderObject_DapChainNetSrvOrderObjectType);
PyObject_Dir((PyObject *)l_obj_order);
l_obj_order->order = l_order;
return (PyObject*)l_obj_order;
}
if (PyDapHashFast_Check(obj_order_hash)){
l_order = dap_chain_net_srv_order_find_by_hash(((PyDapChainNetObject*)obj_net)->chain_net,
((PyDapHashFastObject*)obj_order_hash)->hash_fast);
if (l_order == NULL){
return Py_None;
}
PyDapChainNetSrvOrderObject *l_obj_order = PyObject_New(PyDapChainNetSrvOrderObject, &DapChainNetSrvOrderObject_DapChainNetSrvOrderObjectType);
PyObject_Dir((PyObject *)l_obj_order);
l_obj_order->order = l_order;
return (PyObject*)l_obj_order;
}
PyErr_SetString(PyExc_ValueError, "An invalid argument type was passed to this function. "
"This function can take a string or an object of the HashFast type "
"as the second argument. ");
return NULL;
}
PyObject *wrapping_dap_chain_net_srv_order_delete(PyObject *self, PyObject *args){
(void)self;
PyObject *obj_net;
PyObject *obj_order_hash;
if (!PyArg_ParseTuple(args, "OO", &obj_net, &obj_order_hash)){
PyErr_SetString(PyExc_ValueError, "This function must take two arguments. ");
return NULL;
}
if(!PyDapChainNet_Check(obj_net)){
PyErr_SetString(PyExc_ValueError, "As the first argument, this function takes "
"an instance of an object of type ChainNet.");
return NULL;
}
int res = -1;
if (PyUnicode_Check(obj_order_hash)){
const char *l_str = PyUnicode_AsUTF8(obj_order_hash);
res = dap_chain_net_srv_order_delete_by_hash_str(((PyDapChainNetObject*)obj_net)->chain_net,
l_str);
return Py_BuildValue("i", res);
}
if (PyDapHashFast_Check(obj_order_hash)) {
res =dap_chain_net_srv_order_delete_by_hash(((PyDapChainNetObject*)obj_net)->chain_net,
((PyDapHashFastObject*)obj_order_hash)->hash_fast);
return Py_BuildValue("i", res);
}
PyErr_SetString(PyExc_ValueError, "An invalid argument type was passed to this function. "
"This function can take a string or an object of the HashFast type "
"as the second argument. ");
return NULL;
}
PyObject *wrapping_dap_chain_net_srv_order_find_all_by(PyObject *self, PyObject *args){}
PyObject *wrapping_dap_chain_net_srv_order_save(PyObject *self, PyObject *args){
PyObject *obj_net;
if(!PyArg_ParseTuple(args, "O", &obj_net)){
PyErr_SetString(PyExc_ValueError, "This function must take one arguments. ");
return NULL;
}
if(!PyDapChainNet_Check(obj_net)){
PyErr_SetString(PyExc_ValueError, "As the first argument, this function takes "
"an instance of an object of type ChainNet.");
return NULL;
}
int res = -1;
res = dap_chain_net_srv_order_save(((PyDapChainNetObject *) self)->chain_net,
WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order);
return Py_BuildValue("i", res);
}
PyObject *wrapping_dap_chain_net_srv_order_get_gdb_group(PyObject *self, PyObject *args){
(void)self;
PyObject *obj_net;
if(!PyArg_ParseTuple(args, "O", &obj_net)){
PyErr_SetString(PyExc_ValueError, "This function must take one arguments. ");
return NULL;
}
if(!PyDapChainNet_Check(obj_net)){
PyErr_SetString(PyExc_ValueError, "As the first argument, this function takes "
"an instance of an object of type ChainNet.");
return NULL;
}
return Py_BuildValue("s", dap_chain_net_srv_order_get_gdb_group(((PyDapChainNetObject*)obj_net)->chain_net));
}
PyObject *wrapping_dap_chain_net_srv_order_get_nodelist_group(PyObject *self, PyObject *args){
(void)self;
PyObject *obj_net;
if(!PyArg_ParseTuple(args, "O", &obj_net)){
PyErr_SetString(PyExc_ValueError, "This function must take one arguments. ");
return NULL;
}
if(!PyDapChainNet_Check(obj_net)){
PyErr_SetString(PyExc_ValueError, "As the first argument, this function takes "
"an instance of an object of type ChainNet.");
return NULL;
}
return Py_BuildValue("s",
dap_chain_net_srv_order_get_nodelist_group(((PyDapChainNetObject*)obj_net)->chain_net));
}