Documentation
¶
Index ¶
- Constants
- Variables
- func EncodeBlock(w utils.Writer, b *Block) error
- func EncodeBlockHeader(w utils.Writer, bh BlockHeader) error
- func EncodeBlockSelf(w utils.Writer, b *Block) error
- func EncodeTx(w utils.Writer, tx *Transaction) error
- func ExecVmTxRawCode(origin AddressType, gasLimit uint64, data []byte, s *storage.Slice, ...) (uint64, error)
- func ExecVmViewRawCode(origin AddressType, gasLimit uint64, data []byte, s *storage.Slice, ...) ([]byte, error)
- func ExecuteBlock(b *Block, reward uint64, s *storage.Slice, ctx *ExecutionContext) error
- func ExecuteTx(tx *Transaction, s *storage.Slice, ctx *ExecutionContext) error
- func GenKeyPair(r io.Reader) (a PubkeyType, b PrivkeyType)
- func LoadContractCode(s *storage.Slice, addr AddressType) ([]byte, error)
- func SetAccountInfo(s *storage.Slice, address AddressType, info AccountInfo)
- type AccountInfo
- type AddressType
- type Block
- type BlockHeader
- type ExecutionCallback
- type ExecutionContext
- type HashType
- type PrivkeyType
- type PubkeyType
- type SigType
- type Transaction
Constants ¶
View Source
const AddressLen = sha256.Size
View Source
const CREATE_INIT = 2
View Source
const CREATE_TRIMELF = 1
View Source
const CREATE_USENONCE = 4
View Source
const CallExternal = 1
View Source
const CallInit = 4
View Source
const CallRegular = 3
View Source
const CallStart = 2
View Source
const CallView = 5
View Source
const DefaultSp = 0x30000000 + vm.PageSize*vm.MaxPagesPerBlock - 16
View Source
const GasCall = 2800
View Source
const GasLoadContractCode = 20000
View Source
const GasLoadContractCodeCached = 400
View Source
const GasLoadContractCodePerBlock = 2000
View Source
const GasSyscallCreatePerByte = 1
View Source
const GasSyscallCreateStorePerBlock = 10000
View Source
const GasSyscallEd25519PerBlock = 100
View Source
const GasSyscallRevertPerByte = 1
View Source
const GasSyscallSha256PerBlock = 60
View Source
const GasSyscallTransferMessagePerByte = 1
View Source
const GasVmTxRawCode = 5000
View Source
const HashLen = sha256.Size
View Source
const MaxByteArrayLen = 1 << 20
View Source
const MaxRevertMsgLen = 1024
View Source
const PrivkeyLen = ed25519.PrivateKeySize
View Source
const PubkeyLen = ed25519.PublicKeySize
View Source
const SYSCALL_BALANCE = 8
View Source
const SYSCALL_BLOCK_NUMBER = 14
View Source
const SYSCALL_CALLER = 3
View Source
const SYSCALL_CALLVALUE = 4
View Source
const SYSCALL_CHAINID = 16
View Source
const SYSCALL_CREATE = 20
View Source
const SYSCALL_DIFFICULTY = 15
View Source
const SYSCALL_ED25519_VERIFY = 21
View Source
const SYSCALL_GAS = 17
View Source
const SYSCALL_JUMPDEST = 18
View Source
const SYSCALL_LOAD_CONTRACT = 9
View Source
const SYSCALL_LOAD_ELF = 22
View Source
const SYSCALL_MINER = 13
View Source
const SYSCALL_ORIGIN = 2
View Source
const SYSCALL_PROTECTED_CALL = 10
View Source
const SYSCALL_REVERT = 11
View Source
const SYSCALL_SELF = 1
View Source
const SYSCALL_SHA256 = 7
View Source
const SYSCALL_STORAGE_LOAD = 6
View Source
const SYSCALL_STORAGE_STORE = 5
View Source
const SYSCALL_TIME = 12
View Source
const SYSCALL_TRANSFER = 19
View Source
const SigLen = ed25519.SignatureSize
View Source
const SyscallProg = 0x7fffffff
Variables ¶
View Source
var ErrContractExists = errors.New("contract exists")
View Source
var ErrContractNotExist = errors.New("contract not exist")
View Source
var ErrIllegalEntry = errors.New("illegal entry")
View Source
var ErrIllegalSyscallParameters = errors.New("illegal syscall parameters")
View Source
var ErrInsufficientBalance = errors.New("insufficient balance")
View Source
var ErrInvalidJumpDest = errors.New("invalid jump dest")
View Source
var ErrInvalidSyscall = errors.New("invalid syscall")
View Source
var GasSyscallBase = map[int]uint64{ SYSCALL_SELF: 40, SYSCALL_ORIGIN: 40, SYSCALL_CALLER: 40, SYSCALL_CALLVALUE: 40, SYSCALL_STORAGE_STORE: 50000, SYSCALL_STORAGE_LOAD: 50000, SYSCALL_SHA256: 400, SYSCALL_BALANCE: 20000, SYSCALL_LOAD_CONTRACT: 500, SYSCALL_PROTECTED_CALL: 1000, SYSCALL_REVERT: 500, SYSCALL_TIME: 40, SYSCALL_MINER: 40, SYSCALL_BLOCK_NUMBER: 40, SYSCALL_DIFFICULTY: 40, SYSCALL_CHAINID: 40, SYSCALL_GAS: 40, SYSCALL_JUMPDEST: 200, SYSCALL_TRANSFER: 40000, SYSCALL_CREATE: 25000, SYSCALL_ED25519_VERIFY: 50000, SYSCALL_LOAD_ELF: 500, }
Functions ¶
func EncodeBlockHeader ¶
func EncodeBlockHeader(w utils.Writer, bh BlockHeader) error
func ExecVmTxRawCode ¶
func ExecVmTxRawCode(origin AddressType, gasLimit uint64, data []byte, s *storage.Slice, ctx *ExecutionContext, tx *Transaction) (uint64, error)
func ExecVmViewRawCode ¶
func ExecVmViewRawCode(origin AddressType, gasLimit uint64, data []byte, s *storage.Slice, ctx *ExecutionContext) ([]byte, error)
func ExecuteBlock ¶
func ExecuteTx ¶
func ExecuteTx(tx *Transaction, s *storage.Slice, ctx *ExecutionContext) error
func GenKeyPair ¶
func GenKeyPair(r io.Reader) (a PubkeyType, b PrivkeyType)
func LoadContractCode ¶
func LoadContractCode(s *storage.Slice, addr AddressType) ([]byte, error)
func SetAccountInfo ¶
func SetAccountInfo(s *storage.Slice, address AddressType, info AccountInfo)
Types ¶
type AccountInfo ¶
func GetAccountInfo ¶
func GetAccountInfo(s *storage.Slice, address AddressType) AccountInfo
type AddressType ¶
type AddressType [AddressLen]byte
func PubkeyToAddress ¶
func PubkeyToAddress(pk PubkeyType) AddressType
type Block ¶
type Block struct {
Header BlockHeader `json:"header"`
Miner AddressType `json:"miner"`
Time uint64 `json:"time"`
Txs []*Transaction `json:"txs"`
}
func (*Block) ComputeHash ¶
type BlockHeader ¶
type BlockHeader struct {
Hash HashType `json:"hash"`
ParentHash HashType `json:"parent_hash"`
BodyHash HashType `json:"body_hash"`
ExtraData HashType `json:"extra_data"`
}
func DecodeBlockHeader ¶
func DecodeBlockHeader(r utils.Reader) (BlockHeader, error)
func (*BlockHeader) ComputeHash ¶
func (bh *BlockHeader) ComputeHash() HashType
type ExecutionCallback ¶
type ExecutionCallback struct {
Transfer func(s *storage.Slice, from AddressType, to AddressType, value uint64, msg []byte, tx *Transaction, ctx *ExecutionContext)
Block func(s *storage.Slice, b *Block, ctx *ExecutionContext)
}
type ExecutionContext ¶
type ExecutionContext struct {
Height int
Time uint64
Miner AddressType
Difficulty HashType
ChainId uint16
Tip1Enabled bool
Callback *ExecutionCallback
}
type PrivkeyType ¶
type PrivkeyType [PrivkeyLen]byte
type PubkeyType ¶
type Transaction ¶
type Transaction struct {
TxType byte `json:"tx_type"`
SenderPubkey PubkeyType `json:"sender_pubkey"`
SenderSig SigType `json:"sender_sig"`
Receiver AddressType `json:"receiver"`
Value uint64 `json:"value"`
GasLimit uint64 `json:"gas_limit"`
Fee uint64 `json:"fee"`
Nonce uint64 `json:"nonce"`
Data []byte `json:"data"`
}
func (*Transaction) Hash ¶
func (tx *Transaction) Hash() HashType
func (*Transaction) Sign ¶
func (tx *Transaction) Sign(privKey PrivkeyType)
Click to show internal directories.
Click to hide internal directories.