-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathHashLoop.java
40 lines (36 loc) · 910 Bytes
/
HashLoop.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package bt.sample;
import bt.compiler.CompilerVersion;
import bt.Contract;
import bt.compiler.TargetCompilerVersion;
import bt.ui.EmulatorWindow;
/**
* A contract that run hashes until there is no more balance.
*
* @author jjos
*
*/
@TargetCompilerVersion(CompilerVersion.v0_0_0)
public class HashLoop extends Contract {
long hash;
/**
* Every time a transaction is sent to the contract, this method is called
*/
@Override
public void txReceived() {
while(true){
// run this forever
// execution will freeze when there is no more balance and can be resumed
// by charging the contract with more BURST
hash = performSHA256_64(getPrevBlockHash1(), hash);
}
}
/**
* A main function for debugging purposes only, this method is not
* compiled into bytecode.
*
* @param args
*/
public static void main(String[] args) {
new EmulatorWindow(HashLoop.class);
}
}