Skip to content

Commit c964a11

Browse files
Merge pull request #737 from tronprotocol/fix_fill_on_fullnode_for_master
fix fill on fullnode for master
2 parents f29b586 + a537d71 commit c964a11

File tree

8 files changed

+14
-7
lines changed

8 files changed

+14
-7
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.tron.core.db.api;
22

3+
import javax.annotation.PostConstruct;
34
import javax.annotation.Resource;
45
import lombok.Getter;
56
import lombok.extern.slf4j.Slf4j;
@@ -34,6 +35,14 @@ public class IndexHelper {
3435
@Resource
3536
private Index.Iface<AssetIssueContract> assetIssueIndex;
3637

38+
@PostConstruct
39+
public void init() {
40+
transactionIndex.fill();
41+
blockIndex.fill();
42+
witnessIndex.fill();
43+
accountIndex.fill();
44+
assetIssueIndex.fill();
45+
}
3746
private <T> void add(Index.Iface<T> index, byte[] bytes) {
3847
index.add(bytes);
3948
}

src/main/java/org/tron/core/db/api/index/AbstractIndex.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ protected T getObject(final WrappedByteArray byteArray) {
5656
return getObject(byteArray.getBytes());
5757
}
5858

59-
protected void fill() {
59+
@Override
60+
public void fill() {
6061
int size = Iterables.size(database);
61-
if (size != 0 && (!indexPath.exists() || index.size() < size)) {
62+
if (size != 0 && !indexPath.exists()) {
6263
database.forEach(e -> add(e.getKey()));
6364
}
6465
}

src/main/java/org/tron/core/db/api/index/AccountIndex.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public AccountIndex(@Qualifier("accountStore") final TronDatabase<AccountCapsule
4040
public void init() {
4141
initIndex(DiskPersistence.onPrimaryKeyInFile(Account_ADDRESS, indexPath));
4242
// index.addIndex(DiskIndex.onAttribute(Account_ADDRESS));
43-
fill();
4443
}
4544

4645
@Override

src/main/java/org/tron/core/db/api/index/AssetIssueIndex.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public void init() {
3939
// index.addIndex(DiskIndex.onAttribute(AssetIssue_NAME));
4040
index.addIndex(DiskIndex.onAttribute(AssetIssue_START));
4141
index.addIndex(DiskIndex.onAttribute(AssetIssue_END));
42-
fill();
4342
}
4443

4544
@Override

src/main/java/org/tron/core/db/api/index/BlockIndex.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public void init() {
5656
index.addIndex(DiskIndex.onAttribute(WITNESS_ADDRESS));
5757
index.addIndex(DiskIndex.onAttribute(OWNERS));
5858
index.addIndex(DiskIndex.onAttribute(TOS));
59-
fill();
6059
}
6160

6261
@Override

src/main/java/org/tron/core/db/api/index/Index.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,7 @@ public interface Iface<T> extends Iterable<T> {
2727
long size();
2828

2929
String getName();
30+
31+
void fill();
3032
}
3133
}

src/main/java/org/tron/core/db/api/index/TransactionIndex.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public void init() {
4949
index.addIndex(DiskIndex.onAttribute(OWNERS));
5050
index.addIndex(DiskIndex.onAttribute(TOS));
5151
index.addIndex(DiskIndex.onAttribute(TIMESTAMP));
52-
fill();
5352
}
5453

5554
@Override

src/main/java/org/tron/core/db/api/index/WitnessIndex.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public void init() {
4343
// index.addIndex(DiskIndex.onAttribute(Witness_ADDRESS));
4444
index.addIndex(DiskIndex.onAttribute(PUBLIC_KEY));
4545
index.addIndex(DiskIndex.onAttribute(Witness_URL));
46-
fill();
4746
}
4847

4948
@Override

0 commit comments

Comments
 (0)