utils

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2020 License: LGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library. * * The ontology is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The ontology is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with The ontology. If not, see <http://www.gnu.org/licenses/>.

* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library. * * The ontology is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The ontology is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with The ontology. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

View Source
var (
	BYTE_FALSE = []byte{0}
	BYTE_TRUE  = []byte{1}

	OntContractAddress, _        = common.AddressParseFromBytes([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01})
	OngContractAddress, _        = common.AddressParseFromBytes([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02})
	OntIDContractAddress, _      = common.AddressParseFromBytes([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03})
	ParamContractAddress, _      = common.AddressParseFromBytes([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04})
	AuthContractAddress, _       = common.AddressParseFromBytes([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06})
	GovernanceContractAddress, _ = common.AddressParseFromBytes([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07})
	HeaderSyncContractAddress, _ = common.AddressParseFromBytes([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08})
	CrossChainContractAddress, _ = common.AddressParseFromBytes([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09})
	LockProxyContractAddress, _  = common.AddressParseFromBytes([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a})
	OntFSContractAddress, _      = common.AddressParseFromBytes([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b})
)
View Source
var (
	TIME_INTERVAL         = constants.UNBOUND_TIME_INTERVAL
	GENERATION_AMOUNT     = constants.UNBOUND_GENERATION_AMOUNT
	NEW_GENERATION_AMOUNT = constants.NEW_UNBOUND_GENERATION_AMOUNT
)

Functions

func CalcGovernanceUnbindOng

func CalcGovernanceUnbindOng(startOffset, endOffset uint32) uint64

startOffset : start timestamp offset from genesis block endOffset : end timestamp offset from genesis block

func CalcUnbindOng

func CalcUnbindOng(balance uint64, startOffset, endOffset uint32) uint64

startOffset : start timestamp offset from genesis block endOffset : end timestamp offset from genesis block

func ConcatBytes

func ConcatBytes(args ...[]byte) []byte

func ConcatKey

func ConcatKey(contract common.Address, args ...[]byte) []byte

func DecodeAddress

func DecodeAddress(source *common.ZeroCopySource) (common.Address, error)

func DecodeBool

func DecodeBool(source *common.ZeroCopySource) (bool, error)

func DecodeString

func DecodeString(source *common.ZeroCopySource) (string, error)

func DecodeUint32

func DecodeUint32(source *common.ZeroCopySource) (uint32, error)

func DecodeUint64

func DecodeUint64(source *common.ZeroCopySource) (uint64, error)

func DecodeVarBytes

func DecodeVarBytes(source *common.ZeroCopySource) ([]byte, error)

func DecodeVarUint

func DecodeVarUint(source *common.ZeroCopySource) (uint64, error)

func EncodeAddress

func EncodeAddress(sink *common.ZeroCopySink, addr common.Address) (size uint64)

func EncodeBool

func EncodeBool(sink *common.ZeroCopySink, value bool)

func EncodeString

func EncodeString(sink *common.ZeroCopySink, str string) (size uint64)

func EncodeVarBytes

func EncodeVarBytes(sink *common.ZeroCopySink, v []byte) (size uint64)

func EncodeVarUint

func EncodeVarUint(sink *common.ZeroCopySink, value uint64) (size uint64)

func GenUInt32StorageItem

func GenUInt32StorageItem(value uint32) *cstates.StorageItem

func GenUInt64StorageItem

func GenUInt64StorageItem(value uint64) *cstates.StorageItem

func GenVarBytesStorageItem

func GenVarBytesStorageItem(value []byte) *cstates.StorageItem

func GetBytesUint32

func GetBytesUint32(b []byte) (uint32, error)

func GetBytesUint64

func GetBytesUint64(b []byte) (uint64, error)

func GetStorageItem

func GetStorageItem(native *native.NativeService, key []byte) (*cstates.StorageItem, error)

func GetStorageUInt32

func GetStorageUInt32(native *native.NativeService, key []byte) (uint32, error)

func GetStorageUInt64

func GetStorageUInt64(native *native.NativeService, key []byte) (uint64, error)

func GetStorageVarBytes

func GetStorageVarBytes(native *native.NativeService, key []byte) ([]byte, error)

func GetUint32Bytes

func GetUint32Bytes(num uint32) ([]byte, error)

func GetUint64Bytes

func GetUint64Bytes(num uint64) ([]byte, error)

func IsNativeContract

func IsNativeContract(addr common.Address) bool

func LinkedlistDelete

func LinkedlistDelete(native *native.NativeService, index []byte, item []byte) (bool, error)

func LinkedlistDeleteAll

func LinkedlistDeleteAll(native *native.NativeService, index []byte) error

func LinkedlistGetHead

func LinkedlistGetHead(native *native.NativeService, index []byte) ([]byte, error)

func LinkedlistGetNumOfItems

func LinkedlistGetNumOfItems(native *native.NativeService, index []byte) (int, error)

func LinkedlistInsert

func LinkedlistInsert(native *native.NativeService, index []byte, item []byte, payload []byte) error

func PutBytes

func PutBytes(native *native.NativeService, key []byte, value []byte)

func ValidateOwner

func ValidateOwner(native *native.NativeService, address common.Address) error

Types

type LinkedlistNode

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

func LinkedlistGetItem

func LinkedlistGetItem(native *native.NativeService, index []byte, item []byte) (*LinkedlistNode, error)

func (*LinkedlistNode) Deserialization

func (this *LinkedlistNode) Deserialization(r []byte) error

func (*LinkedlistNode) GetNext

func (this *LinkedlistNode) GetNext() []byte

func (*LinkedlistNode) GetPayload

func (this *LinkedlistNode) GetPayload() []byte

func (*LinkedlistNode) GetPrevious

func (this *LinkedlistNode) GetPrevious() []byte

func (*LinkedlistNode) Serialization

func (this *LinkedlistNode) Serialization() ([]byte, error)

Jump to

Keyboard shortcuts

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