├── .gitignore
├── LICENSE
├── README.md
├── pom.xml
└── src
├── main
└── java
│ └── com
│ └── turu
│ └── hashgraphmachine
│ └── domain
│ ├── HashgraphEvent.java
│ ├── HashgraphNode.java
│ ├── HashgraphTransaction.java
│ └── nodes
│ └── LocalNode.java
└── test
└── groovy
└── com
└── turu
└── hashgraphmachine
└── domain
└── nodes
└── LocalNodeTest.groovy
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.ear
17 | *.zip
18 | *.tar.gz
19 | *.rar
20 |
21 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
22 | hs_err_pid*
23 |
24 | # Intellij:
25 | .idea/
26 |
27 | ## File-based project format:
28 | *.iws
29 |
30 | # Maven artifacts
31 | target/
32 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Piotr Turek
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # HashgraphMachine
2 | This project is a JVM implementation of the **Swirlds Hashgraph** by *Leemon Baird* - a **fair**, **fast**, **replicated**, **Byzantine** state machine.
3 |
4 | Once it reaches maturity, ```HashgraphMachine``` is intended to be a **correct**, **performant** and **reusable** **implementation** of the consensus protocol.
5 |
6 | # Project status
7 | Please, be warned that **this project is in a very early, proof-of-concept stage**. Both APIs and implementation can and will change without notice.
8 |
9 | # About the algorithm
10 | Swirlds Hashgraph is fair, fast, replicated, Byzantine consensus algorithm, which can be used to implement distributed state machines.
11 |
12 | Key properties of Hashgraph, which make it a very powerful tool for building real-world, large scale distributed systems (f.e. databases) include:
13 | - **Byzantine fault tolerancy**, that is an ability to tolerate both classic node failures and network partitions as well as malicious, adversarial nodes - as long as at least ~2/3 of all peers are available and conforming.
14 | - **No single point of failure** due to a leaderless approach to arriving at consensus.
15 | - **Scalability, peformance and energy efficiency** due to a novel use of gossip protocol enabling the concept of *virtual voting*, which results in a very limited utilization of both network bandwidth and processing power.
16 |
17 | For more detailed description, please consult the whitepaper: http://www.swirlds.com/downloads/SWIRLDS-TR-2016-01.pdf
18 |
19 | //TODO: consider elaborating more
20 |
21 | # Specification and APIs
22 | //TODO: write down specs of the implementation and APIs
23 |
24 | # Implementation architecture
25 | //TODO: document architecture once there is some ;)
26 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.turu
7 | hashgraphmachine
8 | 0.0.1
9 | jar
10 |
11 | ${project.groupId}:${project.artifactId}
12 | HashgraphMachine - a fair, fast, replicated, Byzantine state machine
13 |
14 |
15 |
16 | Piotr turek
17 | https://github.com/turu
18 |
19 |
20 |
21 | 2017
22 |
23 |
24 | scm:git:ssh://git@github.com:turu/HashgraphMachine.git
25 | scm:git:ssh://git@github.com:turu/HashgraphMachine.git
26 | https://github.com/turu/HashgraphMachine.git
27 | 0.0.1
28 |
29 |
30 |
31 | UTF-8
32 |
33 |
34 |
35 |
36 |
37 | junit
38 | junit
39 | 4.12
40 |
41 |
42 | org.spockframework
43 | spock-core
44 | 1.0-groovy-2.4
45 |
46 |
47 |
48 |
49 |
50 |
51 | org.apache.maven.plugins
52 | maven-javadoc-plugin
53 | 2.10.4
54 |
55 |
56 | org.apache.maven.plugins
57 | maven-surefire-plugin
58 | 2.19.1
59 |
60 |
61 | org.apache.maven.plugins
62 | maven-deploy-plugin
63 | 2.7
64 |
65 |
66 | org.apache.maven.plugins
67 | maven-compiler-plugin
68 | 3.2
69 |
70 | 1.8
71 | 1.8
72 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/src/main/java/com/turu/hashgraphmachine/domain/HashgraphEvent.java:
--------------------------------------------------------------------------------
1 | package com.turu.hashgraphmachine.domain;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * Created by turu on 21/05/17.
7 | */
8 | public interface HashgraphEvent {
9 | String getSelfParentHash();
10 | String getOtherParentHash();
11 | List getTransactions();
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/com/turu/hashgraphmachine/domain/HashgraphNode.java:
--------------------------------------------------------------------------------
1 | package com.turu.hashgraphmachine.domain;
2 |
3 | /**
4 | * Created by turu on 21/05/17.
5 | */
6 | public interface HashgraphNode {
7 | void acceptEvent(HashgraphEvent event);
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/java/com/turu/hashgraphmachine/domain/HashgraphTransaction.java:
--------------------------------------------------------------------------------
1 | package com.turu.hashgraphmachine.domain;
2 |
3 | import java.nio.ByteBuffer;
4 |
5 | /**
6 | * Created by turu on 21/05/17.
7 | */
8 | public interface HashgraphTransaction {
9 | ByteBuffer getPayloadBytes();
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/com/turu/hashgraphmachine/domain/nodes/LocalNode.java:
--------------------------------------------------------------------------------
1 | package com.turu.hashgraphmachine.domain.nodes;
2 |
3 | import com.turu.hashgraphmachine.domain.HashgraphEvent;
4 | import com.turu.hashgraphmachine.domain.HashgraphNode;
5 |
6 | /**
7 | * Created by turu on 21/05/17.
8 | */
9 | public class LocalNode implements HashgraphNode {
10 | @Override
11 | public void acceptEvent(HashgraphEvent event) {
12 | //TODO: implement
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/test/groovy/com/turu/hashgraphmachine/domain/nodes/LocalNodeTest.groovy:
--------------------------------------------------------------------------------
1 | package com.turu.hashgraphmachine.domain.nodes
2 |
3 | import com.turu.hashgraphmachine.domain.HashgraphEvent
4 | import spock.lang.Specification
5 |
6 | /**
7 | * Created by turu on 21/05/17.
8 | */
9 | class LocalNodeTest extends Specification {
10 | LocalNode localNode
11 |
12 | def setup() {
13 | localNode = new LocalNode()
14 | }
15 |
16 | def "acceptEvent should not fail given HashgraphEvent"() {
17 | given:
18 | def event = Mock(HashgraphEvent)
19 |
20 | when:
21 | localNode.acceptEvent(event)
22 |
23 | then:
24 | 1 == 1
25 | }
26 | }
27 |
--------------------------------------------------------------------------------