BlockDAG Blue Selection Algorithm Demo (Golang)

BlockChain (for example Bitcoin, Etherum, etc.) is just a ‘k=0’ special subtype of BlockDAG, that’s why they suffer from the highly restrictive throughput. DAG is the future!

Blue set selection algorithm is the base of the BlockDAG technology. Thanks Go Playground, to create a new example DAG and run it online to see the DAG blue behaviour, it’s quite easy now. For example, to test a DAG in this figure ‘Fig.4’, just add a piece of codes like this:
Fig.4

[]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
ChainAddBlock("Genesis", []string{}, chain)

ChainAddBlock("B", []string{"Genesis"}, chain)
ChainAddBlock("C", []string{"Genesis"}, chain)
ChainAddBlock("D", []string{"Genesis"}, chain)
ChainAddBlock("E", []string{"Genesis"}, chain)

ChainAddBlock("F", []string{"B","C"}, chain)
ChainAddBlock("I", []string{"C","D"}, chain)
ChainAddBlock("H", []string{"E"}, chain)

ChainAddBlock("J", []string{"F","D"}, chain)
ChainAddBlock("L", []string{"F"}, chain)
ChainAddBlock("K", []string{"J","I","E"}, chain)
ChainAddBlock("N", []string{"D","H"}, chain)

ChainAddBlock("M", []string{"L","K"}, chain)
ChainAddBlock("O", []string{"K"}, chain)
ChainAddBlock("P", []string{"K"}, chain)
ChainAddBlock("Q", []string{"N"}, chain)

ChainAddBlock("R", []string{"O","P","N"}, chain)

ChainAddBlock("S", []string{"Q"}, chain)
ChainAddBlock("T", []string{"S"}, chain)
ChainAddBlock("U", []string{"T"}, chain)

Run your own BlockDag example online

Click it will open the Go Playground: Click me to run You can edit your own blockDAG example and run it online!
The output will be like this:

[]
1
2
3
- BlockDAG Algorithms Simulation - Algorithm 1: Selection of a blue set. -
chainInitialize(): done. blocks= 20
blue set selection done. blue blocks = (G).B.C.D.F.I.J.K.O.P.M.R.(V). total blue: 13

The full open source project

The full source code is here: go-dag.