Project Web site http://oursql.org
OurSQL allows to create a blockchain database quickly with connecting MySQL servers into a cluster.
Use OurSQL to create new blockchain mapped to a MySQL DB or to join to existent blockchain as a cluster node and get MySQL DB data replicated.
OurSQL supports cryptocurrency too. It is a "side effect" of a blockchain used to replicate data. When blocks are created, some wallet receives coins. It is possible to send coins to any other wallet as it works in bitcoin or similar cryptocurrencies.
Additionally, it is possible to define "paid" SQL transactions in a consensus rules. To protect some data from unlimited modifications.
OurSQL containes a MySQL proxy server. To make a decetralized application (or "blockchain app") it is needed to code an app that connects to MySQL and works with it like normal single app. Nothing special in the app code. Just standard way to work with MySQL server - update data and select data.
For the app, all this work is not visible. It just exexutes SQL commands and doesn't care about blockchain or so. OurSQL does all this work itself.
Current version supports only Proof of Work consensus type. Every blockchain has a consensus config file which containes rules. Options of PoW: block hash options, coins to add for minter, numbers of transactions per block etc.
This file is distributed as part of a package instalation package.
Also, in this file it is possible to describe which SQL operation are allowed in this decetralized DB: insert, update, delete , table create. Additionally, it is possible to set rules per table.
Finally, it is possible to set a cost of SQL query per table and type. For example, 0.5 (of a coin) per insert in a table "members". This allows to control updates.
Soon we add extended support of a consensus management.
We are going to add support of a consensus plug-in. It will be a module for OurSQL (.so or .dll) to control updates.
The consensus module will be able to do some work for every proposed update. Each SQL transaction goes together with a wallet address. The module will be able to check if an address can do this SQL command now. It can do extra requests to other DB table to do some checks, etc.
For example, all users of an app can vote for some user to be a moderator. If a user was elected he is able to update some table. All other are not able. Consensus module can controll such things.
Consensus module will filter all SQL commands received from an app via the proxy and also received from other nodes.
OurSQL is a Golang app. You can compile it yourself or use one of precompiled options.
Pull the image
docker pull oursql/oursql-server
Or just try to run, it will pull automatically.
docker run --name oursql -p 8766:8766 -it oursql/oursql-server
Now you can connect to the mysql proxy on port 8766 and all updates you do in the DB will be added to a blockchain!
mysql -h 127.0.0.1 -P 8766 -u blockchain -pblockchain BC
> CREATE TABLE test (a int unsigned primary key auto_increment, b varchar(100));
> INSERT INTO test SET b='row1';
Find more usage examples and try to run multiple nodes to see how replication works.
Get OurSQL code files. This works on linux. If you are on other platform the process should be similar.
go get github.com/gelembjuk/oursql
Install dependencies
github.com/go-sql-driver/mysql
go get github.com/JamesStewy/go-mysqldump
go get github.com/btcsuite/btcutil
go get github.com/fatih/structs
go get github.com/mitchellh/mapstructure
Go to the node library and build
cd $GOPATH/src/github.com/gelembjuk/oursql/node
go build
It is ready. Now you can run the OurSQL server. You must have MySQL server running.
You can exacute now
./node
Find usage examples to do some tests.
We don't have intallation packages yet. We plan to make it soon.
Blockchain application lifecycle is like:
Each SQL update is a blockchain transaction and it must be signed. There are 2 supported ways to sign a transaction.
Read more about signing of transactions.
Roman Gelembjuk , roman@gelembjuk.com
Email: oursql.project@gmail.com
GNU3