Skip to content

Commit de24e45

Browse files
committed
a actuator's demo
1 parent b49e82b commit de24e45

File tree

4 files changed

+62
-7
lines changed

4 files changed

+62
-7
lines changed

example/actuator-example/build.gradle

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
description = "actuator-example – a example of actuator."
2+
3+
dependencies {
4+
compile project(":actuator")
5+
}
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package org.tron.core.actuator;
2+
3+
import com.google.protobuf.ByteString;
4+
import com.google.protobuf.InvalidProtocolBufferException;
5+
import java.util.Objects;
6+
import lombok.extern.slf4j.Slf4j;
7+
import org.tron.common.utils.Commons;
8+
import org.tron.core.capsule.TransactionResultCapsule;
9+
import org.tron.core.capsule.WitnessCapsule;
10+
import org.tron.core.exception.ContractExeException;
11+
import org.tron.core.exception.ContractValidateException;
12+
import org.tron.core.store.AccountStore;
13+
import org.tron.core.store.WitnessStore;
14+
import org.tron.core.utils.TransactionUtil;
15+
import org.tron.protos.Protocol.Transaction.Contract.ContractType;
16+
import org.tron.protos.Protocol.Transaction.Result.code;
17+
import org.tron.protos.contract.AccountContract;
18+
import org.tron.protos.contract.WitnessContract.WitnessUpdateContract;
19+
20+
@Slf4j(topic = "actuator")
21+
public class ExampleActuator extends AbstractActuator {
22+
23+
public ExampleActuator() {
24+
super(ContractType.AccountCreateContract, AccountContract.AccountCreateContract.class);
25+
}
26+
27+
@Override
28+
public boolean execute(Object result) throws ContractExeException {
29+
logger.info("ExampleActuator execute successfully.");
30+
return true;
31+
}
32+
33+
@Override
34+
public boolean validate() throws ContractValidateException {
35+
logger.info("ExampleActuator validate successfully.");
36+
return true;
37+
}
38+
39+
@Override
40+
public ByteString getOwnerAddress() throws InvalidProtocolBufferException {
41+
return null;
42+
}
43+
44+
@Override
45+
public long calcFee() {
46+
return 0;
47+
}
48+
}

framework/build.gradle

+6-6
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,12 @@ def createScript(project, mainClass, name) {
239239
}
240240
}
241241

242-
distZip {
243-
doLast {
244-
file("$destinationDir/$archiveName").renameTo("$destinationDir/"+'java-tron-'+version+'-bin.zip')
245-
}
246-
}
247-
configurations.archives.artifacts.removeAll {it.type == 'tar' || it.type == 'zip'}
242+
//distZip {
243+
// doLast {
244+
// file("$destinationDir/$archiveName").renameTo("$destinationDir/"+'java-tron-'+version+'-bin.zip')
245+
// }
246+
//}
247+
configurations.archives.artifacts.removeAll {it.type == 'tar'}
248248
applicationName = 'java-tron'
249249
startScripts.enabled = false
250250
run.enabled = false

settings.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
rootProject.name = 'javatron'
1+
rootProject.name = 'java-tron'
22
include 'framework'
33
include 'chainbase'
44
include 'protocol'
55
include 'actuator'
66
include 'consensus'
77
include 'common'
8+
include 'example:actuator-example'

0 commit comments

Comments
 (0)