Skip to content

Commit c516bdb

Browse files
committed
Merge branch 'feature/update_token_v1' of https://github.com/tronprotocol/java-tron into feature/update_token_v1
2 parents 24da6d2 + 8945fc6 commit c516bdb

3 files changed

Lines changed: 25 additions & 2 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,12 @@ public void addVotes(ByteString voteAddress, long voteAdd) {
285285
.build();
286286
}
287287

288+
public void clearAssetV2() {
289+
this.account = this.account.toBuilder()
290+
.clearAssetV2()
291+
.build();
292+
}
293+
288294
public void clearVotes() {
289295
this.account = this.account.toBuilder()
290296
.clearVotes()

‎src/main/java/org/tron/core/db/api/AssetUpdateHelper.java‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
import java.util.Iterator;
55
import java.util.Map;
66
import java.util.Map.Entry;
7+
import lombok.extern.slf4j.Slf4j;
78
import org.tron.core.capsule.AccountCapsule;
89
import org.tron.core.capsule.AssetIssueCapsule;
910
import org.tron.core.capsule.ExchangeCapsule;
1011
import org.tron.core.db.Manager;
1112

12-
13+
@Slf4j
1314
public class AssetUpdateHelper {
1415

1516
private Manager dbManager;
@@ -21,11 +22,13 @@ public AssetUpdateHelper(Manager dbManager) {
2122
}
2223

2324
public void doWork() {
25+
logger.info("Start to update the asset");
2426
init();
2527
updateAsset();
2628
updateExchange();
2729
updateAccount();
2830
finish();
31+
logger.info("Complete the asset update");
2932
}
3033

3134
public void init() {
@@ -47,6 +50,8 @@ public void updateAsset() {
4750
tokenIdNum++;
4851
}
4952

53+
logger.info("Complete the asset store update");
54+
5055
}
5156

5257
public void updateExchange() {
@@ -59,10 +64,14 @@ public void updateExchange() {
5964
dbManager.getExchangeV2Store().put(exchangeCapsule.createDbKey(), exchangeCapsule);
6065
}
6166

67+
logger.info("Complete the exchange store update");
68+
6269
}
6370

6471
public void updateAccount() {
6572

73+
long count = 0;
74+
6675
Iterator<Entry<byte[], AccountCapsule>> iterator = dbManager.getAccountStore().iterator();
6776
while (iterator.hasNext()) {
6877
AccountCapsule accountCapsule = iterator.next().getValue();
@@ -71,15 +80,23 @@ public void updateAccount() {
7180
assetV2Map.put(new String(assetNameToIdMap.get(entry.getKey())), entry.getValue());
7281
}
7382

83+
accountCapsule.clearAssetV2();
7484
accountCapsule.addAssetV2Map(assetV2Map);
7585
dbManager.getAccountStore().put(accountCapsule.createDbKey(), accountCapsule);
7686

87+
if (count % 50000 == 0) {
88+
logger.info("The number of accounts that have completed the update :{}", count);
89+
}
90+
count++;
7791
}
7892

93+
logger.info("Complete the account store update");
94+
7995
}
8096

8197
public void finish() {
8298
dbManager.getDynamicPropertiesStore().saveTokenUpdateDone(1);
99+
assetNameToIdMap.clear();
83100
}
84101

85102

‎src/main/resources/config.conf‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ storage {
4747
]
4848

4949

50-
needToUpdateAsset = false
50+
needToUpdateAsset = true
5151

5252
}
5353

0 commit comments

Comments
 (0)