Created
March 5, 2018 19:24
-
-
Save kemalyen/fb89983e7ce799356a5a1fce406a1d1a to your computer and use it in GitHub Desktop.
Blockchain oluşturan örnek projemizin kalbi ve main methodu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gazatem.java.blockchain.tutorial; | |
import com.gazatem.java.blockchain.tutorial.model.Block; | |
import com.gazatem.java.blockchain.tutorial.service.Calculate; | |
import java.util.ArrayList; | |
public class main { | |
private static Calculate calculate; | |
public static ArrayList<Block> blockchain = new ArrayList<Block>(); | |
public static void main(String[] args) { | |
int difficulty = 1; | |
calculate = new Calculate(); | |
String previousHash = ""; | |
for(int i = 0; i < 10; i++){ | |
Block block = new Block("Sample block no: " + i, previousHash); | |
block.setHash(calculate.createHash(block)); | |
calculate.mineBlock(difficulty, block); | |
previousHash = block.getPreviousHash(); | |
blockchain.add(block); | |
System.out.println(i +". "+ block.getHash()); | |
} | |
System.out.println("All blocks are hashed..."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment