forked from tronprotocol/java-tron
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWitnessStore.java
More file actions
38 lines (32 loc) · 1022 Bytes
/
WitnessStore.java
File metadata and controls
38 lines (32 loc) · 1022 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package org.tron.core.db;
import java.util.List;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import com.google.common.collect.Streams;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.tron.core.capsule.WitnessCapsule;
@Slf4j
@Component
public class WitnessStore extends TronStoreWithRevoking<WitnessCapsule> {
@Autowired
protected WitnessStore(@Value("witness") String dbName) {
super(dbName);
}
/**
* get all witnesses.
*/
public List<WitnessCapsule> getAllWitnesses() {
return Streams.stream(iterator())
.map(Entry::getValue)
.collect(Collectors.toList());
}
@Override
public WitnessCapsule get(byte[] key) {
byte[] value = revokingDB.getUnchecked(key);
return ArrayUtils.isEmpty(value) ? null : new WitnessCapsule(value);
}
}