forked from tronprotocol/java-tron
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProposalStore.java
More file actions
38 lines (33 loc) · 1.09 KB
/
ProposalStore.java
File metadata and controls
38 lines (33 loc) · 1.09 KB
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 com.google.common.collect.Streams;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.tron.core.capsule.ProposalCapsule;
import org.tron.core.exception.ItemNotFoundException;
@Component
public class ProposalStore extends TronStoreWithRevoking<ProposalCapsule> {
@Autowired
public ProposalStore(@Value("proposal") String dbName) {
super(dbName);
}
@Override
public ProposalCapsule get(byte[] key) throws ItemNotFoundException {
byte[] value = revokingDB.get(key);
return new ProposalCapsule(value);
}
/**
* get all proposals.
*/
public List<ProposalCapsule> getAllProposals() {
return Streams.stream(iterator())
.map(Map.Entry::getValue)
.sorted(
(ProposalCapsule a, ProposalCapsule b) -> a.getCreateTime() <= b.getCreateTime() ? 1
: -1)
.collect(Collectors.toList());
}
}