2015-03-17 21:46:26 -07:00
|
|
|
package vm
|
|
|
|
|
2015-03-28 23:44:07 -07:00
|
|
|
import (
|
2015-04-01 17:30:16 -07:00
|
|
|
. "github.com/tendermint/tendermint/common"
|
2015-05-16 00:48:04 -04:00
|
|
|
ptypes "github.com/tendermint/tendermint/permission/types"
|
2015-08-10 20:38:45 -07:00
|
|
|
"github.com/tendermint/tendermint/types"
|
2015-03-28 23:44:07 -07:00
|
|
|
)
|
2015-03-17 21:46:26 -07:00
|
|
|
|
|
|
|
const (
|
|
|
|
defaultDataStackCapacity = 10
|
|
|
|
)
|
|
|
|
|
|
|
|
type Account struct {
|
2015-07-28 12:39:10 -07:00
|
|
|
Address Word256
|
|
|
|
Balance int64
|
|
|
|
Code []byte
|
|
|
|
Nonce int64
|
|
|
|
Other interface{} // For holding all other data.
|
2015-05-16 00:48:04 -04:00
|
|
|
|
2015-07-07 14:26:05 -07:00
|
|
|
Permissions ptypes.AccountPermissions
|
2015-03-17 21:46:26 -07:00
|
|
|
}
|
|
|
|
|
2015-05-01 17:26:49 -07:00
|
|
|
func (acc *Account) String() string {
|
2015-07-24 12:32:22 -07:00
|
|
|
if acc == nil {
|
|
|
|
return "nil-VMAccount"
|
|
|
|
}
|
2015-07-28 12:39:10 -07:00
|
|
|
return Fmt("VMAccount{%X B:%v C:%X N:%v}",
|
|
|
|
acc.Address, acc.Balance, acc.Code, acc.Nonce)
|
2015-05-01 17:26:49 -07:00
|
|
|
}
|
|
|
|
|
2015-03-17 21:46:26 -07:00
|
|
|
type AppState interface {
|
|
|
|
|
|
|
|
// Accounts
|
2015-03-28 23:44:07 -07:00
|
|
|
GetAccount(addr Word256) *Account
|
|
|
|
UpdateAccount(*Account)
|
|
|
|
RemoveAccount(*Account)
|
|
|
|
CreateAccount(*Account) *Account
|
2015-03-17 21:46:26 -07:00
|
|
|
|
|
|
|
// Storage
|
2015-03-28 23:44:07 -07:00
|
|
|
GetStorage(Word256, Word256) Word256
|
|
|
|
SetStorage(Word256, Word256, Word256) // Setting to Zero is deleting.
|
2015-03-17 21:46:26 -07:00
|
|
|
|
|
|
|
// Logs
|
2015-08-10 20:38:45 -07:00
|
|
|
AddLog(types.EventDataLog)
|
2015-03-17 21:46:26 -07:00
|
|
|
}
|
2015-03-20 05:47:52 -07:00
|
|
|
|
|
|
|
type Params struct {
|
2015-06-25 20:28:34 -07:00
|
|
|
BlockHeight int64
|
2015-03-28 23:44:07 -07:00
|
|
|
BlockHash Word256
|
2015-03-20 05:47:52 -07:00
|
|
|
BlockTime int64
|
2015-06-25 20:28:34 -07:00
|
|
|
GasLimit int64
|
2015-03-20 05:47:52 -07:00
|
|
|
}
|