state

package
v0.8.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2017 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OperationPlus is plus operation in state
	OperationPlus uint32 = iota
	// OperationSub is sub operation in state
	OperationSub
)

Variables

View Source
var (
	//ErrNegativeBalance negative balance when execute transaction
	ErrNegativeBalance = errors.New("balance is Negative")
)

Functions

This section is empty.

Types

type Balance

type Balance struct {
	Amount *big.Int
	Nonce  uint32
}

Balance contain amount nonce

func NewBalance

func NewBalance(amount *big.Int, nonce uint32) *Balance

NewBalance initialization

type State

type State struct {
	// contains filtered or unexported fields
}

State represents the account state

func NewState

func NewState(db *db.BlockchainDB) *State

NewState returns a new State

func (*State) AtomicWrite

func (state *State) AtomicWrite(writeBatchs []*db.WriteBatch) error

AtomicWrite atomic writeBatchs

func (*State) GetBalance

func (state *State) GetBalance(a accounts.Address) (*big.Int, uint32, error)

GetBalance returns balance by account

func (*State) GetTmpBalance

func (state *State) GetTmpBalance(addr accounts.Address) (*Balance, error)

GetTmpBalance get tmpBalance When the block is not packaged

func (*State) Init

func (state *State) Init(a accounts.Address) error

Init initializes a account

func (*State) Transfer

func (state *State) Transfer(sender, recipient accounts.Address, fee *big.Int, balance *Balance, txType uint32) ([]*db.WriteBatch, error)

Transfer updates the sender->recipient account balance

func (*State) UpdateBalance

func (state *State) UpdateBalance(a accounts.Address, balance *Balance, fee *big.Int, operation uint32) ([]*db.WriteBatch, error)

UpdateBalance updates the account balance

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL