Skip to content

Commit 70789f6

Browse files
authored
Merge pull request #878 from iiimoon/develop
typo fixes/spelling corrections , IO handler leak fix
2 parents c0ea3c6 + 0a554e6 commit 70789f6

27 files changed

+115
-105
lines changed

src/main/java/org/tron/common/application/ApplicationImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private void closeConnection() {
117117
try {
118118
p2pNode.close();
119119
} catch (Exception e) {
120-
System.err.println("faild to close p2pNode. " + e);
120+
System.err.println("failed to close p2pNode. " + e);
121121
} finally {
122122
System.err.println("******** end to shutdown connection ********");
123123
}

src/main/java/org/tron/common/overlay/server/SyncPool.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class SyncPool {
5151
public static final Logger logger = LoggerFactory.getLogger("SyncPool");
5252

5353
private static final long WORKER_TIMEOUT = 16;
54-
private static final double fator = 0.4;
54+
private static final double factor = 0.4;
5555

5656
private final List<PeerConnection> activePeers = Collections.synchronizedList(new ArrayList<PeerConnection>());
5757
private final AtomicInteger passivePeersCount = new AtomicInteger(0);
@@ -106,7 +106,7 @@ public void init(PeerConnectionDelegate peerDel) {
106106
}
107107

108108
private void fillUp() {
109-
int lackSize = (int) (maxActiveNodes * fator) - activePeers.size();
109+
int lackSize = (int) (maxActiveNodes * factor) - activePeers.size();
110110
if(lackSize <= 0) return;
111111

112112
final Set<String> nodesInUse = channelManager.nodesInUse();

src/main/java/org/tron/core/capsule/AccountCapsule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public AccountCapsule(final AccountCreateContract contract) {
7777
}
7878

7979
/**
80-
* construct account from AccountCreateContract and creatTime.
80+
* construct account from AccountCreateContract and createTime.
8181
*/
8282
public AccountCapsule(final AccountCreateContract contract, long createTime) {
8383
this.account = Account.newBuilder()

src/main/java/org/tron/core/capsule/TransactionCapsule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ private Sha256Hash getRawHash() {
191191
}
192192

193193
/**
194-
* cheack balance of the address.
194+
* check balance of the address.
195195
*/
196196
public boolean checkBalance(byte[] address, byte[] to, long amount, long balance) {
197197
if (!Wallet.addressValid(address)) {

src/main/java/org/tron/core/config/args/Args.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,10 @@ private static void externalIp(final com.typesafe.config.Config config) {
519519
.getString("node.discovery.external.ip").trim().isEmpty()) {
520520
if (INSTANCE.nodeExternalIp == null) {
521521
logger.info("External IP wasn't set, using checkip.amazonaws.com to identify it...");
522-
try (BufferedReader in = new BufferedReader(new InputStreamReader(
523-
new URL("http://checkip.amazonaws.com").openStream()))) {
522+
BufferedReader in = null;
523+
try {
524+
in = new BufferedReader(new InputStreamReader(
525+
new URL("http://checkip.amazonaws.com").openStream()));
524526
INSTANCE.nodeExternalIp = in.readLine();
525527
if (INSTANCE.nodeExternalIp == null || INSTANCE.nodeExternalIp.trim().isEmpty()) {
526528
throw new IOException("Invalid address: '" + INSTANCE.nodeExternalIp + "'");
@@ -536,6 +538,15 @@ private static void externalIp(final com.typesafe.config.Config config) {
536538
logger.warn(
537539
"Can't get external IP. Fall back to peer.bind.ip: " + INSTANCE.nodeExternalIp + " :"
538540
+ e);
541+
}finally{
542+
if (in != null){
543+
try {
544+
in.close();
545+
} catch (IOException e) {
546+
//ignore
547+
}
548+
}
549+
539550
}
540551
}
541552
} else {

src/main/java/org/tron/core/db/AbstractRevokingStore.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public synchronized void onCreate(RevokingTuple tuple, byte[] value) {
6262
return;
6363
}
6464

65-
addIfEmtpy();
65+
addIfEmpty();
6666
RevokingState state = stack.peekLast();
6767
state.newIds.add(tuple);
6868
}
@@ -73,7 +73,7 @@ public synchronized void onModify(RevokingTuple tuple, byte[] value) {
7373
return;
7474
}
7575

76-
addIfEmtpy();
76+
addIfEmpty();
7777
RevokingState state = stack.peekLast();
7878
if (state.newIds.contains(tuple) || state.oldValues.containsKey(tuple)) {
7979
return;
@@ -88,7 +88,7 @@ public synchronized void onRemove(RevokingTuple tuple, byte[] value) {
8888
return;
8989
}
9090

91-
addIfEmtpy();
91+
addIfEmpty();
9292
RevokingState state = stack.peekLast();
9393
if (state.newIds.contains(tuple)) {
9494
state.newIds.remove(tuple);
@@ -239,7 +239,7 @@ public synchronized void disable() {
239239
disabled = true;
240240
}
241241

242-
private void addIfEmtpy() {
242+
private void addIfEmpty() {
243243
if (stack.isEmpty()) {
244244
stack.add(new RevokingState());
245245
}
@@ -280,7 +280,7 @@ public synchronized void shutdown() {
280280
}
281281
}
282282
} catch (Exception e) {
283-
System.err.println("******** faild to pop revokingStore. " + e);
283+
System.err.println("******** failed to pop revokingStore. " + e);
284284
} finally {
285285
System.err.println("******** after revokingStore size:" + stack.size());
286286
System.err.println("******** after revokingStore contains:" + stack);
@@ -306,9 +306,9 @@ public Dialog(RevokingDatabase revokingDatabase) {
306306
this(revokingDatabase, false);
307307
}
308308

309-
public Dialog(RevokingDatabase revokingDatabase, boolean disbaleOnExit) {
309+
public Dialog(RevokingDatabase revokingDatabase, boolean disableOnExit) {
310310
this.revokingDatabase = revokingDatabase;
311-
this.disableOnExit = disbaleOnExit;
311+
this.disableOnExit = disableOnExit;
312312
}
313313

314314
void commit() throws RevokingStoreIllegalStateException {

src/main/java/org/tron/core/db/ByteArrayWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class ByteArrayWrapper implements Comparable<ByteArrayWrapper>, Serializa
3030
private int hashCode = 0;
3131

3232
/**
33-
* construcor.
33+
* constructor.
3434
*/
3535
public ByteArrayWrapper(byte[] data) {
3636
if (data == null) {

src/main/java/org/tron/core/db/Manager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ public synchronized void pushBlock(final BlockCapsule block)
633633

634634
if (!block.generatedByMyself) {
635635
if (!block.validateSignature()) {
636-
logger.info("The siganature is not validated.");
636+
logger.info("The signature is not validated.");
637637
// TODO: throw exception here.
638638
return;
639639
}
@@ -1234,7 +1234,7 @@ private void closeOneStore(TronDatabase database) {
12341234
try {
12351235
database.close();
12361236
} catch (Exception e) {
1237-
System.err.println("faild to close " + database.getName() + ". " + e);
1237+
System.err.println("failed to close " + database.getName() + ". " + e);
12381238
} finally {
12391239
System.err.println("******** end to close " + database.getName() + " ********");
12401240
}

src/main/java/org/tron/core/db/TransactionStore.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public long getTotalTransactions() {
5050
return dbSource.getTotal();
5151
}
5252

53-
5453
@Override
5554
public Iterator<Entry<byte[], TransactionCapsule>> iterator() {
5655
return new TransactionIterator(dbSource.iterator());

src/main/java/org/tron/core/net/node/NodeDelegateImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public synchronized LinkedList<Sha256Hash> handleBlock(BlockCapsule block, boole
5757
throw new BadBlockException("block size over limit");
5858
}
5959

60-
// TODO timestamp shouble be consistent.
60+
// TODO timestamp should be consistent.
6161
long gap = block.getTimeStamp() - System.currentTimeMillis();
6262
if (gap >= BLOCK_PRODUCED_INTERVAL) {
6363
throw new BadBlockException("block time error");
@@ -84,11 +84,11 @@ public synchronized LinkedList<Sha256Hash> handleBlock(BlockCapsule block, boole
8484
} catch (ContractValidateException e) {
8585
throw new BadBlockException("ContractValidate exception," + e.getMessage());
8686
} catch (ContractExeException e) {
87-
throw new BadBlockException("Contract Exectute exception," + e.getMessage());
87+
throw new BadBlockException("Contract Execute exception," + e.getMessage());
8888
} catch (TaposException e) {
8989
throw new BadBlockException("tapos exception," + e.getMessage());
9090
} catch (DupTransactionException e) {
91-
throw new BadBlockException("DupTransation exception," + e.getMessage());
91+
throw new BadBlockException("DupTransaction exception," + e.getMessage());
9292
} catch (TooBigTransactionException e) {
9393
throw new BadBlockException("TooBigTransaction exception," + e.getMessage());
9494
} catch (TransactionExpirationException e) {

0 commit comments

Comments
 (0)