From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from localhost.localdomain (unknown [138.197.159.143]) by gnuweeb.org (Postfix) with ESMTPSA id 90DFE7F9CC; Tue, 28 Jun 2022 06:21:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1656397304; bh=HJHolPL1A/SxXmiiITxAs9sbSrPCIvwFDVLnI9sRt50=; h=From:To:Cc:Subject:Date:From; b=O+MZmrTJEOc52Wq/WT2wbgovUehjbh8JTMhMio/biHN+ji9Jh90d+1/SuyftIhpP/ Mq0forqvmgS/mJsReMt/WLHxoK1Mxoejc8A4bAd9/MLkvRtDOkIi+tIv8FoM7/hTqi t7ZyR65cKG4/vAVasYsZHXPf62sWfgH2fnlAYk8uIBtxOiBpD3AxA0nvuycdA2Btr4 LfkM+9wTiPy5b4XZMkmGehEQLwoBB2aAqU9I+K9JvPLW6tFZiwXs82Di3bwPD1t2it ZUxHIYx7P9GkM1mWUxe2oxPZhRjYrfA5uAVbbvIKVgdyre0Py7CL8QW4Dube+sQXHS rty9KPa5rYB8w== From: Alviro Iskandar Setiawan To: Ammar Faizi Cc: GNU/Weeb Mailing List , Alviro Iskandar Setiawan Subject: [RFC PATCH v1 0/1] GNU/Weeb Financial Transaction Record Design Date: Tue, 28 Jun 2022 06:21:38 +0000 Message-Id: <20220628062139.262361-1-alviro.iskandar@gnuweeb.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 --- 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