I believe you are over complicating your life.
Having a BlockChain (a Linked Ledger) in SQL can be prototyped in the following manner
Create a table, such as:
CREATE TABLE IF NOT EXISTS
MyBlockChain (
LedgerID int(10) NOT NULL auto_increment,
block varchar(255),
datetimestamp datetime,
guid varchar(255), --Have a Default GUID Generated
PRIMARY KEY( `LedgerID` )
);
Having an AutoGenerated Sequence Number (as a primary key) - This creates the sequence in your ledger.
Assign Proper Security to only allow INSERTS to happen over a Public API.
- Only the GUID is used to access a Record (block) via ReadOnly permissions.
- When users can only INSERT Data (No DELETE or UPDATE) you, in essence, created a Ledger.
- And since the Sequence Number will be used to determine ordering of actions.
The biggest challenge to distributing the MySQL database over multiple instances an having an API interface and ensuring ReadOnly and Insert Only security.
That by default is a simple implementation of a BlockChain
In order for this to be more blockchain-like, I believe you'd have to make
guidthe primary key instead ofLedgerID, and then make aprev_guidthe link to the previous block (row in this case). Of course, you'd have to uniquely generate each guid to keep database integrity. – Volomike – 2019-01-09T05:34:23.013Meanwhile, for a faster table speed, you could move
blockto the end of the table and then even switch it fromvarchar(255)totext,mediumtext, orlongtext. – Volomike – 2019-01-09T05:37:16.887Permit no inserts unless no other block (row in this case) shares the same
prev_guid, and yourguidis unique. – Volomike – 2019-01-09T05:42:17.910