File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
src/main/java/org/tron/core/db Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -124,10 +124,9 @@ public void consumeBandwidth(TransactionCapsule trx)
124
124
125
125
private boolean consumeFee (AccountCapsule accountCapsule , long fee ) {
126
126
try {
127
- dbManager .adjustBalance (accountCapsule .getAddress ().toByteArray (), -fee );
128
127
long latestOperationTime = dbManager .getHeadBlockTimeStamp ();
129
128
accountCapsule .setLatestOperationTime (latestOperationTime );
130
- dbManager .getAccountStore (). put ( accountCapsule .createDbKey (), accountCapsule );
129
+ dbManager .adjustBalance ( accountCapsule .createDbKey (), - fee );
131
130
return true ;
132
131
} catch (BalanceInsufficientException e ) {
133
132
return false ;
Original file line number Diff line number Diff line change @@ -380,24 +380,31 @@ public AccountStore getAccountStore() {
380
380
return this .accountStore ;
381
381
}
382
382
383
+ public void adjustBalance (byte [] accountAddress , long amount )
384
+ throws BalanceInsufficientException {
385
+ AccountCapsule account = getAccountStore ().get (accountAddress );
386
+ adjustBalance (account , amount );
387
+ }
388
+
383
389
/**
384
390
* judge balance.
385
391
*/
386
- public void adjustBalance (byte [] accountAddress , long amount )
392
+ public void adjustBalance (AccountCapsule account , long amount )
387
393
throws BalanceInsufficientException {
388
- AccountCapsule account = getAccountStore (). get ( accountAddress );
394
+
389
395
long balance = account .getBalance ();
390
396
if (amount == 0 ) {
391
397
return ;
392
398
}
393
399
394
400
if (amount < 0 && balance < -amount ) {
395
- throw new BalanceInsufficientException (accountAddress + " Insufficient" );
401
+ throw new BalanceInsufficientException (account . createDbKey () + " Insufficient" );
396
402
}
397
403
account .setBalance (Math .addExact (balance , amount ));
398
404
this .getAccountStore ().put (account .getAddress ().toByteArray (), account );
399
405
}
400
406
407
+
401
408
public void adjustAllowance (byte [] accountAddress , long amount )
402
409
throws BalanceInsufficientException {
403
410
AccountCapsule account = getAccountStore ().get (accountAddress );
You can’t perform that action at this time.
0 commit comments