Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.tron.core.db.Manager;
import org.tron.core.net.TronNetService;
import org.tron.core.services.event.EventService;
import org.tron.program.SolidityNode;

@Slf4j(topic = "app")
@Component
Expand All @@ -33,6 +34,9 @@ public class ApplicationImpl implements Application {
@Autowired
private ConsensusService consensusService;

@Autowired(required = false)
private SolidityNode solidityNode;

private final CountDownLatch shutdown = new CountDownLatch(1);

/**
Expand All @@ -50,11 +54,14 @@ public void startup() {
@Override
public void shutdown() {
this.shutdownServices();
if (!Args.getInstance().isSolidityNode() && (!Args.getInstance().p2pDisable)) {
if (!Args.getInstance().isSolidityNode() && !Args.getInstance().p2pDisable) {
tronNetService.close();
}
consensusService.stop();
eventService.close();
if (solidityNode != null) {
solidityNode.close();
}
dbManager.close();
shutdown.countDown();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public Block getBlock(long blockNum) {
}

public void shutdown() {
channel.shutdown();
channel.shutdownNow();
}

public DynamicProperties getDynamicProperties() {
Expand Down
17 changes: 0 additions & 17 deletions framework/src/main/java/org/tron/core/db/Manager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1042,23 +1042,6 @@ public void eraseBlock() {
}
}

public void pushVerifiedBlock(BlockCapsule block) throws ContractValidateException,
ContractExeException, ValidateSignatureException, AccountResourceInsufficientException,
TransactionExpirationException, TooBigTransactionException, DupTransactionException,
TaposException, ValidateScheduleException, ReceiptCheckErrException,
VMIllegalException, TooBigTransactionResultException, UnLinkedBlockException,
NonCommonBlockException, BadNumberBlockException, BadBlockException, ZksnarkException,
EventBloomException {
block.generatedByMyself = true;
long start = System.currentTimeMillis();
pushBlock(block);
logger.info("Push block cost: {} ms, blockNum: {}, blockHash: {}, trx count: {}.",
System.currentTimeMillis() - start,
block.getNum(),
block.getBlockId(),
block.getTransactions().size());
}

private void applyBlock(BlockCapsule block) throws ContractValidateException,
ContractExeException, ValidateSignatureException, AccountResourceInsufficientException,
TransactionExpirationException, TooBigTransactionException, DupTransactionException,
Expand Down
13 changes: 13 additions & 0 deletions framework/src/main/java/org/tron/core/net/TronNetDelegate.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,19 @@ public Message getData(Sha256Hash hash, InventoryType type) throws P2pException
}
}

public void pushVerifiedBlock(BlockCapsule block) throws P2pException {
block.generatedByMyself = true;
long start = System.currentTimeMillis();
processBlock(block, true);
if (!hitDown) {
logger.info("Push block cost: {} ms, blockNum: {}, blockHash: {}, trx count: {}.",
System.currentTimeMillis() - start,
block.getNum(),
block.getBlockId(),
block.getTransactions().size());
}
}

public void processBlock(BlockCapsule block, boolean isSync) throws P2pException {
if (!hitDown && dbManager.getLatestSolidityNumShutDown() > 0
&& dbManager.getLatestSolidityNumShutDown() == dbManager.getDynamicPropertiesStore()
Expand Down
25 changes: 17 additions & 8 deletions framework/src/main/java/org/tron/program/FullNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.util.ObjectUtils;
import org.tron.common.application.Application;
import org.tron.common.application.ApplicationFactory;
import org.tron.common.application.TronApplicationContext;
Expand All @@ -28,19 +29,23 @@ public static void main(String[] args) {

LogService.load(parameter.getLogbackPath());

if (parameter.isSolidityNode()) {
SolidityNode.start();
return;
}
if (parameter.isKeystoreFactory()) {
KeystoreFactory.start();
return;
}
logger.info("Full node running.");
if (Args.getInstance().isDebug()) {
logger.info("in debug mode, it won't check energy time");
if (parameter.isSolidityNode()) {
logger.info("Solidity node is running.");
if (ObjectUtils.isEmpty(parameter.getTrustNodeAddr())) {
throw new TronError(new IllegalArgumentException("Trust node is not set."),
TronError.ErrCode.SOLID_NODE_INIT);
}
} else {
logger.info("not in debug mode, it will check energy time");
logger.info("Full node running.");
if (Args.getInstance().isDebug()) {
logger.info("in debug mode, it won't check energy time");
} else {
logger.info("not in debug mode, it will check energy time");
}
}

// init metrics first
Expand All @@ -55,6 +60,10 @@ public static void main(String[] args) {
Application appT = ApplicationFactory.create(context);
context.registerShutdownHook();
appT.startup();
if (parameter.isSolidityNode()) {
SolidityNode node = context.getBean(SolidityNode.class);
node.run();
}
appT.blockUntilShutdown();
}

Expand Down
Loading
Loading