MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / decreaseAccountToken

Method decreaseAccountToken

blockproducer/metastate.go:272–286  ·  view source on GitHub ↗
(k proto.AccountAddress, amount uint64, tokenType types.TokenType)

Source from the content-addressed store, hash-verified

270}
271
272func (s *metaState) decreaseAccountToken(k proto.AccountAddress, amount uint64, tokenType types.TokenType) error {
273 var (
274 src, dst *types.Account
275 ok bool
276 )
277 if dst, ok = s.dirty.accounts[k]; !ok {
278 if src, ok = s.readonly.accounts[k]; !ok {
279 err := errors.Wrap(ErrAccountNotFound, "decrease account balance fail")
280 return err
281 }
282 dst = deepcopy.Copy(src).(*types.Account)
283 s.dirty.accounts[k] = dst
284 }
285 return safeSub(&dst.TokenBalance[tokenType], &amount)
286}
287
288func (s *metaState) increaseAccountStableBalance(k proto.AccountAddress, amount uint64) error {
289 return s.increaseAccountToken(k, amount, types.Particle)

Calls 1

safeSubFunction · 0.85

Tested by

no test coverage detected