Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
python-cellframe
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
2
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cellframe
python-cellframe
Commits
3840aa50
Commit
3840aa50
authored
5 months ago
by
ArxysMarks
Browse files
Options
Downloads
Patches
Plain Diff
added atom confirmed notifier
parent
22a006fb
No related branches found
Branches containing commit
No related tags found
2 merge requests
!430
Develop port 02 12
,
!418
added atom confirmed notifier
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/cellframe-sdk/chain/include/libdap-chain-python.h
+1
-0
1 addition, 0 deletions
modules/cellframe-sdk/chain/include/libdap-chain-python.h
modules/cellframe-sdk/chain/src/libdap-chain-python.c
+71
-0
71 additions, 0 deletions
modules/cellframe-sdk/chain/src/libdap-chain-python.c
with
72 additions
and
0 deletions
modules/cellframe-sdk/chain/include/libdap-chain-python.h
+
1
−
0
View file @
3840aa50
...
@@ -45,6 +45,7 @@ PyObject *dap_chain_python_atom_iter_get_next(PyObject *self, PyObject *args);
...
@@ -45,6 +45,7 @@ PyObject *dap_chain_python_atom_iter_get_next(PyObject *self, PyObject *args);
PyObject
*
dap_chain_python_atom_iter_get_dag
(
PyObject
*
self
,
PyObject
*
args
);
PyObject
*
dap_chain_python_atom_iter_get_dag
(
PyObject
*
self
,
PyObject
*
args
);
PyObject
*
dap_chain_python_add_mempool_notify_callback
(
PyObject
*
self
,
PyObject
*
args
);
PyObject
*
dap_chain_python_add_mempool_notify_callback
(
PyObject
*
self
,
PyObject
*
args
);
PyObject
*
dap_chain_net_add_atom_notify_callback
(
PyObject
*
self
,
PyObject
*
args
);
PyObject
*
dap_chain_net_add_atom_notify_callback
(
PyObject
*
self
,
PyObject
*
args
);
PyObject
*
dap_chain_atom_confirmed_notify_add_py
(
PyObject
*
self
,
PyObject
*
args
);
PyObject
*
dap_chain_python_atom_find_by_hash
(
PyObject
*
self
,
PyObject
*
args
);
PyObject
*
dap_chain_python_atom_find_by_hash
(
PyObject
*
self
,
PyObject
*
args
);
PyObject
*
dap_chain_python_get_atom_count
(
PyObject
*
self
,
PyObject
*
args
);
PyObject
*
dap_chain_python_get_atom_count
(
PyObject
*
self
,
PyObject
*
args
);
...
...
This diff is collapsed.
Click to expand it.
modules/cellframe-sdk/chain/src/libdap-chain-python.c
+
71
−
0
View file @
3840aa50
...
@@ -34,6 +34,7 @@ static PyMethodDef DapChainMethods[] = {
...
@@ -34,6 +34,7 @@ static PyMethodDef DapChainMethods[] = {
{
"getCSName"
,
(
PyCFunction
)
dap_chain_python_get_cs_name
,
METH_NOARGS
,
""
},
{
"getCSName"
,
(
PyCFunction
)
dap_chain_python_get_cs_name
,
METH_NOARGS
,
""
},
{
"getNet"
,
(
PyCFunction
)
dap_chain_python_get_net
,
METH_NOARGS
,
""
},
{
"getNet"
,
(
PyCFunction
)
dap_chain_python_get_net
,
METH_NOARGS
,
""
},
{
"configGetItem"
,
(
PyCFunction
)
dap_chain_python_get_config_item
,
METH_VARARGS
,
""
},
{
"configGetItem"
,
(
PyCFunction
)
dap_chain_python_get_config_item
,
METH_VARARGS
,
""
},
{
"addAtomConfirmedNotify"
,
(
PyCFunction
)
dap_chain_atom_confirmed_notify_add_py
,
METH_VARARGS
,
"Add a callback for confirmed atoms"
},
{}
{}
};
};
...
@@ -315,6 +316,43 @@ static void _wrapping_dap_chain_atom_notify_handler(void * a_arg, dap_chain_t *a
...
@@ -315,6 +316,43 @@ static void _wrapping_dap_chain_atom_notify_handler(void * a_arg, dap_chain_t *a
PyGILState_Release
(
state
);
PyGILState_Release
(
state
);
}
}
static
void
_wrapping_dap_chain_atom_confirmed_notify_handler
(
void
*
a_arg
,
dap_chain_t
*
a_chain
,
dap_chain_cell_id_t
a_id
,
dap_hash_fast_t
*
a_hash
,
void
*
a_atom
,
size_t
a_atom_size
){
if
(
!
a_arg
)
{
return
;
}
_wrapping_chain_mempool_notify_callback_t
*
l_callback
=
(
_wrapping_chain_mempool_notify_callback_t
*
)
a_arg
;
PyGILState_STATE
state
=
PyGILState_Ensure
();
dap_chain_atom_ptr_t
l_atom
=
(
dap_chain_atom_ptr_t
)
a_atom
;
PyChainAtomObject
*
l_atom_obj
=
NULL
;
if
(
l_atom
)
{
l_atom_obj
=
PyObject_New
(
PyChainAtomObject
,
&
DapChainAtomPtrObjectType
);
l_atom_obj
->
atom
=
l_atom
;
l_atom_obj
->
atom_size
=
a_atom_size
;
PyObject
*
l_args
=
Py_BuildValue
(
"OO"
,
l_atom_obj
,
l_callback
->
arg
);
log_it
(
L_DEBUG
,
"Call atom confirmed notifier for chain %s with atom size %zd"
,
a_chain
->
name
,
a_atom_size
);
PyObject
*
result
=
PyObject_CallObject
(
l_callback
->
func
,
l_args
);
if
(
!
result
)
{
python_error_in_log_it
(
LOG_TAG
);
}
Py_XDECREF
(
result
);
Py_DECREF
(
l_args
);
Py_DECREF
(
l_atom_obj
);
}
else
{
PyObject
*
l_args
=
Py_BuildValue
(
"OO"
,
Py_None
,
l_callback
->
arg
);
PyObject
*
result
=
PyObject_CallObject
(
l_callback
->
func
,
l_args
);
if
(
!
result
)
{
python_error_in_log_it
(
LOG_TAG
);
}
Py_XDECREF
(
result
);
Py_DECREF
(
l_args
);
}
PyGILState_Release
(
state
);
}
/**
/**
* @brief dap_chain_python_add_mempool_notify_callback
* @brief dap_chain_python_add_mempool_notify_callback
* @param self
* @param self
...
@@ -379,6 +417,39 @@ PyObject *dap_chain_net_add_atom_notify_callback(PyObject *self, PyObject *args)
...
@@ -379,6 +417,39 @@ PyObject *dap_chain_net_add_atom_notify_callback(PyObject *self, PyObject *args)
Py_RETURN_NONE
;
Py_RETURN_NONE
;
}
}
/**
* @brief dap_chain_atom_confirmed_notify_add_py
* @param self
* @param args
* @return
*/
PyObject
*
dap_chain_atom_confirmed_notify_add_py
(
PyObject
*
self
,
PyObject
*
args
)
{
dap_chain_t
*
l_chain
=
((
PyDapChainObject
*
)
self
)
->
chain_t
;
PyObject
*
obj_func
;
PyObject
*
obj_arg
;
if
(
!
PyArg_ParseTuple
(
args
,
"OO"
,
&
obj_func
,
&
obj_arg
))
{
PyErr_SetString
(
PyExc_AttributeError
,
"Arguments must be a callable and an argument"
);
return
NULL
;
}
if
(
!
PyCallable_Check
(
obj_func
))
{
PyErr_SetString
(
PyExc_AttributeError
,
"First argument must be a callable function"
);
return
NULL
;
}
_wrapping_chain_mempool_notify_callback_t
*
l_callback
=
DAP_NEW_Z
(
_wrapping_chain_mempool_notify_callback_t
);
if
(
!
l_callback
)
{
log_it
(
L_CRITICAL
,
"Memory allocation error"
);
return
NULL
;
}
l_callback
->
func
=
obj_func
;
l_callback
->
arg
=
obj_arg
;
Py_INCREF
(
obj_func
);
Py_INCREF
(
obj_arg
);
dap_chain_atom_confirmed_notify_add
(
l_chain
,
_wrapping_dap_chain_atom_confirmed_notify_handler
,
l_callback
);
Py_RETURN_NONE
;
}
/**
/**
* @brief dap_chain_python_atom_find_by_hash
* @brief dap_chain_python_atom_find_by_hash
* @param self
* @param self
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment