diff options
author | Joseph <Joseph.xu@efrei.net> | 2022-12-21 08:06:47 -0500 |
---|---|---|
committer | Joseph <Joseph.xu@efrei.net> | 2022-12-21 08:06:47 -0500 |
commit | f2b104192564711c48d7e7e9c264e2a72043e192 (patch) | |
tree | 39f1c6263ebe13a4b3cbd75a2ea88a2a3b3ff9e9 | |
parent | 2030d6491005cd6e714b4a4ef40b13a7dc1bdc74 (diff) |
fixing some bugs
3 files changed, 12 insertions, 31 deletions
diff --git a/src/exchangedb/exchange_do_batch4_reserves_in_insert.sql b/src/exchangedb/exchange_do_batch4_reserves_in_insert.sql index bf3b2eaa2..edbbe100d 100644 --- a/src/exchangedb/exchange_do_batch4_reserves_in_insert.sql +++ b/src/exchangedb/exchange_do_batch4_reserves_in_insert.sql @@ -150,27 +150,24 @@ BEGIN THEN out_reserve_found = FALSE; ruuid = i.reserve_uuid; - k = k+1; END IF; IF in2_reserve_pub = i.reserve_pub THEN out_reserve_found2 = FALSE; ruuid2 = i.reserve_uuid; - k=k+1; END IF; IF in3_reserve_pub = i.reserve_pub THEN out_reserve_found3 = FALSE; ruuid3 = i.reserve_uuid; - k=k+1; END IF; IF in4_reserve_pub = i.reserve_pub THEN out_reserve_found4 = FALSE; ruuid4 = i.reserve_uuid; - k=k+1; END IF; END IF; + k=k+1; END LOOP; CLOSE curs_reserve_exist; IF out_reserve_found @@ -236,24 +233,21 @@ BEGIN IF in_reserve_pub = i.reserve_pub THEN transaction_duplicate = TRUE; - k=k+1; END IF; IF in2_reserve_pub = i.reserve_pub THEN transaction_duplicate2 = TRUE; - k=k+1; END IF; IF in3_reserve_pub = i.reserve_pub THEN transaction_duplicate3 = TRUE; - k=k+1; END IF; IF in4_reserve_pub = i.reserve_pub THEN transaction_duplicate4 = TRUE; - k=k+1; END IF; END IF; + k=k+1; END LOOP; CLOSE curs_transaction_exist; diff --git a/src/exchangedb/exchange_do_batch8_reserves_in_insert.sql b/src/exchangedb/exchange_do_batch8_reserves_in_insert.sql index ab11e3806..fc735adda 100644 --- a/src/exchangedb/exchange_do_batch8_reserves_in_insert.sql +++ b/src/exchangedb/exchange_do_batch8_reserves_in_insert.sql @@ -248,52 +248,44 @@ BEGIN THEN out_reserve_found = FALSE; ruuid = i.reserve_uuid; - k = k+1; END IF; IF in2_reserve_pub = i.reserve_pub THEN out_reserve_found2 = FALSE; ruuid2 = i.reserve_uuid; - k=k+1; END IF; IF in3_reserve_pub = i.reserve_pub THEN out_reserve_found3 = FALSE; ruuid3 = i.reserve_uuid; - k=k+1; END IF; IF in4_reserve_pub = i.reserve_pub THEN out_reserve_found4 = FALSE; ruuid4 = i.reserve_uuid; - k=k+1; END IF; IF in5_reserve_pub = i.reserve_pub THEN out_reserve_found5 = FALSE; ruuid5 = i.reserve_uuid; - k=k+1; END IF; IF in6_reserve_pub = i.reserve_pub THEN out_reserve_found6 = FALSE; ruuid6 = i.reserve_uuid; - k=k+1; END IF; IF in7_reserve_pub = i.reserve_pub THEN out_reserve_found7 = FALSE; ruuid7 = i.reserve_uuid; - k=k+1; END IF; IF in8_reserve_pub = i.reserve_pub THEN out_reserve_found8 = FALSE; ruuid8 = i.reserve_uuid; - k=k+1; END IF; END IF; - + k=k+1; END LOOP; CLOSE curs_reserve_existed; @@ -397,46 +389,38 @@ BEGIN IF in_reserve_pub = r.reserve_pub THEN transaction_duplicate = TRUE; - k=k+1; END IF; IF in2_reserve_pub = r.reserve_pub THEN transaction_duplicate2 = TRUE; - k=k+1; END IF; IF in3_reserve_pub = r.reserve_pub THEN transaction_duplicate3 = TRUE; - k=k+1; END IF; IF in4_reserve_pub = r.reserve_pub THEN transaction_duplicate4 = TRUE; - k=k+1; END IF; IF in5_reserve_pub = r.reserve_pub THEN transaction_duplicate5 = TRUE; - k=k+1; END IF; IF in6_reserve_pub = r.reserve_pub THEN transaction_duplicate6 = TRUE; - k=k+1; END IF; IF in7_reserve_pub = r.reserve_pub THEN transaction_duplicate7 = TRUE; - k=k+1; END IF; IF in8_reserve_pub = r.reserve_pub THEN transaction_duplicate8 = TRUE; - k=k+1; END IF; END IF; - + k=k+1; END LOOP; CLOSE curs_transaction_existed; diff --git a/src/exchangedb/exchange_do_batch_reserves_in_insert.sql b/src/exchangedb/exchange_do_batch_reserves_in_insert.sql index ef4c84aa7..d7efe01b9 100644 --- a/src/exchangedb/exchange_do_batch_reserves_in_insert.sql +++ b/src/exchangedb/exchange_do_batch_reserves_in_insert.sql @@ -34,6 +34,9 @@ LANGUAGE plpgsql AS $$ BEGIN +ruuid= 0; +out_reserve_found = TRUE; +transaction_duplicate= FALSE; --SIMPLE INSERT ON CONFLICT DO NOTHING INSERT INTO wire_targets (wire_target_h_payto @@ -56,9 +59,7 @@ BEGIN ,in_expiration_date ,in_gc_date) ON CONFLICT DO NOTHING - RETURNING reserve_uuid INTO ruuid; - PERFORM pg_notify(in_notify, NULL); - + RETURNING reserves.reserve_uuid INTO ruuid; IF FOUND THEN -- We made a change, so the reserve did not previously exist. @@ -68,7 +69,7 @@ BEGIN out_reserve_found = TRUE; /*RESERVE EXISTED BUT WE DO NOT KNOW ANY INFORMATIONS ABOUT TRANSACTION, RETURN*/ RETURN; END IF; - + PERFORM pg_notify(in_notify, NULL); INSERT INTO reserves_in (reserve_pub ,wire_reference @@ -91,7 +92,9 @@ BEGIN transaction_duplicate = FALSE; /*HAPPY PATH THERE IS NO DUPLICATE TRANS AND NEW RESERVE*/ RETURN; ELSE - transaction_duplicate = TRUE; /*HAPPY PATH IF THERE IS A DUPLICATE TRANS WE JUST NEED TO ROLLBACK COMPLAIN*/ + transaction_duplicate = TRUE; + /*HAPPY PATH IF THERE IS A DUPLICATE TRANS WE JUST NEED TO ROLLBACK COMPLAIN*/ RETURN; END IF; + RETURN; END $$; |