public inbox for [email protected]
 help / color / mirror / Atom feed
* [RFC PATCH v1 0/1] GNU/Weeb Financial Transaction Record Design
@ 2022-06-28  6:21 Alviro Iskandar Setiawan
  2022-06-28  6:21 ` [RFC PATCH v1 1/1] db: Create starting DDL for saving transaction Alviro Iskandar Setiawan
  0 siblings, 1 reply; 8+ messages in thread
From: Alviro Iskandar Setiawan @ 2022-06-28  6:21 UTC (permalink / raw)
  To: Ammar Faizi; +Cc: GNU/Weeb Mailing List, Alviro Iskandar Setiawan

Hi,

In order to keep the transaction record consistent, we can use a
chaining hash system that generates the transaction ID by using its
parent ID and the current transaction details.

For example, to create a new transaction, we have several things to note, like:

  1. date
  2. description
  3. commiter
  4. amount

  [ other metadata stuff may be included ]

We can then generate the transaction id by using a hash function,
let's say SHA1:

 trx_info = date . description . commiter . amount . parent_trx_id
 trx_id   = SHA1(info)
 SAVE(trx_id, date, description, commiter, amount, parent_trx_id)

Note that since the current trx ID uses its parent trx ID to generate
itself, it makes the situation impossible to rewrite the history
without breaking the whole chain. That's the point of the consistency
in this design. We can verify that the data is consistent by just
re-hashing the transaction info together with its parent trx id.

Also note that, for the first transaction, it doesn't have a parent
trx id. So only the first transaction doesn't use a parent trx id to
generate itself. Let's call it the genesis transaction.

Please comment!

tq

-- Viro

Signed-off-by: Alviro Iskandar Setiawan <[email protected]>
---

Alviro Iskandar Setiawan (1):
  db: Create starting DDL for saving transaction

 database.sql | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 database.sql

-- 
Alviro Iskandar Setiawan


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-06-28  8:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-28  6:21 [RFC PATCH v1 0/1] GNU/Weeb Financial Transaction Record Design Alviro Iskandar Setiawan
2022-06-28  6:21 ` [RFC PATCH v1 1/1] db: Create starting DDL for saving transaction Alviro Iskandar Setiawan
2022-06-28  7:27   ` Ammar Faizi
2022-06-28  7:31     ` Alviro Iskandar Setiawan
2022-06-28  7:47       ` Ammar Faizi
2022-06-28  7:49         ` Ammar Faizi
2022-06-28  8:03         ` Alviro Iskandar Setiawan
2022-06-28  8:07           ` Ammar Faizi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox