fixing some bugs

This commit is contained in:
Joseph 2022-12-21 08:06:47 -05:00
parent 2030d64910
commit f2b1041925
No known key found for this signature in database
GPG Key ID: E709789D3076B5CC
3 changed files with 12 additions and 31 deletions

View File

@ -150,27 +150,24 @@ BEGIN
THEN THEN
out_reserve_found = FALSE; out_reserve_found = FALSE;
ruuid = i.reserve_uuid; ruuid = i.reserve_uuid;
k = k+1;
END IF; END IF;
IF in2_reserve_pub = i.reserve_pub IF in2_reserve_pub = i.reserve_pub
THEN THEN
out_reserve_found2 = FALSE; out_reserve_found2 = FALSE;
ruuid2 = i.reserve_uuid; ruuid2 = i.reserve_uuid;
k=k+1;
END IF; END IF;
IF in3_reserve_pub = i.reserve_pub IF in3_reserve_pub = i.reserve_pub
THEN THEN
out_reserve_found3 = FALSE; out_reserve_found3 = FALSE;
ruuid3 = i.reserve_uuid; ruuid3 = i.reserve_uuid;
k=k+1;
END IF; END IF;
IF in4_reserve_pub = i.reserve_pub IF in4_reserve_pub = i.reserve_pub
THEN THEN
out_reserve_found4 = FALSE; out_reserve_found4 = FALSE;
ruuid4 = i.reserve_uuid; ruuid4 = i.reserve_uuid;
k=k+1;
END IF; END IF;
END IF; END IF;
k=k+1;
END LOOP; END LOOP;
CLOSE curs_reserve_exist; CLOSE curs_reserve_exist;
IF out_reserve_found IF out_reserve_found
@ -236,24 +233,21 @@ BEGIN
IF in_reserve_pub = i.reserve_pub IF in_reserve_pub = i.reserve_pub
THEN THEN
transaction_duplicate = TRUE; transaction_duplicate = TRUE;
k=k+1;
END IF; END IF;
IF in2_reserve_pub = i.reserve_pub IF in2_reserve_pub = i.reserve_pub
THEN THEN
transaction_duplicate2 = TRUE; transaction_duplicate2 = TRUE;
k=k+1;
END IF; END IF;
IF in3_reserve_pub = i.reserve_pub IF in3_reserve_pub = i.reserve_pub
THEN THEN
transaction_duplicate3 = TRUE; transaction_duplicate3 = TRUE;
k=k+1;
END IF; END IF;
IF in4_reserve_pub = i.reserve_pub IF in4_reserve_pub = i.reserve_pub
THEN THEN
transaction_duplicate4 = TRUE; transaction_duplicate4 = TRUE;
k=k+1;
END IF; END IF;
END IF; END IF;
k=k+1;
END LOOP; END LOOP;
CLOSE curs_transaction_exist; CLOSE curs_transaction_exist;

View File

@ -248,52 +248,44 @@ BEGIN
THEN THEN
out_reserve_found = FALSE; out_reserve_found = FALSE;
ruuid = i.reserve_uuid; ruuid = i.reserve_uuid;
k = k+1;
END IF; END IF;
IF in2_reserve_pub = i.reserve_pub IF in2_reserve_pub = i.reserve_pub
THEN THEN
out_reserve_found2 = FALSE; out_reserve_found2 = FALSE;
ruuid2 = i.reserve_uuid; ruuid2 = i.reserve_uuid;
k=k+1;
END IF; END IF;
IF in3_reserve_pub = i.reserve_pub IF in3_reserve_pub = i.reserve_pub
THEN THEN
out_reserve_found3 = FALSE; out_reserve_found3 = FALSE;
ruuid3 = i.reserve_uuid; ruuid3 = i.reserve_uuid;
k=k+1;
END IF; END IF;
IF in4_reserve_pub = i.reserve_pub IF in4_reserve_pub = i.reserve_pub
THEN THEN
out_reserve_found4 = FALSE; out_reserve_found4 = FALSE;
ruuid4 = i.reserve_uuid; ruuid4 = i.reserve_uuid;
k=k+1;
END IF; END IF;
IF in5_reserve_pub = i.reserve_pub IF in5_reserve_pub = i.reserve_pub
THEN THEN
out_reserve_found5 = FALSE; out_reserve_found5 = FALSE;
ruuid5 = i.reserve_uuid; ruuid5 = i.reserve_uuid;
k=k+1;
END IF; END IF;
IF in6_reserve_pub = i.reserve_pub IF in6_reserve_pub = i.reserve_pub
THEN THEN
out_reserve_found6 = FALSE; out_reserve_found6 = FALSE;
ruuid6 = i.reserve_uuid; ruuid6 = i.reserve_uuid;
k=k+1;
END IF; END IF;
IF in7_reserve_pub = i.reserve_pub IF in7_reserve_pub = i.reserve_pub
THEN THEN
out_reserve_found7 = FALSE; out_reserve_found7 = FALSE;
ruuid7 = i.reserve_uuid; ruuid7 = i.reserve_uuid;
k=k+1;
END IF; END IF;
IF in8_reserve_pub = i.reserve_pub IF in8_reserve_pub = i.reserve_pub
THEN THEN
out_reserve_found8 = FALSE; out_reserve_found8 = FALSE;
ruuid8 = i.reserve_uuid; ruuid8 = i.reserve_uuid;
k=k+1;
END IF; END IF;
END IF; END IF;
k=k+1;
END LOOP; END LOOP;
CLOSE curs_reserve_existed; CLOSE curs_reserve_existed;
@ -397,46 +389,38 @@ BEGIN
IF in_reserve_pub = r.reserve_pub IF in_reserve_pub = r.reserve_pub
THEN THEN
transaction_duplicate = TRUE; transaction_duplicate = TRUE;
k=k+1;
END IF; END IF;
IF in2_reserve_pub = r.reserve_pub IF in2_reserve_pub = r.reserve_pub
THEN THEN
transaction_duplicate2 = TRUE; transaction_duplicate2 = TRUE;
k=k+1;
END IF; END IF;
IF in3_reserve_pub = r.reserve_pub IF in3_reserve_pub = r.reserve_pub
THEN THEN
transaction_duplicate3 = TRUE; transaction_duplicate3 = TRUE;
k=k+1;
END IF; END IF;
IF in4_reserve_pub = r.reserve_pub IF in4_reserve_pub = r.reserve_pub
THEN THEN
transaction_duplicate4 = TRUE; transaction_duplicate4 = TRUE;
k=k+1;
END IF; END IF;
IF in5_reserve_pub = r.reserve_pub IF in5_reserve_pub = r.reserve_pub
THEN THEN
transaction_duplicate5 = TRUE; transaction_duplicate5 = TRUE;
k=k+1;
END IF; END IF;
IF in6_reserve_pub = r.reserve_pub IF in6_reserve_pub = r.reserve_pub
THEN THEN
transaction_duplicate6 = TRUE; transaction_duplicate6 = TRUE;
k=k+1;
END IF; END IF;
IF in7_reserve_pub = r.reserve_pub IF in7_reserve_pub = r.reserve_pub
THEN THEN
transaction_duplicate7 = TRUE; transaction_duplicate7 = TRUE;
k=k+1;
END IF; END IF;
IF in8_reserve_pub = r.reserve_pub IF in8_reserve_pub = r.reserve_pub
THEN THEN
transaction_duplicate8 = TRUE; transaction_duplicate8 = TRUE;
k=k+1;
END IF; END IF;
END IF; END IF;
k=k+1;
END LOOP; END LOOP;
CLOSE curs_transaction_existed; CLOSE curs_transaction_existed;

View File

@ -34,6 +34,9 @@ LANGUAGE plpgsql
AS $$ AS $$
BEGIN BEGIN
ruuid= 0;
out_reserve_found = TRUE;
transaction_duplicate= FALSE;
--SIMPLE INSERT ON CONFLICT DO NOTHING --SIMPLE INSERT ON CONFLICT DO NOTHING
INSERT INTO wire_targets INSERT INTO wire_targets
(wire_target_h_payto (wire_target_h_payto
@ -56,9 +59,7 @@ BEGIN
,in_expiration_date ,in_expiration_date
,in_gc_date) ,in_gc_date)
ON CONFLICT DO NOTHING ON CONFLICT DO NOTHING
RETURNING reserve_uuid INTO ruuid; RETURNING reserves.reserve_uuid INTO ruuid;
PERFORM pg_notify(in_notify, NULL);
IF FOUND IF FOUND
THEN THEN
-- We made a change, so the reserve did not previously exist. -- 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*/ out_reserve_found = TRUE; /*RESERVE EXISTED BUT WE DO NOT KNOW ANY INFORMATIONS ABOUT TRANSACTION, RETURN*/
RETURN; RETURN;
END IF; END IF;
PERFORM pg_notify(in_notify, NULL);
INSERT INTO reserves_in INSERT INTO reserves_in
(reserve_pub (reserve_pub
,wire_reference ,wire_reference
@ -91,7 +92,9 @@ BEGIN
transaction_duplicate = FALSE; /*HAPPY PATH THERE IS NO DUPLICATE TRANS AND NEW RESERVE*/ transaction_duplicate = FALSE; /*HAPPY PATH THERE IS NO DUPLICATE TRANS AND NEW RESERVE*/
RETURN; RETURN;
ELSE 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; RETURN;
END IF; END IF;
RETURN;
END $$; END $$;