Skip to content
Snippets Groups Projects
Commit 94ff5a32 authored by Dmitriy A. Gerasimov's avatar Dmitriy A. Gerasimov
Browse files

[+] Single tx search function

parent c285d7ca
No related branches found
No related tags found
No related merge requests found
...@@ -1617,3 +1617,42 @@ void dap_chain_net_proc_datapool (dap_chain_net_t * a_net) ...@@ -1617,3 +1617,42 @@ void dap_chain_net_proc_datapool (dap_chain_net_t * a_net)
{ {
} }
/**
* @brief dap_chain_net_tx_get_by_hash
* @param a_net
* @param a_tx_hash
* @param a_search_type
* @return
*/
dap_chain_datum_tx_t * dap_chain_net_get_tx_by_hash(dap_chain_net_t * a_net, dap_chain_hash_fast_t * a_tx_hash,
dap_chain_net_tx_search_type_t a_search_type)
{
dap_ledger_t * l_ledger = dap_chain_ledger_by_net_name( a_net->pub.name );
dap_chain_datum_tx_t * l_tx = NULL;
switch (a_search_type) {
case TX_SEARCH_TYPE_NET:
case TX_SEARCH_TYPE_CELL:
case TX_SEARCH_TYPE_LOCAL:{
if ( ! l_tx ){
// pass all chains
for ( dap_chain_t * l_chain = a_net->pub.chains; l_chain; l_chain = l_chain->next){
if ( l_chain->callback_tx_find_by_hash ){
// try to find transaction in chain ( inside shard )
l_tx = l_chain->callback_tx_find_by_hash( l_chain, a_tx_hash );
if (l_tx)
break;
}
}
}
}break;
case TX_SEARCH_TYPE_NET_UNSPENT:
case TX_SEARCH_TYPE_CELL_UNSPENT:{
l_tx = dap_chain_ledger_tx_find_by_hash( l_ledger, a_tx_hash );
}break;
}
return l_tx;
}
...@@ -108,6 +108,21 @@ dap_chain_cell_id_t * dap_chain_net_get_cur_cell( dap_chain_net_t * l_net); ...@@ -108,6 +108,21 @@ dap_chain_cell_id_t * dap_chain_net_get_cur_cell( dap_chain_net_t * l_net);
void dap_chain_net_links_connect(dap_chain_net_t * a_net); void dap_chain_net_links_connect(dap_chain_net_t * a_net);
typedef enum dap_chain_net_tx_search_type {
/// Search local, in memory, possible load data from drive to memory
TX_SEARCH_TYPE_LOCAL,
/// Do the request to the network if its not full node, search inside shard
TX_SEARCH_TYPE_CELL,
/// Do the request for unspent txs in cell
TX_SEARCH_TYPE_CELL_UNSPENT,
/// Do the search in whole network and request tx from others cells if need
TX_SEARCH_TYPE_NET,
/// Do the search in whole network but search only unspent
TX_SEARCH_TYPE_NET_UNSPENT
}dap_chain_net_tx_search_type_t;
dap_chain_datum_tx_t * dap_chain_net_get_tx_by_hash(dap_chain_net_t * a_net, dap_chain_hash_fast_t * a_tx_hash,
dap_chain_net_tx_search_type_t a_search_type);
/** /**
* @brief dap_chain_net_get_gdb_group_mempool * @brief dap_chain_net_get_gdb_group_mempool
......
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