Skip to content
Permalink
Browse files

Integrating with burstkit4j

  • Loading branch information...
jjos2372 committed Apr 21, 2019
1 parent 0f6e150 commit 4887ca219407b3165b2f6c1beb956a78aac74bf4
Showing with 185 additions and 297 deletions.
  1. +2 −0 .gitignore
  2. +23 −0 .project
  3. +3 −0 .vscode/settings.json
  4. +4 −0 build.gradle
  5. +22 −18 src/main/java/bt/Emulator.java
  6. +0 −140 src/main/java/bt/ReedSolomon.java
  7. +131 −139 src/main/java/bt/compiler/Compiler.java
@@ -0,0 +1,2 @@
bin
.gradle
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>blocktalk</name>
<comment>Project blocktalk created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "automatic"
}
@@ -21,11 +21,15 @@ repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()

maven { url 'https://jitpack.io' }
}

dependencies {
implementation 'org.ow2.asm:asm-tree:7.1'

implementation 'com.github.burst-apps-team:burstkit4j:v0.9-beta1'

// Use JUnit test framework
testImplementation 'junit:junit:4.12'
}
@@ -2,28 +2,31 @@

import java.util.ArrayList;

import burst.kit.burst.BurstCrypto;
import burst.kit.entity.BurstID;

/**
* Emulates the blockchain for debugging/testing purposes.
*
* @author jjos
*
*/
public class Emulator {

static final Emulator instance = new Emulator();

Block genesis;

/**
* Block being forged, also representing the mempool.
*/
Block currentBlock;
Block prevBlock;

ArrayList<Block> blocks = new ArrayList<Block>();
ArrayList<Transaction> txs = new ArrayList<Transaction>();
ArrayList<Address> addresses = new ArrayList<Address>();

public ArrayList<Block> getBlocks() {
return blocks;
}
@@ -45,39 +48,40 @@
e.printStackTrace();
}
}

public static void main(String[] args) throws Exception {
Emulator e = Emulator.getInstance();

Address add1 = e.getAddress("BURST-C6HC-TZF2-FXPU-GCCSC");
Address add2 = e.getAddress("BURST-9VBL-B3KR-HE6P-98L5G");

e.airDrop(add1, 100000);
e.airDrop(add2, 100000);


Address c1 = e.getAddress("AUCTION-1");
e.createConctract(add1, c1, "test.Auction", Contract.ONE_BURST);
e.forgeBlock();
e.send(add1, c1, 1000*Contract.ONE_BURST, null);

e.send(add1, c1, 1000 * Contract.ONE_BURST, null);
e.forgeBlock();
}

public Address findAddress(String rs) {
for(Address a : addresses) {
if(a.rsAddress.equals(rs))
for (Address a : addresses) {
if (a.rsAddress.equals(rs))
return a;
}
return null;
}

public Address getAddress(String rs) {
Address ret = findAddress(rs);
if(ret!=null)
if (ret != null)
return ret;

long id = ReedSolomon.rsDecode(rs);

BurstCrypto bc = BurstCrypto.getInstance();
BurstID ad = bc.rsDecode(rs);
long id = ad.getSignedLongId();
ret = new Address(id, 0, rs);
addresses.add(ret);

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 4887ca2

Please sign in to comment.
You can’t perform that action at this time.