utils

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2021 License: LGPL-3.0 Imports: 12 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})
	SystemContractAddress, _     = common.AddressParseFromBytes([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff})
)
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 added in v1.15.0

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 added in v1.15.0

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

func ConcatKey

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

func DecodeAddress added in v1.0.3

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

func DecodeBool added in v1.15.0

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

func DecodeString added in v1.15.0

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

func DecodeUint32 added in v1.15.0

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

func DecodeUint64 added in v1.15.0

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

func DecodeVarBytes added in v1.15.0

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

func DecodeVarUint added in v1.0.3

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

func EncodeAddress added in v1.0.3

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

func EncodeBool added in v1.15.0

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

func EncodeString added in v1.15.0

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

func EncodeVarBytes added in v1.15.0

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

func EncodeVarUint added in v1.0.3

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 added in v1.15.0

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

func GetBytesUint32 added in v1.15.0

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

func GetBytesUint64 added in v1.15.0

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

func GetNativeTokenBalance added in v1.15.0

func GetNativeTokenBalance(cacheDB *storage.CacheDB, key []byte) (cstates.NativeTokenBalance, error)

func GetStorageItem

func GetStorageItem(cacheDB *storage.CacheDB, key []byte) (*cstates.StorageItem, error)

func GetStorageUInt32

func GetStorageUInt32(cacheDB *storage.CacheDB, key []byte) (uint32, error)

func GetStorageVarBytes added in v1.15.0

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

func GetUint32Bytes added in v1.15.0

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

func GetUint64Bytes added in v1.15.0

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

func IsNativeContract added in v1.8.0

func IsNativeContract(addr common.Address) bool

func LinkedlistDelete

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

func LinkedlistDeleteAll added in v1.15.0

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 added in v1.15.0

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 added in v1.15.0

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

Jump to

Keyboard shortcuts

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