common

package
v0.0.0-...-84d53aa Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2019 License: GPL-3.0 Imports: 6 Imported by: 26

Documentation

Index

Constants

View Source
const (
	AddressLength = 33
	HashLength    = 32
)

Types' length.

Variables

This section is empty.

Functions

func IsHash

func IsHash(s string) bool

IsHash checks hash string.

func IsHexAddress

func IsHexAddress(s string) bool

IsHexAddress checks hex address.

Types

type Address

type Address [AddressLength]byte

Address represents Address.

func BytesToAddress

func BytesToAddress(b []byte) (Address, error)

BytesToAddress gets Address from bytes.

func HexToAddress

func HexToAddress(s string) (Address, error)

HexToAddress gets Address from hex string.

func PublicKeyToAddress

func PublicKeyToAddress(p signature.PublicKey) (Address, error)

PublicKeyToAddress gets Address from PublicKey.

func (Address) Big

func (a Address) Big() *big.Int

Big returns Address in big Int.

func (Address) Bytes

func (a Address) Bytes() []byte

Bytes returns Address in bytes.

func (Address) Equals

func (a Address) Equals(b Address) bool

Equals compare Address.

func (*Address) FromBytes

func (a *Address) FromBytes(b []byte) error

FromBytes convert byte slice to slice (for trie.Serializable)

func (Address) Hex

func (a Address) Hex() string

Hex returns Address in hex string

func (*Address) SetBytes

func (a *Address) SetBytes(b []byte)

SetBytes the address to the value of b. If b is larger than len(a) it will panic

func (Address) Str

func (a Address) Str() string

Str returns Address in string.

func (Address) String

func (a Address) String() string

String is a stringer interface of Address.

func (Address) ToBytes

func (a Address) ToBytes() ([]byte, error)

ToBytes convert address to byte slice (for trie.Serializable)

type Bandwidth

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

Bandwidth is structure for cpu and net bandwidth

func NewBandwidth

func NewBandwidth(cpu, net uint64) *Bandwidth

NewBandwidth returns new bandwidth

func (*Bandwidth) Add

func (b *Bandwidth) Add(obj *Bandwidth)

Add add obj's bandwidth

func (*Bandwidth) CPUUsage

func (b *Bandwidth) CPUUsage() uint64

CPUUsage returns cpuUsage

func (*Bandwidth) CalcPoints

func (b *Bandwidth) CalcPoints(p Price) (points *util.Uint128, err error)

CalcPoints multiply bandwidth and price

func (*Bandwidth) Clone

func (b *Bandwidth) Clone() *Bandwidth

Clone clones existing bandwidth struct.

func (Bandwidth) IsZero

func (b Bandwidth) IsZero() bool

IsZero return true when cpu and net value are both zero

func (*Bandwidth) NetUsage

func (b *Bandwidth) NetUsage() uint64

NetUsage returns netUsage

func (*Bandwidth) SetCPUUsage

func (b *Bandwidth) SetCPUUsage(cpuUsage uint64)

SetCPUUsage sets cpuUsage

func (*Bandwidth) SetNetUsage

func (b *Bandwidth) SetNetUsage(netUsage uint64)

SetNetUsage sets netUsage

func (*Bandwidth) Sub

func (b *Bandwidth) Sub(obj *Bandwidth)

Sub subtract obj's bandwidth

type Price

type Price struct {
	CPUPrice *util.Uint128
	NetPrice *util.Uint128
}

Price is structure for prices of cpu and net

Directories

Path Synopsis
pb
Package triepb is a generated protocol buffer package.
Package triepb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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