This article was originally written by Mika Hyttinen. Medium link: https://email@example.com
Oh boy, I have been trying and trying to find some time to do this article and it’s finally here!
Cellframe has built in some pretty neat features. One of the features is GlobalDB (global database).
While GlobalDB is currently in unstable state (as far as I know), it will be one of the key features of Cellframe ecosystem in the future in my opinion.
In this article, I’m trying to share my views about GlobalDB (eg. the possibilities for using such feature).
. . .
Cellframe is an ambitious third generation blockchain project and few people (me included) have already started to talk about it as the next Polkadot or Kusama.
This project is, however, more service oriented and has some advantages compared to Polkadot/Kusama (eg. post-quantum cryptography, 2-level sharding, P2P cross-chain operations).
Cellframe is written in C (which will make it FAST and portable), and it has an SDK for C and Python at the moment. More supported languages are coming in the future.
I really recommend visiting their website (https://cellframe.net) and read their whitepaper!
. . .
First something about databases
Every person who uses internet is probably registered to some type of service (Facebook, Instagram etc.). The service usually has a database which collects eg. your username and your password and those credentials are checked from the database when you login to the service.
Obviously the passwords and usernames are typically stored to the database encrypted. So if a rogue user can access the database, that user is usually unable to extract any necessary login details from there.
The most simple database usage could be something like with installation of Wordpress CMS. It’s installed typically on a VPS and you have to manually create the database and then run the installation process for it. Basically everything you update to your website is then stored on the database and will be queried from there when user is viewing your website.
Of course, this is only a local approach of database usage and with strict permissions, no one else can have access to your database.
A database can also have different types of data. It can be movies, music, games… anything really!
What about GlobalDB then?
I asked briefly about GlobalDB from Dmitriy (CEO @ Cellframe Platform) about the GlobalDB feature and he answered me like this:
GlobalDB is working globally and publicly. If group has a prefix scorpion, mileena, or something like this, then it syncs globally and publicly.
If not, it’s local. Also there could be private GlobalDB that syncs only with selected nodes.
So technically, if you have a testnet prefix on your database, it works globally. It’s also possible to keep them private also if you plan to run closed services with Cellframe nodes.
Let’s take a look about the “how to implement” GlobalDB usage in public or private environment:
In this example we have one client, which connects to a node. Obviously it could connect to any node which is providing the service.
The nodes would keep the GlobalDB synced all the time so it wouldn’t really matter to which node the client would connect to.
Let’s take an example like Netflix type of service:
- Client connects to node (checking credentials and subscription)
- Node passes the requested movie to the user from the global database
- User starts watching the movie
This is obviously really simple example, but that’s something what you can expect feature wise in the future!
Interacting GlobalDB with Cellframe Python SDK
Luckily, Cellframe Python SDK has 4 methods to interact with global databases:
CellFrame.GlobalDB.get()-> Get data from GlobalDB
CellFrame.GlobalDB.set()-> Write data to GlobalDB
CellFrame.GlobalDB.delete() -> Delete data from GlobalDB
Now the 4th method is
that’s a feature that looks like it’s unimplemented for now. Maybe for pinning some data so it can’t be overwritten? Just guessing here 😏.
Oh well, let’s look at these methods in real world.
Umm, well that’s kind of easy to understand what happens here. I’m just writing “This data is written to database”… to a database!
By the way: If
method returns True, writing was successful. If not, it will return False!
Now looking at the logs after this plugin is setup in the correct directory, we should see something like:
[05/24/22-20:13:08] [ * ] [libdap-python] Initialize GlobalDB plugin
[05/24/22-20:13:08] [ * ] [libdap-python] Data written to database
Ok, let’s also add a feature to read data from the database with
After adding this part of code to the plugin, we should see exactly the data in our logs which was added to the database in the earlier part of the code:
[05/26/22-08:58:45] [ * ] [libdap-python] Reading from database: This data is written to database
It works! Now let’s also add the last method, deleting data from the database using
method also returns True if deleting the data from the database was successful, otherwise it will return False!
Looking at the logs then, we should see something like this:
[05/26/22-08:58:45] [ * ] [libdap-python] Data was deleted from a database
Now all this may sound little too simple to you, adding some text to a database and then printing it to the log output. But imagine something like this:
There are billions of smartphones which could be used for providing a global database for users like me. That database could have technically anything available for the end users so a service provider wouldn’t have to keep their databases on a centralized locations. Everything would be decentralized, shared from everyone to everyone!
Like I have mentioned earlier in my articles, if/when someone creates such a service without any type of central servers and everything could be running for example on a typical smartphone:
It will be a game changer in the real world.
If you want to build something on the future of blockchains, join their development Telegram channel!
Thank you for reading!
And huge thanks for all my Twitter followers for encouraging me to write more articles!