Skip to content

Commit 6819814

Browse files
committed
initial commit
0 parents  commit 6819814

51 files changed

Lines changed: 3506 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.jar
2+
*.iml
3+
/qlite/target

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 qubiclite.org
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.

README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Qubic Lite Library
2+
3+
This library provides a basic framework to interact with the Qubic Lite protocol.
4+
5+
6+
7+
## Installation
8+
9+
### 1) Requirements
10+
11+
You will need the JDK and Maven. A guide on how to do that on Windows or Ubuntu can be found in [this section](https://github.com/mikrohash/isf-jclient#1-get-the-requirements-jdk--maven).
12+
13+
### 2) Dependencies
14+
15+
To make this library work, you have to install the [iota java library](https://github.com/iotaledger/iota.lib.java). In the following sections we will use git to clone the repositories. But you can also download them [manually](https://github.com/mikrohash/isf-jclient#method-c-manual-download) or [via wget](https://github.com/mikrohash/isf-jclient#method-a-download-via-wget).
16+
17+
#### IOTA Library
18+
19+
cd /path/to/your/favourite/directory/
20+
git clone https://github.com/iotaledger/iota.lib.java
21+
cd iota.lib.java/
22+
mvn install
23+
24+
### 3) Building the Qlite Library
25+
26+
cd /path/to/your/favourite/directory/
27+
git clone https://github.com/qubiclite/qlite.lib.java
28+
cd qlite.lib.java/
29+
mvn versions:use-latest-versions -DallowSnapshots=true -DexcludeReactor=false
30+
mvn install
31+
32+
## Adding the Maven Module
33+
34+
After you have installed the maven module as shown above,
35+
you can include it into your own maven project by adding
36+
it as a dependency to your pom.xml file:
37+
38+
<dependency>
39+
<groupId>org.qubiclite</groupId>
40+
<artifactId>qlite.lib.java</artifactId>
41+
<version>0.1-SNAPSHOT</version>
42+
</dependency>
43+
44+
## Using the Library
45+
46+
### Starting a Qubic
47+
48+
Here is a small example showcasing how you can publish a new qubic:
49+
50+
String code = "return(epoch^2);";
51+
52+
// start qubic in 180 seconds
53+
int executionStart = (int)(System.currentTimeMillis()/1000)+180;
54+
55+
QubicWriter qw = new QubicWriter(executionStart, 30, 30, 10);
56+
qw.setCode(code);
57+
qw.publishQubicTx();
58+
59+
Now go tell your friends to set up their oracles (see [next section](#running-an-oracle))
60+
and apply to your qubic. After that we can publish the assembly transaction:
61+
62+
// the oracle IDs of your friends oracles
63+
String michelsOracle = "WQTNBLHTEIRTFEIL99NDCGDGDWDYOJVSMYODNLCHGHZRBQKTXVMSTGVOO9C9KMYGJQLYXWPCTLVIHC999";
64+
String clairesOracle = "HMSCIRTQEM9GMRENWOXEJYXARGZNUTLFBTSORUSFU9LYTOLTGGYJXCYAJYGEDTDZVUXRUTPMPSWDWO999";
65+
66+
// add them to the assembly
67+
qw.addToAssembly(michelsOracle);
68+
qw.addToAssembly(clairesOracle);
69+
70+
// publish the assembly transaction (this has to be done within the 180 seconds set in executionStart!)
71+
qw.publishAssemblyTx();
72+
73+
### Running an Oracle
74+
75+
These few lines will create a new oracle that processes a specific qubic:
76+
77+
// replace this with the id of the qubic you want to process
78+
String qubicID = "KAHQRHDKODUBLPCRUBCBEKAQKAAHTCEUPMFRTMDXTKHNJMGVSMHH9T9TBKBAFRGJTGKKIKZM9HWMKX999";
79+
80+
// create a new oracle for the specific qubic
81+
QubicReader qr = new QubicReader(qubicID);
82+
OracleWriter ow = new OracleWriter(qr);
83+
84+
// let the oracle run its automized life-cycle asynchronously
85+
// it will apply for the qubic and process it if it makes it into the assembly
86+
OracleManager om = new OracleManager(ow);
87+
om.start();
88+
89+
// you can give this id to the qubic owner, so he can manually add you to the assembly
90+
String myOracleID = ow.getID();
91+
92+
More content will be added soon.
93+
94+
## Project Resources
95+
96+
official project website: http://qubiclite.org
97+
98+
java documentation: http://qubiclite.org/doc/qlite.lib.java

pom.xml

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>org.qubiclite</groupId>
8+
<artifactId>qlite.lib.java</artifactId>
9+
<version>0.1</version>
10+
<packaging>pom</packaging>
11+
<name>QLite</name>
12+
<description>The Qubic Lite library provides a framework to interact with the Qubic Lite protocol by creating, reading and processing qubics.</description>
13+
<url>https://github.com/qubiclite/qlite.lib.java</url>
14+
15+
<licenses>
16+
<license>
17+
<name>MIT License</name>
18+
<url>http://www.opensource.org/licenses/mit-license.php</url>
19+
<distribution>repo</distribution>
20+
</license>
21+
</licenses>
22+
23+
<developers>
24+
<developer>
25+
<id>microhash</id>
26+
<name>MicroHash</name>
27+
</developer>
28+
</developers>
29+
30+
31+
<properties>
32+
<maven.compiler.source>8</maven.compiler.source>
33+
<maven.compiler.target>8</maven.compiler.target>
34+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
35+
36+
<!-- plugins -->
37+
<version.maven-release-plugin>2.5.3</version.maven-release-plugin>
38+
<version.maven-source-plugin>3.0.1</version.maven-source-plugin>
39+
<version.maven-javadoc-plugin>2.10.4</version.maven-javadoc-plugin>
40+
<version.maven-surefire-plugin>2.13</version.maven-surefire-plugin>
41+
</properties>
42+
43+
<dependencyManagement>
44+
<dependencies>
45+
<dependency>
46+
<groupId>org.iota</groupId>
47+
<artifactId>jota</artifactId>
48+
<version>0.9.11-SNAPSHOT</version>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.json</groupId>
52+
<artifactId>json</artifactId>
53+
<version>20180130</version>
54+
</dependency>
55+
<dependency>
56+
<groupId>org.apache.logging.log4j</groupId>
57+
<artifactId>log4j-slf4j-impl</artifactId>
58+
<version>2.10.0</version>
59+
</dependency>
60+
<dependency>
61+
<groupId>org.apache.logging.log4j</groupId>
62+
<artifactId>log4j-core</artifactId>
63+
<version>2.10.0</version>
64+
</dependency>
65+
</dependencies>
66+
</dependencyManagement>
67+
68+
<build>
69+
<plugins>
70+
<plugin>
71+
<artifactId>maven-release-plugin</artifactId>
72+
<version>${version.maven-release-plugin}</version>
73+
<configuration>
74+
<useReleaseProfile>false</useReleaseProfile>
75+
<releaseProfiles>release</releaseProfiles>
76+
<autoVersionSubmodules>true</autoVersionSubmodules>
77+
<tagNameFormat>@{project.version}</tagNameFormat>
78+
</configuration>
79+
</plugin>
80+
<plugin>
81+
<groupId>org.apache.maven.plugins</groupId>
82+
<artifactId>maven-surefire-plugin</artifactId>
83+
<version>${version.maven-surefire-plugin}</version>
84+
<dependencies>
85+
<dependency>
86+
<groupId>org.apache.maven.surefire</groupId>
87+
<artifactId>surefire-junit47</artifactId>
88+
<version>${version.maven-surefire-plugin}</version>
89+
</dependency>
90+
</dependencies>
91+
<configuration>
92+
<excludedGroups>jota.category.IntegrationTest</excludedGroups>
93+
</configuration>
94+
</plugin>
95+
</plugins>
96+
<resources>
97+
<resource>
98+
<directory>res</directory>
99+
<includes>
100+
<include>log4j2.xml</include>
101+
</includes>
102+
</resource>
103+
</resources>
104+
</build>
105+
106+
<modules>
107+
<module>qlite</module>
108+
</modules>
109+
110+
<profiles>
111+
<profile>
112+
<id>release</id>
113+
<build>
114+
<plugins>
115+
<plugin>
116+
<artifactId>maven-assembly-plugin</artifactId>
117+
<configuration>
118+
<archive>
119+
<manifest>
120+
<mainClass />
121+
</manifest>
122+
</archive>
123+
<descriptorRefs>
124+
<descriptorRef>jar-with-dependencies</descriptorRef>
125+
</descriptorRefs>
126+
</configuration>
127+
<executions>
128+
<execution>
129+
<id>make-assembly</id> <!-- this is used for inheritance merges -->
130+
<phase>package</phase> <!-- bind to the packaging phase -->
131+
<goals>
132+
<goal>single</goal>
133+
</goals>
134+
</execution>
135+
</executions>
136+
</plugin>
137+
</plugins>
138+
</build>
139+
</profile>
140+
</profiles>
141+
</project>

qlite/pom.xml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<parent>
6+
<groupId>org.qubiclite</groupId>
7+
<artifactId>qlite.lib.java</artifactId>
8+
<version>0.1</version>
9+
</parent>
10+
11+
<name>QLite : Library</name>
12+
<artifactId>qlite</artifactId>
13+
14+
<dependencies>
15+
<dependency>
16+
<groupId>org.iota</groupId>
17+
<artifactId>jota</artifactId>
18+
<version>0.9.11-SNAPSHOT</version>
19+
</dependency>
20+
<dependency>
21+
<groupId>org.json</groupId>
22+
<artifactId>json</artifactId>
23+
<version>20180130</version>
24+
</dependency>
25+
<dependency>
26+
<groupId>org.apache.logging.log4j</groupId>
27+
<artifactId>log4j-slf4j-impl</artifactId>
28+
<version>2.10.0</version>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.apache.logging.log4j</groupId>
32+
<artifactId>log4j-core</artifactId>
33+
<version>2.10.0</version>
34+
</dependency>
35+
</dependencies>
36+
</project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package constants;
2+
3+
public class GeneralConstants {
4+
5+
public static final String VERSION = "ql-0.1";
6+
7+
public static final int QLVM_MAX_VALUE_LENGTH = 1000;
8+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package constants;
2+
3+
public class TangleJSONConstants {
4+
5+
// general
6+
public static final String TRANSACTION_TYPE = "type";
7+
public static final String VERSION = "version";
8+
9+
// Oracle
10+
public static final String ORACLE_ID = "oracle_id";
11+
public static final String ORACLE_NAME = "oracle_name";
12+
public static final String ORACLE_RESULT_STREAM = "result_stream";
13+
public static final String ORACLE_HASH_STREAM = "hash_stream";
14+
15+
// Statement
16+
public static final String STATEMENT_EPOCH_INDEX = "epoch";
17+
public static final String HASH_STATEMENT_HASH = "hash";
18+
public static final String HASH_STATEMENT_RATINGS = "ratings";
19+
public static final String RESULT_STATEMENT_RESULT = "result";
20+
21+
// IAMStream
22+
public static final String TANGLE_PUBLISHER_CONTENT = "content";
23+
public static final String TANGLE_PUBLISHER_SIGNATURE = "signature";
24+
25+
// Qubic
26+
public static final String QUBIC_ASSEMBLY = "assembly";
27+
public static final String QUBIC_CODE = "code";
28+
public static final String QUBIC_EXECUTION_START = "execution_start";
29+
public static final String QUBIC_APPLICATION_ADDRESS = "application_address";
30+
public static final String QUBIC_HASH_PERIOD_DURATION = "hash_period_duration";
31+
public static final String QUBIC_RESULT_PERIOD_DURATION = "result_period_duration";
32+
public static final String QUBIC_RUN_TIME_LIMIT = "run_time_limit";
33+
}

0 commit comments

Comments
 (0)