Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing account-related errors for rhp4 #121

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions rhp/v4/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ const (
memoryPer100TiB = sectorsPer100TiB * 32
)

var (
// ErrBalanceInsufficient is returned by RPCs when the account balance isn't
// enough to pay for the corresponding RPC.
ErrBalanceInsufficient = errors.New("ephemeral account balance was insufficient")

// ErrMaxBalanceExceeded is returned when funding an account results in the
// maximum allowed balance being exceeded.
ErrMaxBalanceExceeded = errors.New("ephemeral account maximum balance exceeded")
)

var protocolVersion = [3]byte{4, 0, 0}

type (
Expand Down Expand Up @@ -119,11 +129,16 @@ type (
// contract ID.
V2FileContractElement(types.FileContractID) (types.ChainIndex, types.V2FileContractElement, error)

// AccountBalance returns the balance of an account.
// AccountBalance returns the balance of an account. Returns 0 if the
// account doesn't exist.
AccountBalance(rhp4.Account) (types.Currency, error)
// CreditAccountsWithContract atomically revises a contract and credits the account.
// CreditAccountsWithContract atomically revises a contract and credits
// the account. If the account doesn't exist yet, it should be created.
// If the account's balance would exceed the maximum allowed balance
// after funding, ErrMaxBalanceExceeded should be returned.
CreditAccountsWithContract([]rhp4.AccountDeposit, types.FileContractID, types.V2FileContract, rhp4.Usage) ([]types.Currency, error)
// DebitAccount debits an account.
// DebitAccount debits an account. Fails with ErrBalanceInsufficient if
// the account doesn't have enough funds.
DebitAccount(rhp4.Account, rhp4.Usage) error
}

Expand Down
Loading