Skip to content

Commit

Permalink
even better pseudocode
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaSripal committed Aug 6, 2018
1 parent d56e3a7 commit 2ac55eb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions docs/spec/auth/vesting.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,20 @@ handled at the `bank.Keeper` level. Specifically in methods that are explicitly
`sendCoins` and `inputOutputCoins`. These methods must check that an account is a vesting account using the check described above.

```go
if Now < vacc.EndTime:
if Now < vestingAccount.EndTime:
// NOTE: SendableCoins may be greater than total coins in account
// because coins can be subtracted by staking module
// SendableCoins denotes maximum coins allowed to be spent.
SendableCoins := ReceivedCoins + OriginalCoins * (Now - StartTime) / (EndTime - StartTime)
if msg.Amount > SendableCoins then fail

// Account fully vested, convert to BaseAccount
else: account = ConvertAccount(account)
else:
account = ConvertAccount(account)

// Must still check if account has enough coins,
// since SendableCoins does not check this.
if msg.Amount > account.GetCoins() then fail
if msg.Amount > account.GetCoins() then fail

// All checks passed, send the coins
SendCoins(inputs, outputs)
Expand Down

0 comments on commit 2ac55eb

Please sign in to comment.