diff --git a/.gitignore b/.gitignore index 61de10a5c2b..f69d0d2a469 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ gradlew.bat # log logs +consensus-logs # lombok out diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d2c6acb3cfd..142e55c2912 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,7 +25,7 @@ for us. We will appreciate it. ### Create issues Any significant improvement should be documented as [a GitHub -issue](https://github.com/tron-network/java-tron/issues) before anybody +issue](https://github.com/tronprotocol/java-tron/issues) before anybody starts working on it. Also when filing an issue, make sure to answer these three questions: diff --git a/README.md b/README.md index 13d8bb9da5d..9393b4731d5 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,14 @@ -# What’s TRON? [![Build Status](https://www.travis-ci.org/tron-network/java-tron.svg?branch=develop)](https://www.travis-ci.org/tron-network/java-tron) +

+        +[![Build Status](https://travis-ci.org/tronprotocol/java-tron.svg?branch=feature%2Fconsensus)](https://travis-ci.org/tronprotocol/java-tron) +[![GitHub last commit](https://img.shields.io/github/last-commit/tronprotocol/java-tron.svg)](https://github.com/tronprotocol/java-tron/commits/develop) +[![GitHub issues](https://img.shields.io/github/issues/tronprotocol/java-tron.svg)](https://github.com/tronprotocol/java-tron/issues) +[![GitHub pull requests](https://img.shields.io/github/issues-pr/tronprotocol/java-tron.svg)](https://github.com/tronprotocol/java-tron/pulls) +[![GitHub contributors](https://img.shields.io/github/contributors/tronprotocol/java-tron.svg)](https://github.com/tronprotocol/java-tron/graphs/contributors) +[![license](https://img.shields.io/github/license/tronprotocol/java-tron.svg)](LICENSE) + +# What's TRON? TRON is a block chain-based decentralized smart protocol and an application development platform. It allows each user to freely publish, store and own contents and data, and in the decentralized autonomous form, decides an incentive mechanism and enables application developers and content creators through digital asset distribution, circulation and transaction, thus forming a decentralized content entertainment ecosystem. TRON is a product of Web 4.0 and the decentralized internet of next generation. @@ -9,29 +18,90 @@ TRON is a product of Web 4.0 and the decentralized internet of next generation. **Download and build** ```shell -> git clone https://github.com/tron-network/java-tron.git +> git clone https://github.com/tronprotocol/java-tron.git > cd java-tron > gradle build ``` **Import project to IDEA** -1. [File] -> [New] -> [Project from Existing Sources...] -2. Select java-tron/build.gradle -3. Dialog [Import Project from Gradle], confirm [Use auto-import] and [Use gradle wrapper task configuration] have been +- [File] -> [New] -> [Project from Existing Sources...] +- Select java-tron/build.gradle +- Dialog [Import Project from Gradle], confirm [Use auto-import] and [Use gradle wrapper task configuration] have been selected,then select Gradle JVM(JDK 1.8)and click [OK] # Testing -- Install Kafka, create two topics (block and transaction) -- Adjust constant **DEFAULT_BOOTSTRAP_SERVERS** in ConsumerProperty.java file and ProducerProperty.java file to your Kafka's host(like:192.168.1.199:9092) -- IDEA: [Edit Configurations...] -> [Program arguments]: **--type server** -- Run Tron (server) -- IDEA: [Edit Configurations...] -> [Program arguments]: **--type normal** -- Run Tron (client) -- Execute `help` command on the client +**Install Kafka and create two topics (block and transaction)** + +**Update the configuration** + +File path: `/java-tron/src/main/resources/tron.conf` + +```yml +kafka { + host = "127.0.0.1" # your Kafka's host + port = ":9092" # your Kafka's port +} +``` + +**Starting program** + +IDEA: +- [Edit Configurations...] -> [Program arguments]: `--type server` +- Run + +![run](https://github.com/tronprotocol/wiki/blob/master/images/show-how/run.gif) + +# Commands +**help** + +| Description | Example | +| --- | --- | +| Help tips | `help` | + +![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/help.gif) + +**account** + +| Description | Example | +| --- | --- | +| Get address | `account` | + +![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/account.gif) + +**getbalance** + +| Description | Example | +| --- | --- | +| Get balance | `getbalance` | + +![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/getbalance.gif) + +**send [to] [balance]** + +| Description | Example | +| --- | --- | +| Send balance to address | `send 2cddf5707aefefb199cb16430fb0f6220d460dfe 2` | + +![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/send.gif) + +**printblockchain** + +| Description | Example | +| --- | --- | +| Print blockchain | `printblockchain` | + +![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/printblockchain.gif) + +**exit** + +| Description | Example | +| --- | --- | +| Exit | `exit` | -# License +![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/exit.gif) -java-tron is released under the [LGPL-V3 license](LICENSE). +# Contribution +Contributions are welcomed and greatly appreciated. Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details on submitting patches and the contribution workflow. diff --git a/build.gradle b/build.gradle index 14f81d2ca96..157fb3fc98e 100644 --- a/build.gradle +++ b/build.gradle @@ -73,6 +73,7 @@ dependencies { compile group: 'io.atomix.copycat', name: 'copycat-server', version: '1.1.4' compile group: 'io.atomix.copycat', name: 'copycat-client', version: '1.1.4' compile group: 'io.atomix.catalyst', name: 'catalyst-netty', version: '1.1.1' + compile group: 'net.jcip', name: 'jcip-annotations', version: '1.0' } tasks.matching { it instanceof Test }.all { diff --git a/src/main/java/org/tron/command/AccountCommand.java b/src/main/java/org/tron/command/AccountCommand.java index 97414bc9749..8b71a33f2eb 100644 --- a/src/main/java/org/tron/command/AccountCommand.java +++ b/src/main/java/org/tron/command/AccountCommand.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.command; import org.tron.peer.Peer; diff --git a/src/main/java/org/tron/command/Cli.java b/src/main/java/org/tron/command/Cli.java index 0ca7bf4d780..8d3774f1608 100644 --- a/src/main/java/org/tron/command/Cli.java +++ b/src/main/java/org/tron/command/Cli.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.command; import org.tron.peer.Peer; @@ -42,6 +56,16 @@ public void run(Peer peer) { case "printblockchain": new PrintBlockchainCommand().execute(peer, cmdParameters); break; + + case "consensus": + new ConsensusCommand().server(); + break; + case "getmessage": + new ConsensusCommand().getClient(cmdParameters); + break; + case "putmessage": + new ConsensusCommand().putClient(cmdParameters); + break; case "help": default: new HelpCommand().execute(peer, cmdParameters); diff --git a/src/main/java/org/tron/command/Command.java b/src/main/java/org/tron/command/Command.java index 25d4e72f4f4..04dc0054bac 100644 --- a/src/main/java/org/tron/command/Command.java +++ b/src/main/java/org/tron/command/Command.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.command; import org.tron.peer.Peer; diff --git a/src/main/java/org/tron/command/ConsensusCommand.java b/src/main/java/org/tron/command/ConsensusCommand.java new file mode 100644 index 00000000000..7ba553f5848 --- /dev/null +++ b/src/main/java/org/tron/command/ConsensusCommand.java @@ -0,0 +1,58 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.tron.command; + +import org.tron.consensus.client.Client; +import org.tron.consensus.server.Server; + +public class ConsensusCommand { + + public ConsensusCommand() { + + } + + public void server() { + Server.serverRun(); + } + + public void putClient(String[] args) { + Client.putMessage(args); + } + + public void getClient(String[] args) { + Client.getMessage(args[0]); + } + + public void usage() { + System.out.println(""); + System.out.println("consensus server"); + System.out.println("Command: consensus"); + System.out.println("Description: Create a server."); + System.out.println(""); + + System.out.println(""); + System.out.println("get Message"); + System.out.println("Command: getmessage [key]"); + System.out.println("Description: Get consensus Message"); + System.out.println(""); + + System.out.println(""); + System.out.println("put Message"); + System.out.println("Command: putmessage [key] [value]"); + System.out.println("Description: Put a consensus Message"); + System.out.println(""); + } + +} diff --git a/src/main/java/org/tron/command/ExitCommand.java b/src/main/java/org/tron/command/ExitCommand.java index fa321698ac1..f48246966fb 100644 --- a/src/main/java/org/tron/command/ExitCommand.java +++ b/src/main/java/org/tron/command/ExitCommand.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.command; import org.tron.peer.Peer; diff --git a/src/main/java/org/tron/command/GetBalanceCommand.java b/src/main/java/org/tron/command/GetBalanceCommand.java index 69bd9f98f61..05fe3613722 100644 --- a/src/main/java/org/tron/command/GetBalanceCommand.java +++ b/src/main/java/org/tron/command/GetBalanceCommand.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.command; import org.tron.peer.Peer; diff --git a/src/main/java/org/tron/command/HelpCommand.java b/src/main/java/org/tron/command/HelpCommand.java index 722362f78fb..4a2219e8ac6 100644 --- a/src/main/java/org/tron/command/HelpCommand.java +++ b/src/main/java/org/tron/command/HelpCommand.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.command; import org.tron.peer.Peer; @@ -13,6 +27,7 @@ public void execute(Peer peer, String[] parameters) { new GetBalanceCommand().usage(); new AccountCommand().usage(); new PrintBlockchainCommand().usage(); + new ConsensusCommand().usage(); } @Override diff --git a/src/main/java/org/tron/command/PrintBlockchainCommand.java b/src/main/java/org/tron/command/PrintBlockchainCommand.java index 1d429f7b3d8..ea07992dbd7 100644 --- a/src/main/java/org/tron/command/PrintBlockchainCommand.java +++ b/src/main/java/org/tron/command/PrintBlockchainCommand.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.command; import org.tron.core.BlockUtils; diff --git a/src/main/java/org/tron/command/SendCommand.java b/src/main/java/org/tron/command/SendCommand.java index 89f24a25a1a..805d940bc96 100644 --- a/src/main/java/org/tron/command/SendCommand.java +++ b/src/main/java/org/tron/command/SendCommand.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.command; import org.slf4j.Logger; @@ -10,7 +24,7 @@ import org.tron.utils.ByteArray; public class SendCommand extends Command { - private static final Logger logger = LoggerFactory.getLogger("command"); + private static final Logger LOGGER = LoggerFactory.getLogger("Command"); public SendCommand() { } @@ -42,12 +56,12 @@ public void usage() { @Override public boolean check(String[] parameters) { if (parameters.length < 2) { - logger.error("missing parameters"); + LOGGER.error("missing parameters"); return false; } if (parameters[0].length() != 40) { - logger.error("address invalid"); + LOGGER.error("address invalid"); return false; } @@ -56,12 +70,12 @@ public boolean check(String[] parameters) { try { amount = Long.valueOf(parameters[1]); } catch (NumberFormatException e) { - logger.error("amount invalid"); + LOGGER.error("amount invalid"); return false; } if (amount <= 0) { - logger.error("amount required a positive number"); + LOGGER.error("amount required a positive number"); return false; } diff --git a/src/main/java/org/tron/config/Configer.java b/src/main/java/org/tron/config/Configer.java index 47b468e155a..a36ca943313 100644 --- a/src/main/java/org/tron/config/Configer.java +++ b/src/main/java/org/tron/config/Configer.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.config; import com.typesafe.config.Config; @@ -12,7 +26,7 @@ import java.util.Properties; public class Configer { - private static Logger logger = LoggerFactory.getLogger("configer"); + private static final Logger LOGGER = LoggerFactory.getLogger("Configer"); private final static String TRON_CONF = "tron.conf"; private final static String DATABASE_DIRECTORY = "database.directory"; @@ -42,9 +56,9 @@ public class Configer { try (Writer w = new FileWriter(file)) { props.store(w, "Generated NodeID."); } - logger.info("New nodeID generated: " + props.getProperty + LOGGER.info("New nodeID generated: " + props.getProperty ("nodeId")); - logger.info("Generated nodeID and its private key stored " + + LOGGER.info("Generated nodeID and its private key stored " + "in " + file); } generatedNodePrivateKey = props.getProperty("nodeIdPrivateKey"); diff --git a/src/main/java/org/tron/config/SystemProperties.java b/src/main/java/org/tron/config/SystemProperties.java index aa8643295f7..d2e136abc42 100644 --- a/src/main/java/org/tron/config/SystemProperties.java +++ b/src/main/java/org/tron/config/SystemProperties.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.config; import com.typesafe.config.Config; @@ -9,8 +23,6 @@ public class SystemProperties { private @interface ValidateMe { } - ; - private static SystemProperties CONFIG; private static boolean useOnlySpringConfig = false; diff --git a/src/main/java/org/tron/consensus/client/Client.java b/src/main/java/org/tron/consensus/client/Client.java new file mode 100644 index 00000000000..8c7d82bc86e --- /dev/null +++ b/src/main/java/org/tron/consensus/client/Client.java @@ -0,0 +1,74 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.tron.consensus.client; + +import io.atomix.catalyst.transport.Address; +import io.atomix.catalyst.transport.netty.NettyTransport; +import io.atomix.copycat.client.ConnectionStrategies; +import io.atomix.copycat.client.CopycatClient; +import org.tron.consensus.common.GetQuery; +import org.tron.consensus.common.PutCommand; + +import java.util.Arrays; +import java.util.Collection; +import java.util.concurrent.CompletableFuture; + +public class Client { + + private static CopycatClient client = null; + + static { + client = CopycatClient.builder() + .withTransport(NettyTransport.builder() + .withThreads(2) + .build()) + .withConnectionStrategy(ConnectionStrategies.FIBONACCI_BACKOFF) + .build(); + + client.serializer().register(PutCommand.class); + client.serializer().register(GetQuery.class); + + Collection
cluster = Arrays.asList( + new Address("192.168.0.108", 5000) + + ); + + CompletableFuture future = client.connect(cluster); + future.join(); + } + + public static CopycatClient getClient() { + return client; + } + + public static void putMessage(String[] args) { + String key = args[0]; + String value = args[1]; + client.submit(new PutCommand(key, value)); + System.out.println("Put message success"); + } + + public static void getMessage1(String key) { + client.submit(new GetQuery(key)).thenAccept(result -> { + System.out.println("Consensus " + key + " is: " + + result); + }); + } + public static void getMessage(String key) { + Object result = client.submit(new GetQuery(key)).join(); + System.out.println("Consensus " + key + " is: " + result); + + } +} diff --git a/src/main/java/org/tron/consensus/common/GetQuery.java b/src/main/java/org/tron/consensus/common/GetQuery.java index c65f0f52497..f47686dfbb7 100644 --- a/src/main/java/org/tron/consensus/common/GetQuery.java +++ b/src/main/java/org/tron/consensus/common/GetQuery.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.consensus.common; import io.atomix.copycat.Query; diff --git a/src/main/java/org/tron/consensus/common/MapstateMachine.java b/src/main/java/org/tron/consensus/common/MapstateMachine.java index 16dd01e0e8a..9ce321fea3a 100644 --- a/src/main/java/org/tron/consensus/common/MapstateMachine.java +++ b/src/main/java/org/tron/consensus/common/MapstateMachine.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.consensus.common; import io.atomix.copycat.server.Commit; diff --git a/src/main/java/org/tron/consensus/common/PutCommand.java b/src/main/java/org/tron/consensus/common/PutCommand.java index 07c82b5de92..f049bc3ee4d 100644 --- a/src/main/java/org/tron/consensus/common/PutCommand.java +++ b/src/main/java/org/tron/consensus/common/PutCommand.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.consensus.common; import io.atomix.copycat.Command; diff --git a/src/main/java/org/tron/consensus/server/Server.java b/src/main/java/org/tron/consensus/server/Server.java new file mode 100644 index 00000000000..168b240987d --- /dev/null +++ b/src/main/java/org/tron/consensus/server/Server.java @@ -0,0 +1,78 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.tron.consensus.server; + +import io.atomix.catalyst.transport.Address; +import io.atomix.catalyst.transport.netty.NettyTransport; +import io.atomix.copycat.server.CopycatServer; +import io.atomix.copycat.server.storage.Storage; +import io.atomix.copycat.server.storage.StorageLevel; +import org.tron.consensus.common.GetQuery; +import org.tron.consensus.common.MapstateMachine; +import org.tron.consensus.common.PutCommand; + +import java.io.File; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.concurrent.CompletableFuture; + +public class Server { + public static void serverRun() { + + InetAddress localhost = null; + try { + localhost = InetAddress.getLocalHost(); + System.out.println("Server localhost: " + localhost.getHostAddress + ()); + + Address address = new Address(localhost.getHostAddress(), 5000); + + CopycatServer server = CopycatServer.builder(address) + .withStateMachine(MapstateMachine::new) + .withTransport(NettyTransport.builder() + .withThreads(4) + .build()) + .withStorage(Storage.builder() + .withDirectory(new File("consensus-logs")) + .withStorageLevel(StorageLevel.DISK) + .build()) + .build(); + + server.serializer().register(PutCommand.class); + server.serializer().register(GetQuery.class); + + CompletableFuture future = server.bootstrap(); + future.join(); + + //Collection
cluster = Collections.singleton(new Address + // ("192.16.50.129", 5000)); + //server.join(cluster).join(); + + System.out.println("Server xxd: " + server.cluster().members()); + + CopycatServer.State state = server.state(); + System.out.println("Server state: " + state); + server.onStateChange(state1 -> { + if (state == CopycatServer.State.LEADER) { + System.out.println("Server state: " + state); + } + }); + server.context(); + + } catch (UnknownHostException e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/org/tron/core/BlockSummary.java b/src/main/java/org/tron/core/BlockSummary.java index 32df5f53f60..87e0342c4b1 100644 --- a/src/main/java/org/tron/core/BlockSummary.java +++ b/src/main/java/org/tron/core/BlockSummary.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.core; diff --git a/src/main/java/org/tron/core/BlockUtils.java b/src/main/java/org/tron/core/BlockUtils.java index ac8129d1ac9..29c581d4909 100644 --- a/src/main/java/org/tron/core/BlockUtils.java +++ b/src/main/java/org/tron/core/BlockUtils.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.core; import com.google.protobuf.ByteString; diff --git a/src/main/java/org/tron/core/Blockchain.java b/src/main/java/org/tron/core/Blockchain.java index 912a5d0b01e..7ca43b2271c 100644 --- a/src/main/java/org/tron/core/Blockchain.java +++ b/src/main/java/org/tron/core/Blockchain.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.core; import com.google.protobuf.ByteString; @@ -29,8 +43,8 @@ import static org.tron.datasource.leveldb.LevelDbDataSource.databaseName; public class Blockchain { - public static final Logger logger = LoggerFactory.getLogger("BlockChain"); - public static final String genesisCoinbaseData = "0x00"; + private static final Logger LOGGER = LoggerFactory.getLogger("Blockchain"); + public static final String GENESIS_COINBASE_DATA = "0x00"; private LevelDbDataSource blockDB = null; private PendingState pendingState = new PendingStateImpl(); @@ -44,7 +58,7 @@ public class Blockchain { */ public Blockchain(String address) { if (dbExists()) { - logger.info("blockchain already exists."); + LOGGER.info("blockchain already exists."); System.exit(0); } @@ -52,7 +66,7 @@ public Blockchain(String address) { blockDB.init(); Transaction coinbase = TransactionUtils.newCoinbaseTransaction - (address, genesisCoinbaseData); + (address, GENESIS_COINBASE_DATA); Block genesisBlock = BlockUtils.newGenesisBlock(coinbase); this.lastHash = genesisBlock.getBlockHeader().getHash().toByteArray(); @@ -66,7 +80,7 @@ public Blockchain(String address) { blockDB.put(LAST_HASH, lastHash); - logger.info("new blockchain"); + LOGGER.info("new blockchain"); } /** @@ -74,7 +88,7 @@ public Blockchain(String address) { */ public Blockchain() { if (!dbExists()) { - logger.info("no existing blockchain found. please create one " + + LOGGER.info("no existing blockchain found. please create one " + "first"); System.exit(0); } @@ -85,7 +99,7 @@ public Blockchain() { this.lastHash = blockDB.get(LAST_HASH); this.currentHash = this.lastHash; - logger.info("load blockchain"); + LOGGER.info("load blockchain"); } /** @@ -277,7 +291,7 @@ public void receiveBlock(Block block, UTXOSet utxoSet) { } public static String getGenesisCoinbaseData() { - return genesisCoinbaseData; + return GENESIS_COINBASE_DATA; } public LevelDbDataSource getBlockDB() { diff --git a/src/main/java/org/tron/core/BlockchainIterator.java b/src/main/java/org/tron/core/BlockchainIterator.java index 20b7776cbf8..a15935b4d54 100644 --- a/src/main/java/org/tron/core/BlockchainIterator.java +++ b/src/main/java/org/tron/core/BlockchainIterator.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.core; import com.google.protobuf.InvalidProtocolBufferException; @@ -20,7 +34,7 @@ public BlockchainIterator(Blockchain blockchain) { @Override public boolean hasNext() { - return (index == null || index.length == 0); + return !(index == null || index.length == 0); } @Override diff --git a/src/main/java/org/tron/core/Constant.java b/src/main/java/org/tron/core/Constant.java index b6f3a77309e..0273ba07e9c 100644 --- a/src/main/java/org/tron/core/Constant.java +++ b/src/main/java/org/tron/core/Constant.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.core; import org.tron.utils.ByteArray; diff --git a/src/main/java/org/tron/core/ImportResult.java b/src/main/java/org/tron/core/ImportResult.java index 99af0fd1ace..957018337b5 100644 --- a/src/main/java/org/tron/core/ImportResult.java +++ b/src/main/java/org/tron/core/ImportResult.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.core; public enum ImportResult { diff --git a/src/main/java/org/tron/core/PendingState.java b/src/main/java/org/tron/core/PendingState.java index 59bb0fb9273..ab20e2c8358 100644 --- a/src/main/java/org/tron/core/PendingState.java +++ b/src/main/java/org/tron/core/PendingState.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.core; diff --git a/src/main/java/org/tron/core/PendingStateImpl.java b/src/main/java/org/tron/core/PendingStateImpl.java index 17702abd258..cfbdab87ec2 100644 --- a/src/main/java/org/tron/core/PendingStateImpl.java +++ b/src/main/java/org/tron/core/PendingStateImpl.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.core; import org.apache.commons.collections4.map.LRUMap; @@ -43,7 +57,6 @@ public void addPendingTransaction(Transaction tx) { public synchronized void addPendingTransaction(Blockchain blockchain, Transaction tx, Net net) { pendingTransactions.add(tx); if (pendingTransactions.size() == 1) { - System.out.println("pending..."); blockchain.addBlock(pendingTransactions, net); pendingTransactions.clear(); System.out.println(); diff --git a/src/main/java/org/tron/core/SpendableOutputs.java b/src/main/java/org/tron/core/SpendableOutputs.java index a64a9c0ea54..9ac540a5ca3 100644 --- a/src/main/java/org/tron/core/SpendableOutputs.java +++ b/src/main/java/org/tron/core/SpendableOutputs.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.core; import java.util.HashMap; diff --git a/src/main/java/org/tron/core/TXInputUtils.java b/src/main/java/org/tron/core/TXInputUtils.java index acbfd44d462..a7ff82e41e1 100644 --- a/src/main/java/org/tron/core/TXInputUtils.java +++ b/src/main/java/org/tron/core/TXInputUtils.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.core; import com.google.protobuf.ByteString; diff --git a/src/main/java/org/tron/core/TXOutputUtils.java b/src/main/java/org/tron/core/TXOutputUtils.java index b6953382d3e..5d1cc5d9746 100644 --- a/src/main/java/org/tron/core/TXOutputUtils.java +++ b/src/main/java/org/tron/core/TXOutputUtils.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.core; import com.google.protobuf.ByteString; diff --git a/src/main/java/org/tron/core/TransactionUtils.java b/src/main/java/org/tron/core/TransactionUtils.java index ba1674cb6b5..dedd4737283 100644 --- a/src/main/java/org/tron/core/TransactionUtils.java +++ b/src/main/java/org/tron/core/TransactionUtils.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.core; import com.google.protobuf.ByteString; @@ -8,6 +22,7 @@ import org.tron.protos.core.TronTXOutput.TXOutput; import org.tron.protos.core.TronTransaction.Transaction; import org.tron.utils.ByteArray; +import org.tron.wallet.Wallet; import java.security.SecureRandom; import java.util.ArrayList; @@ -19,8 +34,8 @@ import static org.tron.utils.Utils.getRandom; public class TransactionUtils { - private static final Logger logger = LoggerFactory.getLogger("transaction"); - private final static int subsidy = 10; // Mining reward + private static final Logger LOGGER = LoggerFactory.getLogger("Transaction"); + private final static int RESERVE_BALANCE = 10; public static Transaction newTransaction(Wallet wallet, String to, long amount, UTXOSet utxoSet) { ArrayList txInputs = new ArrayList<>(); @@ -31,7 +46,7 @@ public static Transaction newTransaction(Wallet wallet, String to, long amount, SpendableOutputs spendableOutputs = utxoSet.findSpendableOutputs(pubKeyHash, amount); if (spendableOutputs.getAmount() < amount) { - logger.error("Not enough funds"); + LOGGER.error("Not enough funds"); return null; } @@ -86,7 +101,7 @@ public static Transaction newCoinbaseTransaction(String to, String data) { TXInput txi = TXInputUtils.newTXInput(new byte[]{}, -1, new byte[]{}, ByteArray.fromHexString(data)); - TXOutput txo = TXOutputUtils.newTXOutput(subsidy, to); + TXOutput txo = TXOutputUtils.newTXOutput(RESERVE_BALANCE, to); Transaction.Builder coinbaseTransaction = Transaction.newBuilder() .addVin(txi) @@ -192,7 +207,7 @@ public static Transaction sign(Transaction transaction, ECKey myKey, for (TXInput vin : transaction.getVinList()) { if (prevTXs.get(ByteArray.toHexString(vin.getTxID().toByteArray() )).getId().toByteArray().length == 0) { - logger.error("ERROR: Previous transaction is not correct"); + LOGGER.error("ERROR: Previous transaction is not correct"); return null; } } @@ -236,7 +251,7 @@ public static boolean verify(ECKey myKey, Transaction transaction, for (TXInput vin : transaction.getVinList()) { if (prevTXs.get(ByteArray.toHexString(vin.getTxID().toByteArray() )).getId().toByteArray().length == 0) { - logger.error("ERROR: Previous transaction is not correct"); + LOGGER.error("ERROR: Previous transaction is not correct"); } } diff --git a/src/main/java/org/tron/core/TronBlockChain.java b/src/main/java/org/tron/core/TronBlockChain.java index 62b3d6f7251..63b9b7a6044 100644 --- a/src/main/java/org/tron/core/TronBlockChain.java +++ b/src/main/java/org/tron/core/TronBlockChain.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.core; diff --git a/src/main/java/org/tron/core/TronBlockChainImpl.java b/src/main/java/org/tron/core/TronBlockChainImpl.java index 7edb2024658..90f05b92922 100644 --- a/src/main/java/org/tron/core/TronBlockChainImpl.java +++ b/src/main/java/org/tron/core/TronBlockChainImpl.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.core; @@ -24,7 +38,7 @@ public class TronBlockChainImpl implements TronBlockChain, org.tron.facade .TronBlockChain { - private static final Logger logger = LoggerFactory.getLogger("blockchain"); + private static final Logger LOGGER = LoggerFactory.getLogger("Blockchain"); SystemProperties config = SystemProperties.getDefault(); @@ -120,7 +134,7 @@ private void recordBlock(TronBlock.Block block) { bw.write("\n"); } catch (IOException e) { - logger.error(e.getMessage(), e); + LOGGER.error(e.getMessage(), e); } finally { try { if (bw != null) bw.close(); diff --git a/src/main/java/org/tron/core/UTXOSet.java b/src/main/java/org/tron/core/UTXOSet.java index 347ea3fbbb3..c79d206384a 100644 --- a/src/main/java/org/tron/core/UTXOSet.java +++ b/src/main/java/org/tron/core/UTXOSet.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.core; import com.google.protobuf.InvalidProtocolBufferException; @@ -15,7 +29,7 @@ import static org.tron.core.Constant.TRANSACTION_DB_NAME; public class UTXOSet { - private static final Logger logger = LoggerFactory.getLogger("UTXOSet"); + private static final Logger LOGGER = LoggerFactory.getLogger("UTXOSet"); private Blockchain blockchain; private LevelDbDataSource txDB = null; @@ -34,7 +48,7 @@ public void setBlockchain(Blockchain blockchain) { } public void reindex() { - logger.info("reindex"); + LOGGER.info("reindex"); txDB.reset(); diff --git a/src/main/java/org/tron/crypto/ECKey.java b/src/main/java/org/tron/crypto/ECKey.java index d16d5ab51a5..67f06cc98ab 100644 --- a/src/main/java/org/tron/crypto/ECKey.java +++ b/src/main/java/org/tron/crypto/ECKey.java @@ -1,7 +1,19 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.crypto; -import org.tron.crypto.jce.*; -import org.tron.utils.ByteUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.spongycastle.asn1.ASN1InputStream; @@ -28,6 +40,8 @@ import org.spongycastle.util.BigIntegers; import org.spongycastle.util.encoders.Base64; import org.spongycastle.util.encoders.Hex; +import org.tron.crypto.jce.*; +import org.tron.utils.ByteUtil; import javax.annotation.Nullable; import javax.crypto.KeyAgreement; @@ -45,7 +59,7 @@ import static org.tron.utils.ByteUtil.bigIntegerToBytes; public class ECKey implements Serializable { - private static final Logger logger = LoggerFactory.getLogger(ECKey.class); + private static final Logger LOGGER = LoggerFactory.getLogger(ECKey.class); private static final BigInteger SECP256K1N = new BigInteger ("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141", 16); @@ -965,7 +979,7 @@ public static boolean verify(byte[] data, ECDSASignature signature, // specially crafted signatures. // Those signatures are inherently invalid/attack sigs so we just // fail them here rather than crash the thread. - logger.error("Caught NPE inside bouncy castle", npe); + LOGGER.error("Caught NPE inside bouncy castle", npe); return false; } } diff --git a/src/main/java/org/tron/crypto/Hash.java b/src/main/java/org/tron/crypto/Hash.java index ef00a4e747f..45a4fb0a731 100644 --- a/src/main/java/org/tron/crypto/Hash.java +++ b/src/main/java/org/tron/crypto/Hash.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.crypto; import org.slf4j.Logger; diff --git a/src/main/java/org/tron/crypto/cryptohash/Digest.java b/src/main/java/org/tron/crypto/cryptohash/Digest.java index 64b98814005..145f1bfbad0 100644 --- a/src/main/java/org/tron/crypto/cryptohash/Digest.java +++ b/src/main/java/org/tron/crypto/cryptohash/Digest.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.crypto.cryptohash; public interface Digest { diff --git a/src/main/java/org/tron/crypto/cryptohash/DigestEngine.java b/src/main/java/org/tron/crypto/cryptohash/DigestEngine.java index ccf2459033d..c699bccdb84 100644 --- a/src/main/java/org/tron/crypto/cryptohash/DigestEngine.java +++ b/src/main/java/org/tron/crypto/cryptohash/DigestEngine.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.crypto.cryptohash; import java.security.MessageDigest; diff --git a/src/main/java/org/tron/crypto/cryptohash/Keccak256.java b/src/main/java/org/tron/crypto/cryptohash/Keccak256.java index 06978f9cd9e..11e2caf1436 100644 --- a/src/main/java/org/tron/crypto/cryptohash/Keccak256.java +++ b/src/main/java/org/tron/crypto/cryptohash/Keccak256.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.crypto.cryptohash; public class Keccak256 extends KeccakCore { diff --git a/src/main/java/org/tron/crypto/cryptohash/Keccak512.java b/src/main/java/org/tron/crypto/cryptohash/Keccak512.java index 5f274645568..d2fe7d80e4d 100644 --- a/src/main/java/org/tron/crypto/cryptohash/Keccak512.java +++ b/src/main/java/org/tron/crypto/cryptohash/Keccak512.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.crypto.cryptohash; public class Keccak512 extends KeccakCore { diff --git a/src/main/java/org/tron/crypto/cryptohash/KeccakCore.java b/src/main/java/org/tron/crypto/cryptohash/KeccakCore.java index e8d0c189a99..57ea80b005f 100644 --- a/src/main/java/org/tron/crypto/cryptohash/KeccakCore.java +++ b/src/main/java/org/tron/crypto/cryptohash/KeccakCore.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.crypto.cryptohash; abstract class KeccakCore extends DigestEngine { diff --git a/src/main/java/org/tron/crypto/jce/ECAlgorithmParameters.java b/src/main/java/org/tron/crypto/jce/ECAlgorithmParameters.java index 2d3cd524696..619d54fb622 100644 --- a/src/main/java/org/tron/crypto/jce/ECAlgorithmParameters.java +++ b/src/main/java/org/tron/crypto/jce/ECAlgorithmParameters.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.crypto.jce; import java.io.IOException; diff --git a/src/main/java/org/tron/crypto/jce/ECKeyAgreement.java b/src/main/java/org/tron/crypto/jce/ECKeyAgreement.java index 85f16facfc0..b27d8cd69eb 100644 --- a/src/main/java/org/tron/crypto/jce/ECKeyAgreement.java +++ b/src/main/java/org/tron/crypto/jce/ECKeyAgreement.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.crypto.jce; import javax.crypto.KeyAgreement; diff --git a/src/main/java/org/tron/crypto/jce/ECKeyFactory.java b/src/main/java/org/tron/crypto/jce/ECKeyFactory.java index 8c55e31f21c..f992a3a02ea 100644 --- a/src/main/java/org/tron/crypto/jce/ECKeyFactory.java +++ b/src/main/java/org/tron/crypto/jce/ECKeyFactory.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.crypto.jce; import java.security.KeyFactory; diff --git a/src/main/java/org/tron/crypto/jce/ECKeyPairGenerator.java b/src/main/java/org/tron/crypto/jce/ECKeyPairGenerator.java index 6e85315fd11..27f4a1e2824 100644 --- a/src/main/java/org/tron/crypto/jce/ECKeyPairGenerator.java +++ b/src/main/java/org/tron/crypto/jce/ECKeyPairGenerator.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.crypto.jce; import java.security.*; diff --git a/src/main/java/org/tron/crypto/jce/ECSignatureFactory.java b/src/main/java/org/tron/crypto/jce/ECSignatureFactory.java index e0998848582..e75403a6b2a 100644 --- a/src/main/java/org/tron/crypto/jce/ECSignatureFactory.java +++ b/src/main/java/org/tron/crypto/jce/ECSignatureFactory.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.crypto.jce; import java.security.NoSuchAlgorithmException; diff --git a/src/main/java/org/tron/crypto/jce/TronCastleProvider.java b/src/main/java/org/tron/crypto/jce/TronCastleProvider.java index 58b0acea489..9eb537f3bb6 100644 --- a/src/main/java/org/tron/crypto/jce/TronCastleProvider.java +++ b/src/main/java/org/tron/crypto/jce/TronCastleProvider.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.crypto.jce; import org.spongycastle.jce.provider.BouncyCastleProvider; diff --git a/src/main/java/org/tron/datasource/AbstractCachedSource.java b/src/main/java/org/tron/datasource/AbstractCachedSource.java index 8ef35fc505a..2f318408c1c 100644 --- a/src/main/java/org/tron/datasource/AbstractCachedSource.java +++ b/src/main/java/org/tron/datasource/AbstractCachedSource.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.datasource; diff --git a/src/main/java/org/tron/datasource/AbstractChainedSource.java b/src/main/java/org/tron/datasource/AbstractChainedSource.java index 797a46982eb..001364f08a4 100644 --- a/src/main/java/org/tron/datasource/AbstractChainedSource.java +++ b/src/main/java/org/tron/datasource/AbstractChainedSource.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.datasource; diff --git a/src/main/java/org/tron/datasource/BatchSource.java b/src/main/java/org/tron/datasource/BatchSource.java index 1cd8e344ff6..2b2724f5790 100644 --- a/src/main/java/org/tron/datasource/BatchSource.java +++ b/src/main/java/org/tron/datasource/BatchSource.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.datasource; import java.util.Map; diff --git a/src/main/java/org/tron/datasource/CachedSource.java b/src/main/java/org/tron/datasource/CachedSource.java index d297e6dc427..9cf54ec7c6a 100644 --- a/src/main/java/org/tron/datasource/CachedSource.java +++ b/src/main/java/org/tron/datasource/CachedSource.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.datasource; import java.util.Collection; diff --git a/src/main/java/org/tron/datasource/DataSourceArray.java b/src/main/java/org/tron/datasource/DataSourceArray.java index 6ead4f851b5..5a7cf93e5e0 100644 --- a/src/main/java/org/tron/datasource/DataSourceArray.java +++ b/src/main/java/org/tron/datasource/DataSourceArray.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.datasource; diff --git a/src/main/java/org/tron/datasource/DbSource.java b/src/main/java/org/tron/datasource/DbSource.java index 8393ccf4316..e1305352795 100644 --- a/src/main/java/org/tron/datasource/DbSource.java +++ b/src/main/java/org/tron/datasource/DbSource.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.datasource; import java.util.Set; diff --git a/src/main/java/org/tron/datasource/MemSizeEstimator.java b/src/main/java/org/tron/datasource/MemSizeEstimator.java index 9b66242f6ca..95343b9e1ea 100644 --- a/src/main/java/org/tron/datasource/MemSizeEstimator.java +++ b/src/main/java/org/tron/datasource/MemSizeEstimator.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.datasource; diff --git a/src/main/java/org/tron/datasource/NoDeleteSource.java b/src/main/java/org/tron/datasource/NoDeleteSource.java index a4be5c03a88..651e5055237 100644 --- a/src/main/java/org/tron/datasource/NoDeleteSource.java +++ b/src/main/java/org/tron/datasource/NoDeleteSource.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.datasource; diff --git a/src/main/java/org/tron/datasource/ObjectDataSource.java b/src/main/java/org/tron/datasource/ObjectDataSource.java index cf05248a876..a9edaa6b0bc 100644 --- a/src/main/java/org/tron/datasource/ObjectDataSource.java +++ b/src/main/java/org/tron/datasource/ObjectDataSource.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.datasource; diff --git a/src/main/java/org/tron/datasource/ReadCache.java b/src/main/java/org/tron/datasource/ReadCache.java index a067b885af3..995c304562d 100644 --- a/src/main/java/org/tron/datasource/ReadCache.java +++ b/src/main/java/org/tron/datasource/ReadCache.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.datasource; diff --git a/src/main/java/org/tron/datasource/Serializer.java b/src/main/java/org/tron/datasource/Serializer.java index f347b502b01..c93cd1cb8a8 100644 --- a/src/main/java/org/tron/datasource/Serializer.java +++ b/src/main/java/org/tron/datasource/Serializer.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.datasource; diff --git a/src/main/java/org/tron/datasource/Serializers.java b/src/main/java/org/tron/datasource/Serializers.java index 4f35398c580..959329e16d3 100644 --- a/src/main/java/org/tron/datasource/Serializers.java +++ b/src/main/java/org/tron/datasource/Serializers.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.datasource; public class Serializers { diff --git a/src/main/java/org/tron/datasource/Source.java b/src/main/java/org/tron/datasource/Source.java index 3709196bdf3..8f1d49e915d 100644 --- a/src/main/java/org/tron/datasource/Source.java +++ b/src/main/java/org/tron/datasource/Source.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.datasource; diff --git a/src/main/java/org/tron/datasource/SourceChainBox.java b/src/main/java/org/tron/datasource/SourceChainBox.java index 61e40bf0eef..c833c6ebd80 100644 --- a/src/main/java/org/tron/datasource/SourceChainBox.java +++ b/src/main/java/org/tron/datasource/SourceChainBox.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.datasource; diff --git a/src/main/java/org/tron/datasource/SourceCodec.java b/src/main/java/org/tron/datasource/SourceCodec.java index e7056e82f68..0888a2b153e 100644 --- a/src/main/java/org/tron/datasource/SourceCodec.java +++ b/src/main/java/org/tron/datasource/SourceCodec.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.datasource; diff --git a/src/main/java/org/tron/datasource/inmem/HashMapDB.java b/src/main/java/org/tron/datasource/inmem/HashMapDB.java index 0f86f98a709..ea6f47b46f4 100644 --- a/src/main/java/org/tron/datasource/inmem/HashMapDB.java +++ b/src/main/java/org/tron/datasource/inmem/HashMapDB.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.datasource.inmem; diff --git a/src/main/java/org/tron/datasource/leveldb/LevelDbDataSource.java b/src/main/java/org/tron/datasource/leveldb/LevelDbDataSource.java index 087cbd45910..4c96d14d447 100644 --- a/src/main/java/org/tron/datasource/leveldb/LevelDbDataSource.java +++ b/src/main/java/org/tron/datasource/leveldb/LevelDbDataSource.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.datasource.leveldb; import org.iq80.leveldb.*; @@ -23,7 +37,7 @@ public class LevelDbDataSource implements DbSource { - private static final Logger logger = LoggerFactory.getLogger("db"); + private static final Logger LOGGER = LoggerFactory.getLogger("DB"); private final static String LEVEL_DB_DIRECTORY = "database-test.directory"; public final static String databaseName = Configer.getConf().getString @@ -41,14 +55,14 @@ public LevelDbDataSource() { public LevelDbDataSource(String name) { this.name = name; - logger.debug("New LevelDbDataSource: " + name); + LOGGER.debug("New LevelDbDataSource: " + name); } @Override public void init() { resetDbLock.writeLock().lock(); try { - logger.debug("~> LevelDbDataSource.init(): " + name); + LOGGER.debug("~> LevelDbDataSource.init(): " + name); if (isAlive()) return; @@ -104,12 +118,12 @@ public boolean isAlive() { public void destroyDB(File fileLocation) { resetDbLock.writeLock().lock(); try { - logger.debug("Destroying existing database: " + fileLocation); + LOGGER.debug("Destroying existing database: " + fileLocation); Options options = new Options(); try { factory.destroy(fileLocation, options); } catch (IOException e) { - logger.error(e.getMessage(), e); + LOGGER.error(e.getMessage(), e); } } finally { resetDbLock.writeLock().unlock(); @@ -229,7 +243,7 @@ public void close() { db.close(); alive = false; } catch (IOException e) { - logger.error("Failed to find the db file on the close: {} ", name); + LOGGER.error("Failed to find the db file on the close: {} ", name); } } finally { resetDbLock.writeLock().unlock(); diff --git a/src/main/java/org/tron/db/AbstractBlockstore.java b/src/main/java/org/tron/db/AbstractBlockstore.java index df86b0fdbb0..91b50949a55 100644 --- a/src/main/java/org/tron/db/AbstractBlockstore.java +++ b/src/main/java/org/tron/db/AbstractBlockstore.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.db; diff --git a/src/main/java/org/tron/db/BlockStore.java b/src/main/java/org/tron/db/BlockStore.java index 3fb8a3ecf0b..c7e3bede2c5 100644 --- a/src/main/java/org/tron/db/BlockStore.java +++ b/src/main/java/org/tron/db/BlockStore.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.db; diff --git a/src/main/java/org/tron/db/BlockStores.java b/src/main/java/org/tron/db/BlockStores.java index 96386d75394..9c67ede8ee6 100644 --- a/src/main/java/org/tron/db/BlockStores.java +++ b/src/main/java/org/tron/db/BlockStores.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.db; import org.slf4j.Logger; @@ -7,7 +21,7 @@ import static org.tron.core.Constant.BLOCK_DB_NAME; public class BlockStores { - public static final Logger logger = LoggerFactory.getLogger("BlockStores"); + private static final Logger LOGGER = LoggerFactory.getLogger("BlockStores"); private LevelDbDataSource blockDbDataSource; diff --git a/src/main/java/org/tron/db/ByteArrayWrapper.java b/src/main/java/org/tron/db/ByteArrayWrapper.java index ef449711146..43b571caf19 100644 --- a/src/main/java/org/tron/db/ByteArrayWrapper.java +++ b/src/main/java/org/tron/db/ByteArrayWrapper.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.db; diff --git a/src/main/java/org/tron/db/IndexedBlockStore.java b/src/main/java/org/tron/db/IndexedBlockStore.java index 6c9794423aa..e6c6c38d5c6 100644 --- a/src/main/java/org/tron/db/IndexedBlockStore.java +++ b/src/main/java/org/tron/db/IndexedBlockStore.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.db; diff --git a/src/main/java/org/tron/db/UTXOStore.java b/src/main/java/org/tron/db/UTXOStore.java index 3882b5213f2..6704c1b18b7 100644 --- a/src/main/java/org/tron/db/UTXOStore.java +++ b/src/main/java/org/tron/db/UTXOStore.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.db; import org.slf4j.Logger; @@ -9,7 +23,7 @@ import static org.tron.core.Constant.TRANSACTION_DB_NAME; public class UTXOStore { - public static final Logger logger = LoggerFactory.getLogger("UTXOStore"); + private static final Logger LOGGER = LoggerFactory.getLogger("UTXOStore"); private LevelDbDataSource uTXODataSource; public UTXOStore( ) { diff --git a/src/main/java/org/tron/example/Tron.java b/src/main/java/org/tron/example/Tron.java index c2312e59905..d39b3bbe32c 100644 --- a/src/main/java/org/tron/example/Tron.java +++ b/src/main/java/org/tron/example/Tron.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.example; import com.beust.jcommander.JCommander; diff --git a/src/main/java/org/tron/facade/TronBlockChain.java b/src/main/java/org/tron/facade/TronBlockChain.java index 9ca77854c80..c6ed30d30d2 100644 --- a/src/main/java/org/tron/facade/TronBlockChain.java +++ b/src/main/java/org/tron/facade/TronBlockChain.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.facade; diff --git a/src/main/java/org/tron/manager/BlockLoader.java b/src/main/java/org/tron/manager/BlockLoader.java index 506b09ce178..74babbe76ab 100644 --- a/src/main/java/org/tron/manager/BlockLoader.java +++ b/src/main/java/org/tron/manager/BlockLoader.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.manager; import org.slf4j.Logger; @@ -18,7 +32,7 @@ public class BlockLoader { - private static final Logger logger = LoggerFactory.getLogger("blockqueue"); + private static final Logger LOGGER = LoggerFactory.getLogger("BlockLoader"); @Autowired private TronBlockChainImpl blockchain; @@ -49,7 +63,7 @@ public TronBlock.Block apply(TronBlock.Block block) { }, new Functional.Consumer() { @Override public void accept(Throwable throwable) { - logger.error("Unhandled exception: ", throwable); + LOGGER.error("Unhandled exception: ", throwable); } }); diff --git a/src/main/java/org/tron/overlay/Net.java b/src/main/java/org/tron/overlay/Net.java index 7c967c8fd26..f779ea2ebc0 100644 --- a/src/main/java/org/tron/overlay/Net.java +++ b/src/main/java/org/tron/overlay/Net.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.overlay; import org.tron.overlay.message.Message; diff --git a/src/main/java/org/tron/overlay/kafka/ConsumerProperty.java b/src/main/java/org/tron/overlay/kafka/ConsumerProperty.java index d5ab7451866..e27144bbb2f 100644 --- a/src/main/java/org/tron/overlay/kafka/ConsumerProperty.java +++ b/src/main/java/org/tron/overlay/kafka/ConsumerProperty.java @@ -1,9 +1,27 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.overlay.kafka; import org.tron.config.Configer; +import static org.tron.overlay.kafka.Kafka.EMPTY_STRING; +import static org.tron.overlay.kafka.Kafka.KAFKA_HOST; +import static org.tron.overlay.kafka.Kafka.KAFKA_PORT; + public class ConsumerProperty { - private final static String DEFAULT_BOOTSTRAP_SERVERS = "11.11.11.12:9092"; + private final static String DEFAULT_BOOTSTRAP_SERVERS = "127.0.0.1:9092"; private final static String DEFAULT_GROUP_ID = Configer.getGNPK(); private final static String DEFAULT_ENABLE_AUTO_COMMIT = "true"; private final static String DEFAULT_AUTO_COMMIT_INTERVAL_MS = "1000"; @@ -41,8 +59,14 @@ public ConsumerProperty( } public static ConsumerProperty getDefault() { + String bootstrapServers = Configer.getConf().getString(KAFKA_HOST) + Configer.getConf().getString(KAFKA_PORT); + + if (EMPTY_STRING.equals(bootstrapServers)) { + bootstrapServers = DEFAULT_BOOTSTRAP_SERVERS; + } + return new ConsumerProperty( - DEFAULT_BOOTSTRAP_SERVERS, + bootstrapServers, DEFAULT_GROUP_ID, DEFAULT_ENABLE_AUTO_COMMIT, DEFAULT_AUTO_COMMIT_INTERVAL_MS, diff --git a/src/main/java/org/tron/overlay/kafka/ConsumerWorker.java b/src/main/java/org/tron/overlay/kafka/ConsumerWorker.java index 345f1a59f17..ed703879898 100644 --- a/src/main/java/org/tron/overlay/kafka/ConsumerWorker.java +++ b/src/main/java/org/tron/overlay/kafka/ConsumerWorker.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.overlay.kafka; import org.apache.kafka.clients.consumer.ConsumerRecord; diff --git a/src/main/java/org/tron/overlay/kafka/Kafka.java b/src/main/java/org/tron/overlay/kafka/Kafka.java index 6978ae91efb..68bc45a24ab 100644 --- a/src/main/java/org/tron/overlay/kafka/Kafka.java +++ b/src/main/java/org/tron/overlay/kafka/Kafka.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.overlay.kafka; import org.apache.kafka.clients.consumer.ConsumerRecord; @@ -20,6 +34,10 @@ import static org.tron.core.Constant.*; public class Kafka implements Net { + public final static String KAFKA_HOST = "kafka.host"; + public final static String KAFKA_PORT = "kafka.port"; + public final static String EMPTY_STRING = ""; + private final static String EMPTY_KEY = ""; private final static int DEFAULT_WORKER_NUM = 4; diff --git a/src/main/java/org/tron/overlay/kafka/ProducerProperty.java b/src/main/java/org/tron/overlay/kafka/ProducerProperty.java index dee77fa2280..a2252de0bda 100644 --- a/src/main/java/org/tron/overlay/kafka/ProducerProperty.java +++ b/src/main/java/org/tron/overlay/kafka/ProducerProperty.java @@ -1,7 +1,27 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.overlay.kafka; +import org.tron.config.Configer; + +import static org.tron.overlay.kafka.Kafka.EMPTY_STRING; +import static org.tron.overlay.kafka.Kafka.KAFKA_HOST; +import static org.tron.overlay.kafka.Kafka.KAFKA_PORT; + public class ProducerProperty { - private final static String DEFAULT_BOOTSTRAP_SERVERS = "11.11.11.12:9092"; + private final static String DEFAULT_BOOTSTRAP_SERVERS = "127.0.0.1:9092"; private final static String DEFAULT_ACKS = "all"; private final static String DEFAULT_RETRIES = "0"; private final static String DEFAULT_BATCH_SIZE = "16384"; @@ -36,8 +56,14 @@ public ProducerProperty(String bootstrapServers, String acks, String retries, St } public static ProducerProperty getDefault() { + String bootstrapServers = Configer.getConf().getString(KAFKA_HOST) + Configer.getConf().getString(KAFKA_PORT); + + if (EMPTY_STRING.equals(bootstrapServers)) { + bootstrapServers = DEFAULT_BOOTSTRAP_SERVERS; + } + return new ProducerProperty( - DEFAULT_BOOTSTRAP_SERVERS, + bootstrapServers, DEFAULT_ACKS, DEFAULT_RETRIES, DEFAULT_BATCH_SIZE, diff --git a/src/main/java/org/tron/overlay/listener/ReceiveListener.java b/src/main/java/org/tron/overlay/listener/ReceiveListener.java index 2249475e8bd..393b10afb31 100644 --- a/src/main/java/org/tron/overlay/listener/ReceiveListener.java +++ b/src/main/java/org/tron/overlay/listener/ReceiveListener.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.overlay.listener; import org.tron.overlay.message.Message; diff --git a/src/main/java/org/tron/overlay/listener/ReceiveSource.java b/src/main/java/org/tron/overlay/listener/ReceiveSource.java index b4be871c2f3..8516d495621 100644 --- a/src/main/java/org/tron/overlay/listener/ReceiveSource.java +++ b/src/main/java/org/tron/overlay/listener/ReceiveSource.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.overlay.listener; import org.tron.overlay.message.Message; diff --git a/src/main/java/org/tron/overlay/message/Message.java b/src/main/java/org/tron/overlay/message/Message.java index 568473ad7ca..12adb523b01 100644 --- a/src/main/java/org/tron/overlay/message/Message.java +++ b/src/main/java/org/tron/overlay/message/Message.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.overlay.message; public class Message { diff --git a/src/main/java/org/tron/overlay/message/Type.java b/src/main/java/org/tron/overlay/message/Type.java index 7657b57c4b4..d0e2ce41f17 100644 --- a/src/main/java/org/tron/overlay/message/Type.java +++ b/src/main/java/org/tron/overlay/message/Type.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.overlay.message; public enum Type { diff --git a/src/main/java/org/tron/peer/Peer.java b/src/main/java/org/tron/peer/Peer.java index bd286e9d38f..404b1de030c 100644 --- a/src/main/java/org/tron/peer/Peer.java +++ b/src/main/java/org/tron/peer/Peer.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.peer; import com.google.protobuf.InvalidProtocolBufferException; @@ -12,6 +26,7 @@ import org.tron.protos.core.TronBlock; import org.tron.protos.core.TronTransaction; import org.tron.utils.ByteArray; +import org.tron.wallet.Wallet; import java.util.Arrays; diff --git a/src/main/java/org/tron/peer/PeerType.java b/src/main/java/org/tron/peer/PeerType.java index 384432f1e2a..52dcb5f226e 100644 --- a/src/main/java/org/tron/peer/PeerType.java +++ b/src/main/java/org/tron/peer/PeerType.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.peer; import com.beust.jcommander.IParameterValidator; diff --git a/src/main/java/org/tron/peer/Validation.java b/src/main/java/org/tron/peer/Validation.java index f0595e15bca..1212818ef01 100644 --- a/src/main/java/org/tron/peer/Validation.java +++ b/src/main/java/org/tron/peer/Validation.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.peer; import org.spongycastle.util.Arrays; diff --git a/src/main/java/org/tron/peer/ValidationRule.java b/src/main/java/org/tron/peer/ValidationRule.java index 33289508258..19779e8866a 100644 --- a/src/main/java/org/tron/peer/ValidationRule.java +++ b/src/main/java/org/tron/peer/ValidationRule.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.peer; import org.tron.protos.core.TronBlock.Block; diff --git a/src/main/java/org/tron/peer/ValidationRuleFactory.java b/src/main/java/org/tron/peer/ValidationRuleFactory.java index 19f144478e3..cc5f4c7c5b8 100644 --- a/src/main/java/org/tron/peer/ValidationRuleFactory.java +++ b/src/main/java/org/tron/peer/ValidationRuleFactory.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.peer; public class ValidationRuleFactory { diff --git a/src/main/java/org/tron/peer/Validator.java b/src/main/java/org/tron/peer/Validator.java index b9d5b08bd0d..a7084d3c103 100644 --- a/src/main/java/org/tron/peer/Validator.java +++ b/src/main/java/org/tron/peer/Validator.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.peer; import org.tron.protos.core.TronBlock.Block; diff --git a/src/main/java/org/tron/trie/Node.java b/src/main/java/org/tron/trie/Node.java index 1069ac356be..560220753d8 100644 --- a/src/main/java/org/tron/trie/Node.java +++ b/src/main/java/org/tron/trie/Node.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.trie; diff --git a/src/main/java/org/tron/trie/SecureTrie.java b/src/main/java/org/tron/trie/SecureTrie.java index 5948e4cd676..51e03f83c18 100644 --- a/src/main/java/org/tron/trie/SecureTrie.java +++ b/src/main/java/org/tron/trie/SecureTrie.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.trie; diff --git a/src/main/java/org/tron/trie/Trie.java b/src/main/java/org/tron/trie/Trie.java index 1a58aacac7a..55d85f93030 100644 --- a/src/main/java/org/tron/trie/Trie.java +++ b/src/main/java/org/tron/trie/Trie.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.trie; diff --git a/src/main/java/org/tron/trie/TrieImpl.java b/src/main/java/org/tron/trie/TrieImpl.java index 8421bda3bd9..32d6bd93733 100644 --- a/src/main/java/org/tron/trie/TrieImpl.java +++ b/src/main/java/org/tron/trie/TrieImpl.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.trie; import com.google.common.util.concurrent.ThreadFactoryBuilder; diff --git a/src/main/java/org/tron/trie/TrieKey.java b/src/main/java/org/tron/trie/TrieKey.java index 80b7c915542..22ca09730e1 100644 --- a/src/main/java/org/tron/trie/TrieKey.java +++ b/src/main/java/org/tron/trie/TrieKey.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.trie; diff --git a/src/main/java/org/tron/utils/ALock.java b/src/main/java/org/tron/utils/ALock.java index 9451f277292..a04761cabd2 100644 --- a/src/main/java/org/tron/utils/ALock.java +++ b/src/main/java/org/tron/utils/ALock.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.utils; diff --git a/src/main/java/org/tron/utils/BIUtil.java b/src/main/java/org/tron/utils/BIUtil.java index 051bb7114bb..da862cbd758 100644 --- a/src/main/java/org/tron/utils/BIUtil.java +++ b/src/main/java/org/tron/utils/BIUtil.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.utils; import java.math.BigInteger; diff --git a/src/main/java/org/tron/utils/ByteArray.java b/src/main/java/org/tron/utils/ByteArray.java index 02371a14236..1e25199d120 100644 --- a/src/main/java/org/tron/utils/ByteArray.java +++ b/src/main/java/org/tron/utils/ByteArray.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.utils; import org.spongycastle.util.encoders.Hex; diff --git a/src/main/java/org/tron/utils/ByteArrayMap.java b/src/main/java/org/tron/utils/ByteArrayMap.java index 2cecc0ed6a0..972d5f30bb5 100644 --- a/src/main/java/org/tron/utils/ByteArrayMap.java +++ b/src/main/java/org/tron/utils/ByteArrayMap.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.utils; diff --git a/src/main/java/org/tron/utils/ByteArraySet.java b/src/main/java/org/tron/utils/ByteArraySet.java index b669317aff1..4d39e38ab5a 100644 --- a/src/main/java/org/tron/utils/ByteArraySet.java +++ b/src/main/java/org/tron/utils/ByteArraySet.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.utils; diff --git a/src/main/java/org/tron/utils/ByteUtil.java b/src/main/java/org/tron/utils/ByteUtil.java index ef19d7f05ca..c8f94074006 100644 --- a/src/main/java/org/tron/utils/ByteUtil.java +++ b/src/main/java/org/tron/utils/ByteUtil.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.utils; import org.spongycastle.util.encoders.Hex; diff --git a/src/main/java/org/tron/utils/CompactEncoder.java b/src/main/java/org/tron/utils/CompactEncoder.java index 1ada0f259b3..b9eb1811371 100644 --- a/src/main/java/org/tron/utils/CompactEncoder.java +++ b/src/main/java/org/tron/utils/CompactEncoder.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.utils; import java.io.ByteArrayOutputStream; diff --git a/src/main/java/org/tron/utils/DecodeResult.java b/src/main/java/org/tron/utils/DecodeResult.java index 5d3ce475cd8..c2dde52eaa7 100644 --- a/src/main/java/org/tron/utils/DecodeResult.java +++ b/src/main/java/org/tron/utils/DecodeResult.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.utils; import org.spongycastle.util.encoders.Hex; diff --git a/src/main/java/org/tron/utils/ExecutorPipeline.java b/src/main/java/org/tron/utils/ExecutorPipeline.java index 3a13c07e8b1..61112d65ffe 100644 --- a/src/main/java/org/tron/utils/ExecutorPipeline.java +++ b/src/main/java/org/tron/utils/ExecutorPipeline.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.utils; diff --git a/src/main/java/org/tron/utils/FastByteComparisons.java b/src/main/java/org/tron/utils/FastByteComparisons.java index 3d8880b78e0..e0f81a142a7 100644 --- a/src/main/java/org/tron/utils/FastByteComparisons.java +++ b/src/main/java/org/tron/utils/FastByteComparisons.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.utils; import com.google.common.primitives.UnsignedBytes; diff --git a/src/main/java/org/tron/utils/FileUtil.java b/src/main/java/org/tron/utils/FileUtil.java index b54d0a6c040..5731d4ebb70 100644 --- a/src/main/java/org/tron/utils/FileUtil.java +++ b/src/main/java/org/tron/utils/FileUtil.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.utils; import java.io.File; diff --git a/src/main/java/org/tron/utils/Functional.java b/src/main/java/org/tron/utils/Functional.java index 755f68aa92a..281f9cedae8 100644 --- a/src/main/java/org/tron/utils/Functional.java +++ b/src/main/java/org/tron/utils/Functional.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.utils; diff --git a/src/main/java/org/tron/utils/SetAdapter.java b/src/main/java/org/tron/utils/SetAdapter.java index 141ed9867da..1821e88044f 100644 --- a/src/main/java/org/tron/utils/SetAdapter.java +++ b/src/main/java/org/tron/utils/SetAdapter.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.utils; import java.util.Collection; diff --git a/src/main/java/org/tron/utils/TypeConversion.java b/src/main/java/org/tron/utils/TypeConversion.java index 280ff62d9b5..88df67885e0 100644 --- a/src/main/java/org/tron/utils/TypeConversion.java +++ b/src/main/java/org/tron/utils/TypeConversion.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.utils; import java.nio.ByteBuffer; diff --git a/src/main/java/org/tron/utils/Utils.java b/src/main/java/org/tron/utils/Utils.java index 460a1dee1b8..55c63e2b12b 100644 --- a/src/main/java/org/tron/utils/Utils.java +++ b/src/main/java/org/tron/utils/Utils.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.utils; import java.security.SecureRandom; diff --git a/src/main/java/org/tron/utils/Value.java b/src/main/java/org/tron/utils/Value.java index 261a774372f..b1b145d9eb9 100644 --- a/src/main/java/org/tron/utils/Value.java +++ b/src/main/java/org/tron/utils/Value.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.utils; diff --git a/src/main/java/org/tron/core/Wallet.java b/src/main/java/org/tron/wallet/Wallet.java similarity index 52% rename from src/main/java/org/tron/core/Wallet.java rename to src/main/java/org/tron/wallet/Wallet.java index 09fa036ee39..d780d92080a 100644 --- a/src/main/java/org/tron/core/Wallet.java +++ b/src/main/java/org/tron/wallet/Wallet.java @@ -1,4 +1,18 @@ -package org.tron.core; +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.tron.wallet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -7,7 +21,7 @@ import org.tron.utils.Utils; public class Wallet { - private static final Logger logger = LoggerFactory.getLogger("wallet"); + private static final Logger LOGGER = LoggerFactory.getLogger("Wallet"); private ECKey ecKey; private byte[] address; @@ -29,7 +43,7 @@ public void init(ECKey ecKey) { this.ecKey = ecKey; address = this.ecKey.getAddress(); - logger.info("wallet address: {}", ByteArray.toHexString(address)); + LOGGER.info("wallet address: {}", ByteArray.toHexString(address)); } public ECKey getEcKey() { diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 5321f32f522..0ff7cf4fd88 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -50,19 +50,18 @@ - - - - - - - - + + + + + + - + + diff --git a/src/main/resources/tron.conf b/src/main/resources/tron.conf index 7248fcf7e54..dc02178910f 100644 --- a/src/main/resources/tron.conf +++ b/src/main/resources/tron.conf @@ -13,4 +13,10 @@ database { # database directory for test database-test { directory = "database-test" +} + +# Kafka +kafka { + host = "11.11.11.12" + port = ":9092" } \ No newline at end of file diff --git a/src/test/java/org/tron/command/CliTest.java b/src/test/java/org/tron/command/CliTest.java index f49383d0fef..43c0a9b5ca9 100644 --- a/src/test/java/org/tron/command/CliTest.java +++ b/src/test/java/org/tron/command/CliTest.java @@ -1,10 +1,24 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.command; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class CliTest { - private static final Logger logger = LoggerFactory.getLogger("test"); + private static final Logger logger = LoggerFactory.getLogger("Test"); // @Test // public void testCli() { diff --git a/src/test/java/org/tron/config/ConfigerTest.java b/src/test/java/org/tron/config/ConfigerTest.java index 15741b1ed8b..9e852f6bfe1 100644 --- a/src/test/java/org/tron/config/ConfigerTest.java +++ b/src/test/java/org/tron/config/ConfigerTest.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.config; import org.junit.Test; @@ -7,12 +21,12 @@ import org.tron.utils.ByteArray; public class ConfigerTest { - private static final Logger logger = LoggerFactory.getLogger("test"); + private static final Logger LOGGER = LoggerFactory.getLogger("Test"); @Test public void testGetECKey() { ECKey key = Configer.getMyKey(); - logger.info("address = {}", ByteArray.toHexString(key.getAddress())); + LOGGER.info("address = {}", ByteArray.toHexString(key.getAddress())); } } diff --git a/src/test/java/org/tron/core/BlockUtilsTest.java b/src/test/java/org/tron/core/BlockUtilsTest.java index a491edeb3fb..1d8ef26187c 100644 --- a/src/test/java/org/tron/core/BlockUtilsTest.java +++ b/src/test/java/org/tron/core/BlockUtilsTest.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.core; import com.google.protobuf.ByteString; @@ -8,10 +22,10 @@ import org.tron.protos.core.TronTransaction.Transaction; import org.tron.utils.ByteArray; -import static org.tron.core.Blockchain.genesisCoinbaseData; +import static org.tron.core.Blockchain.GENESIS_COINBASE_DATA; public class BlockUtilsTest { - private static final Logger logger = LoggerFactory.getLogger("test"); + private static final Logger logger = LoggerFactory.getLogger("Test"); @Test public void testNewBlock() { @@ -27,7 +41,7 @@ public void testNewBlock() { @Test public void testNewGenesisBlock() { Transaction coinbase = TransactionUtils.newCoinbaseTransaction - ("0304f784e4e7bae517bcab94c3e0c9214fb4ac7ff9d7d5a937d1f40031f87b85", genesisCoinbaseData); + ("0304f784e4e7bae517bcab94c3e0c9214fb4ac7ff9d7d5a937d1f40031f87b85", GENESIS_COINBASE_DATA); Block genesisBlock = BlockUtils.newGenesisBlock(coinbase); logger.info("test new genesis block: {}", BlockUtils.toPrintString @@ -37,7 +51,7 @@ public void testNewGenesisBlock() { @Test public void testPrepareData() { Transaction coinbase = TransactionUtils.newCoinbaseTransaction - ("0304f784e4e7bae517bcab94c3e0c9214fb4ac7ff9d7d5a937d1f40031f87b85", genesisCoinbaseData); + ("0304f784e4e7bae517bcab94c3e0c9214fb4ac7ff9d7d5a937d1f40031f87b85", GENESIS_COINBASE_DATA); logger.info("test prepare data: {}", "12580a2015f3988aa8d56eab3bfca45144bad77fc60acce50437a0a9d794a03a83c15c5e120e10ffffffffffffffffff012201001a24080a12200304f784e4e7bae517bcab94c3e0c9214fb4ac7ff9d7d5a937d1f40031f87b8532022001".equals(ByteArray.toHexString(BlockUtils.prepareData(BlockUtils.newGenesisBlock(coinbase))))); } @@ -45,7 +59,7 @@ public void testPrepareData() { @Test public void testIsValidate() { Transaction coinbase = TransactionUtils.newCoinbaseTransaction - ("0304f784e4e7bae517bcab94c3e0c9214fb4ac7ff9d7d5a937d1f40031f87b85", genesisCoinbaseData); + ("0304f784e4e7bae517bcab94c3e0c9214fb4ac7ff9d7d5a937d1f40031f87b85", GENESIS_COINBASE_DATA); Block genesisBlock = BlockUtils.newGenesisBlock(coinbase); logger.info("nonce: {}", ByteArray.toHexString(genesisBlock.getBlockHeader().getNonce ().toByteArray())); @@ -56,7 +70,7 @@ public void testIsValidate() { @Test public void testToPrintString() { Transaction coinbase = TransactionUtils.newCoinbaseTransaction - ("0304f784e4e7bae517bcab94c3e0c9214fb4ac7ff9d7d5a937d1f40031f87b85", genesisCoinbaseData); + ("0304f784e4e7bae517bcab94c3e0c9214fb4ac7ff9d7d5a937d1f40031f87b85", GENESIS_COINBASE_DATA); logger.info("test to print string: {}", BlockUtils.toPrintString (BlockUtils.newGenesisBlock(coinbase))); } @@ -64,7 +78,7 @@ public void testToPrintString() { @Test public void testGetMineValue() { Transaction coinbase = TransactionUtils.newCoinbaseTransaction - ("0304f784e4e7bae517bcab94c3e0c9214fb4ac7ff9d7d5a937d1f40031f87b85", genesisCoinbaseData); + ("0304f784e4e7bae517bcab94c3e0c9214fb4ac7ff9d7d5a937d1f40031f87b85", GENESIS_COINBASE_DATA); logger.info("test get mine value: {}", ByteArray.toHexString (BlockUtils.getMineValue(BlockUtils.newGenesisBlock(coinbase) ))); @@ -73,7 +87,7 @@ public void testGetMineValue() { @Test public void testGetPowBoundary() { Transaction coinbase = TransactionUtils.newCoinbaseTransaction - ("0304f784e4e7bae517bcab94c3e0c9214fb4ac7ff9d7d5a937d1f40031f87b85", genesisCoinbaseData); + ("0304f784e4e7bae517bcab94c3e0c9214fb4ac7ff9d7d5a937d1f40031f87b85", GENESIS_COINBASE_DATA); logger.info("test get pow boundary: {}", ByteArray.toHexString (BlockUtils.getPowBoundary(BlockUtils.newGenesisBlock (coinbase)))); diff --git a/src/test/java/org/tron/core/BlockchainTest.java b/src/test/java/org/tron/core/BlockchainTest.java index 0fd323800d6..814df686086 100644 --- a/src/test/java/org/tron/core/BlockchainTest.java +++ b/src/test/java/org/tron/core/BlockchainTest.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.core; import com.google.protobuf.ByteString; @@ -10,6 +24,7 @@ import org.tron.protos.core.TronTXOutputs; import org.tron.protos.core.TronTransaction.Transaction; import org.tron.utils.ByteArray; +import org.tron.wallet.Wallet; import java.util.ArrayList; import java.util.HashMap; @@ -20,14 +35,14 @@ public class BlockchainTest { - private static final Logger logger = LoggerFactory.getLogger("test"); + private static final Logger LOGGER = LoggerFactory.getLogger("Test"); @Test public void testBlockchain() { Blockchain blockchain = new Blockchain ("0304f784e4e7bae517bcab94c3e0c9214fb4ac7ff9d7d5a937d1f40031f87b85"); - logger.info("test blockchain: lashHash = {}, currentHash = {}", + LOGGER.info("test blockchain: lashHash = {}, currentHash = {}", ByteArray.toHexString(blockchain.getLastHash()), ByteArray .toHexString(blockchain.getCurrentHash())); } @@ -36,7 +51,7 @@ public void testBlockchain() { public void testBlockchainNew() { Blockchain blockchain = new Blockchain(); - logger.info("test blockchain new: lastHash = {}", ByteArray + LOGGER.info("test blockchain new: lastHash = {}", ByteArray .toHexString(blockchain.getLastHash())); byte[] blockBytes = blockchain.getBlockDB().get(blockchain.getLastHash()); @@ -45,7 +60,7 @@ public void testBlockchainNew() { Block block = Block.parseFrom(blockBytes); for (Transaction transaction : block.getTransactionsList()) { - logger.info("transaction id = {}", ByteArray.toHexString + LOGGER.info("transaction id = {}", ByteArray.toHexString (transaction.getId().toByteArray())); } } catch (InvalidProtocolBufferException e) { @@ -60,7 +75,7 @@ public void testIterator() { BlockchainIterator bi = new BlockchainIterator(blockchain); while (bi.hasNext()) { info = (Block) bi.next(); - logger.info("blockParentHash:{},number:{}", toHexString(info + LOGGER.info("blockParentHash:{},number:{}", toHexString(info .getBlockHeader() .getParentHash().toByteArray()), info.getBlockHeader() .getNumber()); @@ -76,12 +91,12 @@ public void testFindTransaction() { Transaction transaction = blockchain.findTransaction(ByteString .copyFrom(ByteArray.fromHexString ("15f3988aa8d56eab3bfca45144bad77fc60acce50437a0a9d794a03a83c15c5e"))); - logger.info("{}", TransactionUtils.toPrintString(transaction)); + LOGGER.info("{}", TransactionUtils.toPrintString(transaction)); } @Test public void testDBExists() { - logger.info("test db exists: {}", dbExists()); + LOGGER.info("test db exists: {}", dbExists()); } @Test diff --git a/src/test/java/org/tron/core/TXInputUtilsTest.java b/src/test/java/org/tron/core/TXInputUtilsTest.java index 7feaef6bca4..9d898bf469e 100644 --- a/src/test/java/org/tron/core/TXInputUtilsTest.java +++ b/src/test/java/org/tron/core/TXInputUtilsTest.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.core; import org.junit.Test; @@ -5,17 +19,17 @@ import org.slf4j.LoggerFactory; public class TXInputUtilsTest { - private static final Logger logger = LoggerFactory.getLogger("test"); + private static final Logger LOGGER = LoggerFactory.getLogger("Test"); @Test public void testNewTXInput() { - logger.info("test new TXInput: {}", TXInputUtils.newTXInput(new + LOGGER.info("test new TXInput: {}", TXInputUtils.newTXInput(new byte[]{}, 1, new byte[]{}, new byte[]{})); } @Test public void testToPrintString() { - logger.info("test to print string: {}", TXInputUtils.toPrintString + LOGGER.info("test to print string: {}", TXInputUtils.toPrintString (TXInputUtils.newTXInput(new byte[]{}, 1, new byte[]{}, new byte[]{}))); } diff --git a/src/test/java/org/tron/core/TXOutputUtilsTest.java b/src/test/java/org/tron/core/TXOutputUtilsTest.java index d5df8e87f25..36dbc01ddce 100644 --- a/src/test/java/org/tron/core/TXOutputUtilsTest.java +++ b/src/test/java/org/tron/core/TXOutputUtilsTest.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.core; import org.junit.Test; @@ -5,17 +19,17 @@ import org.slf4j.LoggerFactory; public class TXOutputUtilsTest { - private static final Logger logger = LoggerFactory.getLogger("test"); + private static final Logger LOGGER = LoggerFactory.getLogger("Test"); @Test public void testNewTXOutput() { - logger.info("test new TXOutput: {}", TXOutputUtils.newTXOutput(1, + LOGGER.info("test new TXOutput: {}", TXOutputUtils.newTXOutput(1, "12")); } @Test public void testToPrintString() { - logger.info("test to print string: {}", TXOutputUtils.toPrintString + LOGGER.info("test to print string: {}", TXOutputUtils.toPrintString (TXOutputUtils.newTXOutput(1, "12"))); } } diff --git a/src/test/java/org/tron/core/TransactionUtilsTest.java b/src/test/java/org/tron/core/TransactionUtilsTest.java index 11a6fb21cbd..0cffd34b04a 100644 --- a/src/test/java/org/tron/core/TransactionUtilsTest.java +++ b/src/test/java/org/tron/core/TransactionUtilsTest.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.core; import com.google.protobuf.InvalidProtocolBufferException; @@ -8,14 +22,14 @@ import org.tron.utils.ByteArray; public class TransactionUtilsTest { - private static final Logger logger = LoggerFactory.getLogger("test"); + private static final Logger LOGGER = LoggerFactory.getLogger("Test"); @Test public void testNewCoinbaseTransaction() { Transaction coinbaseTransaction = TransactionUtils .newCoinbaseTransaction("12", ""); - logger.info("test new coinbase transaction: {}", coinbaseTransaction); + LOGGER.info("test new coinbase transaction: {}", coinbaseTransaction); } @Test @@ -23,7 +37,7 @@ public void testGetHash() { Transaction coinbaseTransaction = TransactionUtils .newCoinbaseTransaction("12", ""); - logger.info("test get hash: {}", ByteArray.toHexString + LOGGER.info("test get hash: {}", ByteArray.toHexString (TransactionUtils.getHash(coinbaseTransaction))); } @@ -32,7 +46,7 @@ public void testToPrintString() { Transaction coinbaseTransaction = TransactionUtils .newCoinbaseTransaction("12", ""); - logger.info("test to print string: {}", TransactionUtils + LOGGER.info("test to print string: {}", TransactionUtils .toPrintString(coinbaseTransaction)); } @@ -41,7 +55,7 @@ public void testIsCoinbaseTransaction() { Transaction coinbaseTransaction = TransactionUtils .newCoinbaseTransaction("12", ""); - logger.info("test is coinbase transaction: {}", TransactionUtils + LOGGER.info("test is coinbase transaction: {}", TransactionUtils .isCoinbaseTransaction(coinbaseTransaction)); } diff --git a/src/test/java/org/tron/core/WalletTest.java b/src/test/java/org/tron/core/WalletTest.java index 06f7fb4b6d5..6491577f88e 100644 --- a/src/test/java/org/tron/core/WalletTest.java +++ b/src/test/java/org/tron/core/WalletTest.java @@ -1,19 +1,34 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.core; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.tron.utils.ByteArray; +import org.tron.wallet.Wallet; public class WalletTest { - private static final Logger logger = LoggerFactory.getLogger("test"); + private static final Logger LOGGER = LoggerFactory.getLogger("Test"); @Test public void testWallet() { Wallet wallet = new Wallet(); wallet.init(); - logger.info("wallet address = {}", ByteArray.toHexString(wallet + LOGGER.info("wallet address = {}", ByteArray.toHexString(wallet .getAddress())); } } diff --git a/src/test/java/org/tron/datasource/leveldb/LevelDbDataSourceTest.java b/src/test/java/org/tron/datasource/leveldb/LevelDbDataSourceTest.java index a7e096c3a4f..7e82ec00ea6 100644 --- a/src/test/java/org/tron/datasource/leveldb/LevelDbDataSourceTest.java +++ b/src/test/java/org/tron/datasource/leveldb/LevelDbDataSourceTest.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.datasource.leveldb; import org.junit.Ignore; @@ -14,7 +28,7 @@ public class LevelDbDataSourceTest { public void testGet() { LevelDbDataSource dataSource = new LevelDbDataSource("test"); dataSource.init(); - String key1="000134yyyhy"; + String key1="000134yh"; byte[] key = key1.getBytes(); byte[] value = dataSource.get(key); String s = ByteArray.toStr(value); @@ -26,7 +40,7 @@ public void testGet() { public void testPut() { LevelDbDataSource dataSource = new LevelDbDataSource("test"); dataSource.init(); - String key1="000134yyyhy"; + String key1="000134yh"; byte[] key = key1.getBytes(); String value1="50000"; diff --git a/src/test/java/org/tron/db/BlockStoresTest.java b/src/test/java/org/tron/db/BlockStoresTest.java index e6f8fd680e0..5cb1e37dfe8 100644 --- a/src/test/java/org/tron/db/BlockStoresTest.java +++ b/src/test/java/org/tron/db/BlockStoresTest.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.db; import org.junit.Test; diff --git a/src/test/java/org/tron/db/UTXOStoreTest.java b/src/test/java/org/tron/db/UTXOStoreTest.java index 4100cc4a1bc..e4ba35ad35a 100644 --- a/src/test/java/org/tron/db/UTXOStoreTest.java +++ b/src/test/java/org/tron/db/UTXOStoreTest.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.db; import org.junit.Test; @@ -5,6 +19,9 @@ public class UTXOStoreTest { + /** + * save utxo + */ @Test public void saveUTXO() { UTXOStore utxoStore = new UTXOStore(); diff --git a/src/test/java/org/tron/overlay/kafka/KafkaTest.java b/src/test/java/org/tron/overlay/kafka/KafkaTest.java index 7019b953216..6e8b1b21b94 100644 --- a/src/test/java/org/tron/overlay/kafka/KafkaTest.java +++ b/src/test/java/org/tron/overlay/kafka/KafkaTest.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.overlay.kafka; import org.junit.Test; @@ -14,7 +28,7 @@ import static org.tron.core.Constant.TOPIC_TRANSACTION; public class KafkaTest { - private static final Logger logger = LoggerFactory.getLogger("test"); + private static final Logger LOGGER = LoggerFactory.getLogger("Test"); @Test public void testKafka() { diff --git a/src/test/java/org/tron/trie/TrieTest.java b/src/test/java/org/tron/trie/TrieTest.java index f98cad20c98..591930f15ab 100644 --- a/src/test/java/org/tron/trie/TrieTest.java +++ b/src/test/java/org/tron/trie/TrieTest.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.trie; @@ -15,7 +29,7 @@ public class TrieTest { - private static final Logger logger = LoggerFactory.getLogger("test"); + private static final Logger LOGGER = LoggerFactory.getLogger("Test"); private static String LONG_STRING = "1234567890abcdefghijklmnopqrstuvwxxzABCEFGHIJKLMNOPQRSTUVWXYZ"; diff --git a/src/test/java/org/tron/utils/ByteArrayTest.java b/src/test/java/org/tron/utils/ByteArrayTest.java index fc66443248e..a9d51cc87f3 100644 --- a/src/test/java/org/tron/utils/ByteArrayTest.java +++ b/src/test/java/org/tron/utils/ByteArrayTest.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.utils; import org.junit.Test; @@ -6,41 +20,41 @@ import org.spongycastle.util.encoders.Hex; public class ByteArrayTest { - private static final Logger logger = LoggerFactory.getLogger("test"); + private static final Logger LOGGER = LoggerFactory.getLogger("Test"); @Test public void testToHexString() { - logger.info("Byte: byte 16 to hex string = {}", ByteArray.toHexString + LOGGER.info("Byte: byte 16 to hex string = {}", ByteArray.toHexString (new byte[]{16})); } @Test public void testHexStringToByte() { - logger.info("Byte: hex string 0x11 to byte = {}", ByteArray + LOGGER.info("Byte: hex string 0x11 to byte = {}", ByteArray .fromHexString("0x11")); - logger.info("Byte: hex string 10 to byte = {}", ByteArray + LOGGER.info("Byte: hex string 10 to byte = {}", ByteArray .fromHexString("10")); - logger.info("Byte: hex string 1 to byte = {}", ByteArray + LOGGER.info("Byte: hex string 1 to byte = {}", ByteArray .fromHexString("1")); } @Test public void testToLong() { - logger.info("Byte: byte 13 to long = {}", ByteArray.toLong(new + LOGGER.info("Byte: byte 13 to long = {}", ByteArray.toLong(new byte[]{13})); } @Test public void testFromLong() { - logger.info("Byte: long 127L to byte = {}", ByteArray.fromLong(127L)); + LOGGER.info("Byte: long 127L to byte = {}", ByteArray.fromLong(127L)); } @Test public void test2ToHexString() { byte[] bs = new byte[]{}; - logger.info("utils.ByteArray.toHexString: {}", ByteArray.toHexString + LOGGER.info("utils.ByteArray.toHexString: {}", ByteArray.toHexString (bs)); - logger.info("Hex.toHexString: {}", Hex.toHexString(bs)); + LOGGER.info("Hex.toHexString: {}", Hex.toHexString(bs)); } } diff --git a/src/test/java/org/tron/utils/LoggerTest.java b/src/test/java/org/tron/utils/LoggerTest.java index 745dea3ede0..6f24ada35d7 100644 --- a/src/test/java/org/tron/utils/LoggerTest.java +++ b/src/test/java/org/tron/utils/LoggerTest.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.utils; import org.junit.Test; @@ -5,13 +19,13 @@ import org.slf4j.LoggerFactory; public class LoggerTest { - private static final Logger logger = LoggerFactory.getLogger("test"); + private static final Logger LOGGER = LoggerFactory.getLogger("Test"); @Test public void testLogger() { - logger.debug("test debug: {}", "success"); - logger.info("test info: {}", "success"); - logger.warn("test warn: {}", "success"); - logger.error("test error: {}", "success"); + LOGGER.debug("test debug: {}", "success"); + LOGGER.info("test info: {}", "success"); + LOGGER.warn("test warn: {}", "success"); + LOGGER.error("test error: {}", "success"); } } diff --git a/src/test/java/org/tron/utils/TypeConversionTest.java b/src/test/java/org/tron/utils/TypeConversionTest.java index 10532ad08ad..a816d01086f 100644 --- a/src/test/java/org/tron/utils/TypeConversionTest.java +++ b/src/test/java/org/tron/utils/TypeConversionTest.java @@ -1,3 +1,17 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.tron.utils; import org.junit.Test; @@ -11,29 +25,29 @@ public class TypeConversionTest { - private static final Logger logger = LoggerFactory.getLogger("test"); + private static final Logger LOGGER = LoggerFactory.getLogger("Test"); @Test public void testLongToBytes() { byte[] result = longToBytes(123L); - logger.info("long 123 to bytes is: {}", result); + LOGGER.info("long 123 to bytes is: {}", result); } @Test public void testBytesToLong() { long result = bytesToLong(new byte[]{0, 0, 0, 0, 0, 0, 0, 124}); - logger.info("bytes 124 to long is: {}", result); + LOGGER.info("bytes 124 to long is: {}", result); } @Test public void testBytesToHexString() { String result = bytesToHexString(new byte[]{0, 0, 0, 0, 0, 0, 0, 125}); - logger.info("bytes 125 to hex string is: {}", result); + LOGGER.info("bytes 125 to hex string is: {}", result); } @Test public void testHexStringToBytes() { byte[] result = hexStringToBytes("7f"); - logger.info("hex string 7f to bytes is: {}", result); + LOGGER.info("hex string 7f to bytes is: {}", result); } } diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml index c767534f22a..12c0064ffd4 100644 --- a/src/test/resources/logback-test.xml +++ b/src/test/resources/logback-test.xml @@ -34,7 +34,6 @@ - - +