From bdfea1837812370683f03e88f2f37bbb1961561a Mon Sep 17 00:00:00 2001
From: "roman.padenkov" <roman.padenkov@demlabs.net>
Date: Thu, 14 Dec 2023 20:50:36 +0700
Subject: [PATCH 1/4] ...

---
 .../service/stake/dap_chain_net_srv_stake_pos_delegate.c  | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c b/modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c
index 8d360c663..cf1fa194d 100644
--- a/modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c
+++ b/modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c
@@ -1704,6 +1704,14 @@ static int s_cli_srv_stake(int a_argc, char **a_argv, char **a_str_reply)
             DAP_DELETE(l_decree);
             dap_cli_server_cmd_set_reply_text(a_str_reply, "Approve decree %s successfully created",
                                               l_decree_hash_str);
+
+            assert(s_srv_stake);
+            dap_chain_net_srv_stake_item_t *l_stake = NULL;
+            l_stake = DAP_NEW_Z(dap_chain_net_srv_stake_item_t);
+            l_stake->net = l_net;
+            l_stake->tx_hash = l_tx_hash;
+            HASH_ADD(ht, s_srv_stake->tx_itemlist, tx_hash, sizeof(dap_chain_hash_fast_t), l_stake);
+
             DAP_DELETE(l_decree_hash_str);
         } break;
         case CMD_LIST: {
-- 
GitLab


From 1aa8477fc6e7c4265617365302235af902d1e4ab Mon Sep 17 00:00:00 2001
From: "roman.padenkov" <roman.padenkov@demlabs.net>
Date: Fri, 15 Dec 2023 20:05:25 +0700
Subject: [PATCH 2/4] fixed order check in validator

---
 .../channel/chain-net/dap_stream_ch_chain_net.c   | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/modules/channel/chain-net/dap_stream_ch_chain_net.c b/modules/channel/chain-net/dap_stream_ch_chain_net.c
index 4c48527ab..9a933bd67 100644
--- a/modules/channel/chain-net/dap_stream_ch_chain_net.c
+++ b/modules/channel/chain-net/dap_stream_ch_chain_net.c
@@ -356,6 +356,8 @@ void s_stream_ch_packet_in(dap_stream_ch_t* a_ch, void* a_arg)
                         uint256_t l_price_min = {};
                         uint256_t l_price_max = {};
                         uint8_t flags = 0;
+                        dap_chain_node_addr_t l_cur_node_addr = { 0 };
+                        l_cur_node_addr.uint64 = dap_chain_net_get_cur_addr_int(l_net);
 
                         if(enc_key_pvt)
                         {
@@ -383,7 +385,18 @@ void s_stream_ch_packet_in(dap_stream_ch_t* a_ch, void* a_arg)
 
                         dap_chain_net_srv_order_find_all_by(l_net,SERV_DIR_UNDEFINED,l_uid,
                                                            l_price_unit,NULL,l_price_min,l_price_max,&l_orders,&l_orders_num);
-                        flags = l_orders_num ? flags | F_ORDR : flags & ~F_ORDR;
+                        size_t l_orders_size = 0;
+                        for (size_t i = 0; i< l_orders_num; i++){
+                            dap_chain_net_srv_order_t *l_order =(dap_chain_net_srv_order_t *) (((byte_t*) l_orders) + l_orders_size);
+                            l_orders_size += dap_chain_net_srv_order_get_size(l_order);
+                            if(l_order->node_addr.uint64 == l_cur_node_addr.uint64)
+                            {
+                                flags = flags | F_ORDR;
+                                break;
+                            }
+                        }
+                        if (l_orders_num)
+                            DAP_DELETE(l_orders);
                         bool auto_online = dap_config_get_item_bool_default( g_config, "general", "auto_online", false );
                         bool auto_update = false;
                         if((system("systemctl status cellframe-updater.service") == 768) && (system("systemctl status cellframe-updater.timer") == 0))
-- 
GitLab


From a7c322d743db1df82f3c80a7137b72ac960abe23 Mon Sep 17 00:00:00 2001
From: "roman.padenkov" <roman.padenkov@demlabs.net>
Date: Tue, 19 Dec 2023 18:23:28 +0700
Subject: [PATCH 3/4] ...

---
 .../service/stake/dap_chain_net_srv_stake_pos_delegate.c   | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c b/modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c
index cf1fa194d..eb5cf050a 100644
--- a/modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c
+++ b/modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c
@@ -1705,13 +1705,6 @@ static int s_cli_srv_stake(int a_argc, char **a_argv, char **a_str_reply)
             dap_cli_server_cmd_set_reply_text(a_str_reply, "Approve decree %s successfully created",
                                               l_decree_hash_str);
 
-            assert(s_srv_stake);
-            dap_chain_net_srv_stake_item_t *l_stake = NULL;
-            l_stake = DAP_NEW_Z(dap_chain_net_srv_stake_item_t);
-            l_stake->net = l_net;
-            l_stake->tx_hash = l_tx_hash;
-            HASH_ADD(ht, s_srv_stake->tx_itemlist, tx_hash, sizeof(dap_chain_hash_fast_t), l_stake);
-
             DAP_DELETE(l_decree_hash_str);
         } break;
         case CMD_LIST: {
-- 
GitLab


From 3188c9ecf70bbc53a17dfbc504bb2a2b9c6e9dd7 Mon Sep 17 00:00:00 2001
From: "roman.padenkov" <roman.padenkov@demlabs.net>
Date: Tue, 26 Dec 2023 20:24:09 +0700
Subject: [PATCH 4/4] change some out messages

---
 .../service/stake/dap_chain_net_srv_stake_pos_delegate.c    | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c b/modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c
index eb5cf050a..cdf1556ae 100644
--- a/modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c
+++ b/modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c
@@ -536,7 +536,7 @@ dap_chain_datum_decree_t *dap_chain_net_srv_stake_decree_approve(dap_chain_net_t
     dap_chain_tx_out_cond_t *l_tx_out_cond = dap_chain_datum_tx_out_cond_get(l_cond_tx,
                                                   DAP_CHAIN_TX_OUT_COND_SUBTYPE_SRV_STAKE_POS_DELEGATE, &l_prev_cond_idx);
     if (!l_tx_out_cond) {
-        log_it(L_WARNING, "Requested conditional transaction has no requires conditional output");
+        log_it(L_CRITICAL, "Requested conditional transaction has no requires conditional output");
         return NULL;
     }
     dap_hash_fast_t l_spender_hash = { };
@@ -704,7 +704,7 @@ static dap_chain_datum_tx_t *s_stake_tx_invalidate(dap_chain_net_t *a_net, dap_h
     dap_chain_tx_out_cond_t *l_tx_out_cond = dap_chain_datum_tx_out_cond_get(l_cond_tx,
                                                   DAP_CHAIN_TX_OUT_COND_SUBTYPE_SRV_STAKE_POS_DELEGATE, &l_prev_cond_idx);
     if (!l_tx_out_cond) {
-        log_it(L_WARNING, "Requested conditional transaction has no requires conditional output");
+        log_it(L_CRITICAL, "Requested conditional transaction has no requires conditional output");
         return NULL;
     }
     dap_hash_fast_t l_spender_hash = { };
@@ -809,7 +809,7 @@ static dap_chain_datum_decree_t *s_stake_decree_invalidate(dap_chain_net_t *a_ne
     dap_chain_tx_out_cond_t *l_tx_out_cond = dap_chain_datum_tx_out_cond_get(l_cond_tx,
                                                   DAP_CHAIN_TX_OUT_COND_SUBTYPE_SRV_STAKE_POS_DELEGATE, &l_prev_cond_idx);
     if (!l_tx_out_cond) {
-        log_it(L_WARNING, "Requested conditional transaction has no requires conditional output");
+        log_it(L_CRITICAL, "Requested conditional transaction has no requires conditional output");
         return NULL;
     }
 
-- 
GitLab