1010import org .tron .core .capsule .AccountCapsule ;
1111import org .tron .core .capsule .BytesCapsule ;
1212import org .tron .core .db .TronStoreWithRevoking ;
13- import java .util .Arrays ;
1413
1514@ Slf4j
1615@ Component
@@ -31,7 +30,7 @@ public BytesCapsule get(byte[] key) {
3130 }
3231
3332 public void addBlockReward (long cycle , byte [] address , long value ) {
34- byte [] key = buildRewarkBlockKey (cycle , address );
33+ byte [] key = buildRewardBlockKey (cycle , address );
3534 BytesCapsule bytesCapsule = get (key );
3635
3736 if (bytesCapsule == null ) {
@@ -43,7 +42,28 @@ public void addBlockReward(long cycle, byte[] address, long value) {
4342 }
4443
4544 public long getBlockReward (long cycle , byte [] address ) {
46- BytesCapsule bytesCapsule = get (buildRewarkBlockKey (cycle , address ));
45+ BytesCapsule bytesCapsule = get (buildRewardBlockKey (cycle , address ));
46+ if (bytesCapsule == null ) {
47+ return 0L ;
48+ } else {
49+ return ByteArray .toLong (bytesCapsule .getData ());
50+ }
51+ }
52+
53+ public void addVodeReward (long cycle , byte [] address , long value ) {
54+ byte [] key = buildRewardVoteKey (cycle , address );
55+ BytesCapsule bytesCapsule = get (key );
56+
57+ if (bytesCapsule == null ) {
58+ put (key , new BytesCapsule (ByteArray .fromLong (value )));
59+ } else {
60+ put (key , new BytesCapsule (ByteArray
61+ .fromLong (ByteArray .toLong (bytesCapsule .getData ()) + value )));
62+ }
63+ }
64+
65+ public long getVoteReward (long cycle , byte [] address ) {
66+ BytesCapsule bytesCapsule = get (buildRewardVoteKey (cycle , address ));
4767 if (bytesCapsule == null ) {
4868 return 0L ;
4969 } else {
@@ -161,10 +181,14 @@ private byte[] buildRewardKey(long cycle, byte[] address) {
161181 return (cycle + "-" + Hex .toHexString (address ) + "-reward" ).getBytes ();
162182 }
163183
164- private byte [] buildRewarkBlockKey (long cycle , byte [] address ) {
184+ private byte [] buildRewardBlockKey (long cycle , byte [] address ) {
165185 return (cycle + "-" + Hex .toHexString (address ) + "-block" ).getBytes ();
166186 }
167187
188+ private byte [] buildRewardVoteKey (long cycle , byte [] address ) {
189+ return (cycle + "-" + Hex .toHexString (address ) + "-reward-vote" ).getBytes ();
190+ }
191+
168192 private byte [] buildRemarkKey (long cycle , byte [] address ) {
169193 return (cycle + "-" + Hex .toHexString (address ) + "-remark" ).getBytes ();
170194 }
0 commit comments