Skip to content

Commit

Permalink
Added links and overview to @JavaDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
pa314159 committed Sep 6, 2019
1 parent 90d923d commit 66af327
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ Add *merkle-tree* as a dependency to your project.
* Gradle

```
implementation 'ascelion.public:merkle-tree:1.0.0'
implementation 'ascelion.public:merkle-tree:1.0.1'
```

* Maven
````
<dependency>
<groupId>ascelion.public</groupId>
<artifactId>merkle-tree</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</dependency>
````

Expand Down Expand Up @@ -49,3 +49,6 @@ Use the TreeBuilder to create a Merkle tree

You may also want to check the demo project for a real example.

Also [see the javadoc](https://ascelion.github.io/merkle-tree/index.html).


58 changes: 58 additions & 0 deletions impl/src/main/java/overview.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<html>
<body>
<h1 id="merkletree">Merkle Tree</h1>

<p>A generic implementation of Merkle trees</p>

<h2 id="usage">Usage</h2>

<p>Add <em>merkle-tree</em> as a dependency to your project.</p>

<ul>
<li>Gradle</li>
</ul>

<pre><code> implementation 'ascelion.public:merkle-tree:1.0.0'
</code></pre>

<ul>
<li>Maven</li>
</ul>

<pre><code class="` language-`"> &lt;dependency&gt;
&lt;groupId&gt;ascelion.public&lt;/groupId&gt;
&lt;artifactId&gt;merkle-tree&lt;/artifactId&gt;
&lt;version&gt;1.0.0&lt;/version&gt;
&lt;/dependency&gt;
</code></pre>

<p>`</p>

<p>Use the TreeBuilder to create a Merkle tree</p>

<pre><code> // create a hash function
UnaryOperator&lt;String&gt; hashFn = ...

// create a concatenation function
BinaryOperator&lt;String, String&gt; concatFn = (s1, s2) -&gt; s1 + s2;

// create a tree builder
TreeBuilder&lt;String&gt; tbd = new TreeBuilder&lt;&gt;(hashFn, concatFn, "");

// add some nodes and build the tree
TreeRoot&lt;String&gt; root = tbd
.collect( new TreeLeaf&lt;&gt;(hashFn, "s1" )
// ....
.collect( new TreeLeaf&lt;&gt;(hashFn, "s2") )
.build();

// get a leaf
TreeLeaf&lt;String&gt; leaf1 = root.getLeaf( 0 );

// validate the hash chain
assertTrue( tbd.validate( leaf1.getChain() ) );
</code></pre>

<p>You may also want to check the <a href="https://github.com/ascelion/merkle-tree/tree/master/demo">demo project</a> for a real example.</p>
</body>
</html>
2 changes: 2 additions & 0 deletions publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ javadoc {

options {
memberLevel = 'PROTECTED'
overview = file( 'src/main/java/overview.html' )
links += [ 'https://docs.oracle.com/javase/8/docs/api' ]
}
}

Expand Down

0 comments on commit 66af327

Please sign in to comment.