tendermint/vm/types.go

67 lines
1.1 KiB
Go
Raw Normal View History

2015-03-17 21:46:26 -07:00
package vm
import ()
const (
defaultDataStackCapacity = 10
)
2015-03-20 05:47:52 -07:00
var (
Zero = Word{0}
One = Word{1}
)
type Word [32]byte
func (w Word) String() string { return string(w[:]) }
func (w Word) Copy() Word { return w }
func (w Word) Bytes() []byte { return w[:] } // copied.
func (w Word) Address() []byte { return w[:20] }
func (w Word) IsZero() bool {
accum := byte(0)
for _, byt := range w {
accum |= byt
}
return accum == 0
}
//-----------------------------------------------------------------------------
2015-03-17 21:46:26 -07:00
type Account struct {
2015-03-20 05:47:52 -07:00
Address Word
Balance uint64
Code []byte
Nonce uint64
StorageRoot Word
2015-03-17 21:46:26 -07:00
}
type Log struct {
Address Word
Topics []Word
Data []byte
Height uint64
}
type AppState interface {
// Accounts
2015-03-18 01:06:33 -07:00
GetAccount(addr Word) (*Account, error)
2015-03-17 21:46:26 -07:00
UpdateAccount(*Account) error
DeleteAccount(*Account) error
CreateAccount(*Account) (*Account, error)
2015-03-17 21:46:26 -07:00
// Storage
GetStorage(Word, Word) (Word, error)
2015-03-20 05:47:52 -07:00
SetStorage(Word, Word, Word) (bool, error) // Setting to Zero is deleting.
2015-03-17 21:46:26 -07:00
// Logs
AddLog(*Log)
}
2015-03-20 05:47:52 -07:00
type Params struct {
BlockHeight uint64
BlockHash Word
BlockTime int64
GasLimit uint64
}