Skip to content

Commit f2f41dd

Browse files
committed
implement fuction getTotal in interface
1 parent 4e17c1c commit f2f41dd

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

‎src/main/java/org/tron/common/storage/leveldb/RocksDbDataSourceImpl.java‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,19 @@ public Set<byte[]> allValues() throws RuntimeException {
116116

117117
@Override
118118
public long getTotal() throws RuntimeException {
119-
return 0;
119+
if (quitIfNotAlive()) {
120+
return 0;
121+
}
122+
resetDbLock.readLock().lock();
123+
try (RocksIterator iterator = database.newIterator()) {
124+
long total = 0;
125+
for (iterator.seekToFirst(); iterator.isValid(); iterator.next()) {
126+
total++;
127+
}
128+
return total;
129+
} finally {
130+
resetDbLock.readLock().unlock();
131+
}
120132
}
121133

122134
@Override

0 commit comments

Comments
 (0)