forked from tronprotocol/java-tron
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccountStore.java
More file actions
67 lines (57 loc) · 1.89 KB
/
AccountStore.java
File metadata and controls
67 lines (57 loc) · 1.89 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package org.tron.core.db;
import com.typesafe.config.ConfigObject;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
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.Wallet;
import org.tron.core.capsule.AccountCapsule;
import org.tron.core.db.common.iterator.AccountIterator;
@Slf4j
@Component
public class AccountStore extends TronStoreWithRevoking<AccountCapsule> {
private static Map<String, byte[]> assertsAddress = new HashMap<>(); // key = name , value = address
@Autowired
private AccountStore(@Value("account") String dbName) {
super(dbName);
}
@Override
public AccountCapsule get(byte[] key) {
byte[] value = revokingDB.getUnchecked(key);
return ArrayUtils.isEmpty(value) ? null : new AccountCapsule(value);
}
/**
* Max TRX account.
*/
public AccountCapsule getSun() {
return getUnchecked(assertsAddress.get("Sun"));
}
/**
* Min TRX account.
*/
public AccountCapsule getBlackhole() {
return getUnchecked(assertsAddress.get("Blackhole"));
}
/**
* Get foundation account info.
*/
public AccountCapsule getZion() {
return getUnchecked(assertsAddress.get("Zion"));
}
public static void setAccount(com.typesafe.config.Config config) {
List list = config.getObjectList("genesis.block.assets");
for (int i = 0; i < list.size(); i++) {
ConfigObject obj = (ConfigObject) list.get(i);
String accountName = obj.get("accountName").unwrapped().toString();
byte[] address = Wallet.decodeFromBase58Check(obj.get("address").unwrapped().toString());
assertsAddress.put(accountName, address);
}
}
}