1
0
Fork 0

[node] fixed contracting and implemented renegotiation

This commit is contained in:
Julien Dessaux 2024-03-30 14:22:59 +01:00
parent 719a9c1a77
commit 8819cf9c67
Signed by: adyxax
GPG key ID: F92E51B86E07177E
8 changed files with 103 additions and 71 deletions

View file

@ -18,12 +18,9 @@ export function getContracts(): Array<Contract> {
}
export function setContract(data: Contract): void {
if (getContract(data.id) === null) {
addContractStatement.run(JSON.stringify(data));
} else {
updateContractStatement.run({
data: JSON.stringify(data),
id: data.id,
});
}
const changes = updateContractStatement.run({
data: JSON.stringify(data),
id: data.id,
}).changes;
if (changes === 0) addContractStatement.run(JSON.stringify(data));
}