Skip to content

Commit 95dc536

Browse files
authored
Merge pull request #915 from tronprotocol/develop
merge from develop
2 parents 0f6a77d + 0d60786 commit 95dc536

28 files changed

+1066
-844
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ public class SyncPool {
6464
private NodeManager nodeManager;
6565

6666
@Autowired
67+
private ApplicationContext ctx;
68+
6769
private ChannelManager channelManager;
6870

6971
private PeerConnectionDelegate peerDel;
@@ -86,6 +88,8 @@ public SyncPool(PeerClient peerClient) {
8688
public void init(PeerConnectionDelegate peerDel) {
8789
this.peerDel = peerDel;
8890

91+
channelManager = ctx.getBean(ChannelManager.class);
92+
8993
poolLoopExecutor.scheduleWithFixedDelay(() -> {
9094
try {
9195
fillUp();

src/main/java/org/tron/core/WalletSolidity.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,10 @@
55
import lombok.extern.slf4j.Slf4j;
66
import org.springframework.beans.factory.annotation.Autowired;
77
import org.springframework.stereotype.Component;
8-
import org.tron.api.GrpcAPI.AssetIssueList;
98
import org.tron.api.GrpcAPI.TransactionList;
10-
import org.tron.api.GrpcAPI.WitnessList;
119
import org.tron.common.utils.ByteArray;
1210
import org.tron.core.db.api.StoreAPI;
13-
import org.tron.protos.Contract.AssetIssueContract;
1411
import org.tron.protos.Protocol.Transaction;
15-
import org.tron.protos.Protocol.Witness;
1612

1713
@Slf4j
1814
@Component
@@ -21,19 +17,6 @@ public class WalletSolidity {
2117
@Autowired
2218
private StoreAPI storeAPI;
2319

24-
public WitnessList getWitnessList() {
25-
List<Witness> witnessAll = storeAPI.getWitnessAll();
26-
WitnessList witnessList = WitnessList.newBuilder().addAllWitnesses(witnessAll).build();
27-
return witnessList;
28-
}
29-
30-
public AssetIssueList getAssetIssueList() {
31-
List<AssetIssueContract> assetIssueAll = storeAPI.getAssetIssueAll();
32-
AssetIssueList assetIssueList =
33-
AssetIssueList.newBuilder().addAllAssetIssue(assetIssueAll).build();
34-
return assetIssueList;
35-
}
36-
3720
public TransactionList getTransactionsFromThis(ByteString thisAddress, long offset, long limit) {
3821
List<Transaction> transactionsFromThis = storeAPI
3922
.getTransactionsFromThis(ByteArray.toHexString(thisAddress.toByteArray()), offset, limit);

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,7 @@ public BlockId getBlockIdByNum(final long num) throws ItemNotFoundException {
905905
public BlockCapsule getBlockByNum(final long num) throws ItemNotFoundException, BadItemException {
906906
return getBlockById(getBlockIdByNum(num));
907907
}
908+
908909
/**
909910
* Generate a block.
910911
*/
@@ -922,24 +923,22 @@ public synchronized BlockCapsule generateBlock(
922923
throw new IllegalArgumentException("generate block timestamp is invalid.");
923924
}
924925

925-
long currentTrxSize = 0;
926926
long postponedTrxCount = 0;
927927

928928
final BlockCapsule blockCapsule =
929929
new BlockCapsule(number + 1, preHash, when, witnessCapsule.getAddress());
930-
currentTrxSize = blockCapsule.getInstance().getSerializedSize();
931930
dialog.reset();
932931
dialog.setValue(revokingStore.buildDialog());
933932
Iterator iterator = pendingTransactions.iterator();
934933
while (iterator.hasNext()) {
935934
TransactionCapsule trx = (TransactionCapsule) iterator.next();
936-
if (DateTime.now().getMillis() - when > ChainConstant.BLOCK_PRODUCED_INTERVAL * 0.5) {
935+
if (DateTime.now().getMillis() - when
936+
> ChainConstant.BLOCK_PRODUCED_INTERVAL * 0.5 * ChainConstant.BLOCK_PRODUCED_TIME_OUT) {
937937
logger.debug("Processing transaction time exceeds the 50% producing time。");
938938
break;
939939
}
940-
currentTrxSize += trx.getSerializedSize() + 2;
941940
// check the block size
942-
if (currentTrxSize > ChainConstant.BLOCK_SIZE) {
941+
if ((blockCapsule.getInstance().getSerializedSize() + trx.getSerializedSize() + 3) > ChainConstant.BLOCK_SIZE) {
943942
postponedTrxCount++;
944943
continue;
945944
}

src/main/java/org/tron/core/db/api/StoreAPI.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020
import org.springframework.util.StringUtils;
2121
import org.tron.core.db.api.index.Index;
2222
import org.tron.core.db.api.index.TransactionIndex;
23-
import org.tron.protos.Contract.AssetIssueContract;
2423
import org.tron.protos.Protocol.Transaction;
25-
import org.tron.protos.Protocol.Witness;
2624

2725
@Component
2826
@Slf4j
@@ -119,17 +117,17 @@ public List<Transaction> getTransactionsToThis(String address, long offset, long
119117
* witness api *
120118
*******************************************************************************
121119
*/
122-
public List<Witness> getWitnessAll() {
123-
Index.Iface<Witness> index = indexHelper.getWitnessIndex();
124-
return ImmutableList.copyOf(index);
125-
}
120+
// public List<Witness> getWitnessAll() {
121+
// Index.Iface<Witness> index = indexHelper.getWitnessIndex();
122+
// return ImmutableList.copyOf(index);
123+
// }
126124

127125
/********************************************************************************
128126
* AssetIssue api *
129127
********************************************************************************
130128
*/
131-
public List<AssetIssueContract> getAssetIssueAll() {
132-
Index.Iface<AssetIssueContract> index = indexHelper.getAssetIssueIndex();
133-
return ImmutableList.copyOf(index);
134-
}
129+
// public List<AssetIssueContract> getAssetIssueAll() {
130+
// Index.Iface<AssetIssueContract> index = indexHelper.getAssetIssueIndex();
131+
// return ImmutableList.copyOf(index);
132+
// }
135133
}

src/main/java/org/tron/core/services/RpcApiService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,14 @@ public void getAccount(Account request, StreamObserver<Account> responseObserver
214214

215215
@Override
216216
public void listWitnesses(EmptyMessage request, StreamObserver<WitnessList> responseObserver) {
217-
responseObserver.onNext(walletSolidity.getWitnessList());
217+
responseObserver.onNext(wallet.getWitnessList());
218218
responseObserver.onCompleted();
219219
}
220220

221221
@Override
222222
public void getAssetIssueList(EmptyMessage request,
223223
StreamObserver<AssetIssueList> responseObserver) {
224-
responseObserver.onNext(walletSolidity.getAssetIssueList());
224+
responseObserver.onNext(wallet.getAssetIssueList());
225225
responseObserver.onCompleted();
226226
}
227227

src/main/java/org/tron/program/FullNode.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.tron.program;
22

33
import lombok.extern.slf4j.Slf4j;
4+
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
45
import org.springframework.context.ApplicationContext;
56
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
67
import org.tron.common.application.Application;
@@ -27,7 +28,11 @@ public static void main(String[] args) throws InterruptedException {
2728
return;
2829
}
2930

30-
ApplicationContext context = new AnnotationConfigApplicationContext(DefaultConfig.class);
31+
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
32+
beanFactory.setAllowCircularReferences(false);
33+
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(beanFactory);
34+
context.register(DefaultConfig.class);
35+
context.refresh();
3136
Application appT = ApplicationFactory.create(context);
3237
shutdown(appT);
3338
//appT.init(cfgArgs);

src/main/protos/api/api.proto

Lines changed: 10 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@ service Wallet {
9393
};
9494

9595
rpc CreateWitness (WitnessCreateContract) returns (Transaction) {
96-
option (google.api.http) = {
97-
post: "/wallet/createwitness"
98-
body: "*"
99-
additional_bindings {
100-
get: "/wallet/createwitness"
101-
}
102-
};
96+
option (google.api.http) = {
97+
post: "/wallet/createwitness"
98+
body: "*"
99+
additional_bindings {
100+
get: "/wallet/createwitness"
101+
}
103102
};
103+
};
104104

105105
rpc TransferAsset (TransferAssetContract) returns (Transaction) {
106106
option (google.api.http) = {
@@ -192,14 +192,14 @@ service Wallet {
192192
};
193193
}
194194
rpc GetAccountNet (Account) returns (AccountNetMessage) {
195-
option (google.api.http) = {
195+
option (google.api.http) = {
196196
post: "/wallet/getaccountnet"
197197
body: "*"
198198
additional_bindings {
199199
get: "/wallet/getaccountnet"
200200
}
201201
};
202-
};
202+
};
203203
rpc GetAssetIssueByName (BytesMessage) returns (AssetIssueContract) {
204204
option (google.api.http) = {
205205
post: "/wallet/getassetissuebyname"
@@ -333,33 +333,6 @@ service WalletSolidity {
333333
}
334334
};
335335
}
336-
rpc GetAssetIssueListByTimestamp (NumberMessage) returns (AssetIssueList) {
337-
option (google.api.http) = {
338-
post: "/walletsolidity/getassetissuelistbytimestamp"
339-
body: "*"
340-
additional_bindings {
341-
get: "/walletsolidity/getassetissuelistbytimestamp"
342-
}
343-
};
344-
}
345-
rpc GetAssetIssueByAccount (Account) returns (AssetIssueList) {
346-
option (google.api.http) = {
347-
post: "/walletsolidity/getassetissuebyaccount"
348-
body: "*"
349-
additional_bindings {
350-
get: "/walletsolidity/getassetissuebyaccount"
351-
}
352-
};
353-
}
354-
rpc GetAssetIssueByName (BytesMessage) returns (AssetIssueContract) {
355-
option (google.api.http) = {
356-
post: "/walletsolidity/getassetissuebyname"
357-
body: "*"
358-
additional_bindings {
359-
get: "/walletsolidity/getassetissuebyname"
360-
}
361-
};
362-
}
363336
rpc GetNowBlock (EmptyMessage) returns (Block) {
364337
option (google.api.http) = {
365338
post: "/walletsolidity/getnowblock"
@@ -378,46 +351,10 @@ service WalletSolidity {
378351
}
379352
};
380353
}
381-
//get transaction
382-
rpc TotalTransaction (EmptyMessage) returns (NumberMessage) {
383-
option (google.api.http) = {
384-
post: "/walletsolidity/totaltransaction"
385-
body: "*"
386-
additional_bindings {
387-
get: "/walletsolidity/totaltransaction"
388-
}
389-
};
390-
}
391-
rpc GetTransactionById (BytesMessage) returns (Transaction) {
392-
option (google.api.http) = {
393-
post: "/walletsolidity/gettransactionbyid"
394-
body: "*"
395-
additional_bindings {
396-
get: "/walletsolidity/gettransactionbyid"
397-
}
398-
};
399-
}
400354
};
401355

402356
service WalletExtension {
403-
rpc GetTransactionsByTimestamp (TimePaginatedMessage) returns (TransactionList) {
404-
option (google.api.http) = {
405-
post: "/walletextension/gettransactionsbytimestamp"
406-
body: "*"
407-
additional_bindings {
408-
get: "/walletextension/gettransactionsbytimestamp"
409-
}
410-
};
411-
}
412-
rpc GetTransactionsByTimestampCount (TimeMessage) returns (NumberMessage) {
413-
option (google.api.http) = {
414-
post: "/walletextension/gettransactionsbytimestampcount"
415-
body: "*"
416-
additional_bindings {
417-
get: "/walletextension/gettransactionsbytimestampcount"
418-
}
419-
};
420-
}
357+
421358
rpc GetTransactionsFromThis (AccountPaginated) returns (TransactionList) {
422359
option (google.api.http) = {
423360
post: "/walletextension/gettransactionsfromthis"
@@ -436,24 +373,6 @@ service WalletExtension {
436373
}
437374
};
438375
}
439-
rpc GetTransactionsFromThisCount (Account) returns (NumberMessage) {
440-
option (google.api.http) = {
441-
post: "/walletextension/gettransactionsfromthiscount"
442-
body: "*"
443-
additional_bindings {
444-
get: "/walletextension/gettransactionsfromthiscount"
445-
}
446-
};
447-
}
448-
rpc GetTransactionsToThisCount (Account) returns (NumberMessage) {
449-
option (google.api.http) = {
450-
post: "/walletextension/gettransactionstothiscount"
451-
body: "*"
452-
additional_bindings {
453-
get: "/walletextension/gettransactionstothiscount"
454-
}
455-
};
456-
}
457376
};
458377

459378
// the api of tron's db

0 commit comments

Comments
 (0)