Assimilating Flowchain’s Algorithms — PART 1

Yoshitha Chowdary
Flowchain Knowledge Camp
3 min readOct 21, 2019

Flowchain proposed the concept of Virtual Blocks to provide a real-time transaction. When nodes mine their virtual blocks, Flowchain creates branches for each node. This can help estimate the block “forks” exception during the mining process. In this way, Flowchain can attain real-time feature by maintaining valid and invalid blocks. The below figure depicts Flowchain’s proposed data structure, called Virtual Blocks.

Algorithm 1

The above shown Flowchain data structure(Algorithm 1) design features include,

  1. The labels N1 to N5 are the IoT devices and each device is considered as a node in a peer-to-peer network.
  2. All nodes are the mining blocks that use the same genesis block.
  3. Each node creates a new “branch” for mining and hence, there is no blockchain “fork”.
  4. Every block in each branch is called a “Virtual Block”.
  5. These Virtual Blocks can be labeled as valid or invalid blocks.
  6. Only valid blocks can be used to record transactions
  7. The most important design feature of the Flowchain data structure is that every node can only mine blocks at its branch. Therefore, Virtual Blocks need not be synchronized with all nodes because nodes do not “compete” to mine new blocks.

Process and Algorithm of Virtual Blocks :

Technically, mining is a mechanism and distributed consensus system that can verify and record such transactions. The Virtual Block system label blocks as valid or invalid. Valid blocks act as a secure ledger that records transactions. Flowchain utilizes the same SHA-256 hash algorithm used by Bitcoin, but the mining algorithm design of Flowchain is completely different. The design proposed by Flowchain allows an IoT device to operate more stable while mining blocks.

Algorithm 2

Node.on(‘message’, function(key, value) {

// Get a valid block of the device’s blockchain

N = GetOneValidBlock(chains)

// Put key-value pair in block “N”

PutToBlock( N, { key: value } );

});

From the above algorithm (Algorithm 2), a node receives a key-value pair through the peer-to-peer network and then stores it in a valid block.

Flowchain uses a probability distribution mechanism in order to update the mining difficulty and this helps Flowchain achieve a cost-effective mining system.

  1. Reliability probability — A probability calculation can directly reference an IoT device's reliability.
  2. Probability density — Use the reliability as the variance input of the probability density function.

In order to facilitate a faster and more cost-effective mining algorithm, a predefined difficulty table can be utilized to implement such an algorithm.

Algorithm 3

Difficulties = [ ‘0000FFFFFFFFFFFF’, // [0.0, 0.2)

‘000FFFFFFFFFFFFF’, // [0.2, 0.4)

‘00FFFFFFFFFFFFFF’, // [0.4, 0.6)

’0FFFFFFFFFFFFFFF’, // [0.6, 0.8)

’FFFFFFFFFFFFFFFF’ // [0.8, 1.0) ]

The above algorithm (Algorithm 3) shows that the miner can simply search the difficulty table and pick a value according to the probability. The leading zeros will increase the degree of difficulty. The mining becomes increasingly difficult with more leading zeros.

The miners then label new Virtual Blocks found as valid, and as any invalid condition occurs, the current virtual block which is in use becomes invalid. Invalid Virtual Blocks are considered as deleted, and they can never become valid again. The conditions for a block to become invalid vary between different types of IoT hardware.

For example, the operating system on a resource-constrained device may enter the starvation status due to the resource leaks. In general, such invalid conditions are dependent on a result from starvation problems, application process abnormal termination (e.g., crash, restart), the operating system exceptions (e.g., out of memory, out of disk space), and the program errors, such as the network disconnection error.

In order to reduce the complexity of maintaining valid and invalid blocks, O(1) is implemented, which labels the latest block as a Most Recently Used(MRU) block. Hence, every IoT device will have only a single valid block.

Algorithm 4

Node.on(‘message’, function(key, value) {

// N is the length of the blockchain.

// Put payload in the latest block in the blockchain.

// This is to say; only the latest block is valid for use.

PutToBlock( chains[N-1], { key: value } );

});

In theory, these systems can simply condition the impossibility of starvation, abnormal, exceptions and errors as mentioned earlier so that Flowchain can employ this single valid block model.

09/10/2019

--

--