forked from Qortal/qortal
Added FATJAR packaging support to pom.xml Added some "summary" fields to API calls but more need doing. Corrected path clash from having unnecessary @OpenAPIDefinition annotations. Added API "tags" to group similar calls (address-based, block-related, etc.) Fixed addresses/lastreference/{address} Implemented addresses/lastreference/{address}/unconfirmed Implemented addresses/assets/{address} Added /admin/stop and /admin/uptime API calls. Moved general API info into new src/api/ApiDefinition.java Added CORS support to ApiService Added /transactions/address/{address} and /transactions/block/{signature} Replaced references to test.Common.* to do with repository factory. This fixes issues with building FATJAR due to references to test classes that are omitted from FATJAR. Changes to AccountBalanceData, BlockData and TransactionData to support JAX-RS rendering to JSON. Added getUnconfirmedLastReference() to Account. Added getAllBalances(address) to account repository - returns all asset balances for that address. Added getAllSignaturesInvolvingAddress(address) to account repository but currently only uses TransactionRecipients HSQLDB table. (And even that wasn't automatically populated). Included: very basic block explorer to be opened in browser as a file: block-explorer.html
76 lines
1.9 KiB
Java
76 lines
1.9 KiB
Java
import java.security.SecureRandom;
|
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
import qora.block.BlockChain;
|
|
import qora.block.BlockGenerator;
|
|
import repository.DataException;
|
|
import repository.RepositoryFactory;
|
|
import repository.RepositoryManager;
|
|
import repository.hsqldb.HSQLDBRepositoryFactory;
|
|
import utils.Base58;
|
|
|
|
public class blockgenerator {
|
|
|
|
private static final Logger LOGGER = LogManager.getLogger(blockgenerator.class);
|
|
public static final String connectionUrl = "jdbc:hsqldb:file:db/test;create=true";
|
|
|
|
public static void main(String[] args) {
|
|
if (args.length != 1) {
|
|
System.err.println("usage: blockgenerator private-key-base58 | 'RANDOM'");
|
|
System.err.println("example: blockgenerator 7Vg53HrETZZuVySMPWJnVwQESS3dV8jCXPL5GDHMCeKS");
|
|
System.exit(1);
|
|
}
|
|
|
|
byte[] privateKey;
|
|
|
|
if (args[0].equalsIgnoreCase("RANDOM")) {
|
|
privateKey = new byte[32];
|
|
new SecureRandom().nextBytes(privateKey);
|
|
} else {
|
|
privateKey = Base58.decode(args[0]);
|
|
}
|
|
|
|
try {
|
|
RepositoryFactory repositoryFactory = new HSQLDBRepositoryFactory(connectionUrl);
|
|
RepositoryManager.setRepositoryFactory(repositoryFactory);
|
|
} catch (DataException e) {
|
|
LOGGER.error("Couldn't connect to repository", e);
|
|
System.exit(2);
|
|
}
|
|
|
|
try {
|
|
BlockChain.validate();
|
|
} catch (DataException e) {
|
|
LOGGER.error("Couldn't validate repository", e);
|
|
System.exit(2);
|
|
}
|
|
|
|
BlockGenerator blockGenerator = new BlockGenerator(privateKey);
|
|
blockGenerator.start();
|
|
|
|
Runtime.getRuntime().addShutdownHook(new Thread() {
|
|
@Override
|
|
public void run() {
|
|
blockGenerator.shutdown();
|
|
|
|
try {
|
|
blockGenerator.join();
|
|
} catch (InterruptedException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
|
|
try {
|
|
RepositoryManager.closeRepositoryFactory();
|
|
} catch (DataException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
}
|