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)
124124
125125 private boolean consumeFee (AccountCapsule accountCapsule , long fee ) {
126126 try {
127- dbManager .adjustBalance (accountCapsule .getAddress ().toByteArray (), -fee );
128127 long latestOperationTime = dbManager .getHeadBlockTimeStamp ();
129128 accountCapsule .setLatestOperationTime (latestOperationTime );
130- dbManager .getAccountStore (). put ( accountCapsule .createDbKey (), accountCapsule );
129+ dbManager .adjustBalance ( accountCapsule .createDbKey (), - fee );
131130 return true ;
132131 } catch (BalanceInsufficientException e ) {
133132 return false ;
Original file line number Diff line number Diff line change @@ -380,24 +380,31 @@ public AccountStore getAccountStore() {
380380 return this .accountStore ;
381381 }
382382
383+ public void adjustBalance (byte [] accountAddress , long amount )
384+ throws BalanceInsufficientException {
385+ AccountCapsule account = getAccountStore ().get (accountAddress );
386+ adjustBalance (account , amount );
387+ }
388+
383389 /**
384390 * judge balance.
385391 */
386- public void adjustBalance (byte [] accountAddress , long amount )
392+ public void adjustBalance (AccountCapsule account , long amount )
387393 throws BalanceInsufficientException {
388- AccountCapsule account = getAccountStore (). get ( accountAddress );
394+
389395 long balance = account .getBalance ();
390396 if (amount == 0 ) {
391397 return ;
392398 }
393399
394400 if (amount < 0 && balance < -amount ) {
395- throw new BalanceInsufficientException (accountAddress + " Insufficient" );
401+ throw new BalanceInsufficientException (account . createDbKey () + " Insufficient" );
396402 }
397403 account .setBalance (Math .addExact (balance , amount ));
398404 this .getAccountStore ().put (account .getAddress ().toByteArray (), account );
399405 }
400406
407+
401408 public void adjustAllowance (byte [] accountAddress , long amount )
402409 throws BalanceInsufficientException {
403410 AccountCapsule account = getAccountStore ().get (accountAddress );
You can’t perform that action at this time.
0 commit comments