common

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2019 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package common contains various helper functions.

Index

Constants

View Source
const (
	RewardMasterPercent        = 40
	RewardVoterPercent         = 50
	RewardFoundationPercent    = 10
	HexSignMethod              = "e341eaa4"
	HexSetSecret               = "34d38600"
	HexSetOpening              = "e11f5ba2"
	EpocBlockSecret            = 800
	EpocBlockOpening           = 850
	EpocBlockRandomize         = 900
	MaxMasternodes             = 150
	LimitPenaltyEpoch          = 4
	BlocksPerYear              = uint64(15768000)
	LimitThresholdNonceInQueue = 10
	DefaultMinGasPrice         = 2500
	MergeSignRange             = 15
	RangeReturnSigner          = 150
	MinimunMinerBlockPerEpoch  = 1
)
View Source
const (
	HashLength          = 32
	AddressLength       = 20
	BlockSigners        = "0x0000000000000000000000000000000000000089"
	MasternodeVotingSMC = "0x0000000000000000000000000000000000000088"
	RandomizeSMC        = "0x0000000000000000000000000000000000000090"
	FoudationAddr       = "0x0000000000000000000000000000000000000068"
	TeamAddr            = "0x0000000000000000000000000000000000000099"
	VoteMethod          = "0x6dd7d8ea"
	UnvoteMethod        = "0x02aa9be2"
	ProposeMethod       = "0x01267951"
	ResignMethod        = "0xae6e43f5"
	SignMethod          = "0xe341eaa4"
)

Variables

View Source
var (
	Big1   = big.NewInt(1)
	Big2   = big.NewInt(2)
	Big3   = big.NewInt(3)
	Big0   = big.NewInt(0)
	Big32  = big.NewInt(32)
	Big256 = big.NewInt(256)
	Big257 = big.NewInt(257)
)

Common big integers often used

View Source
var BlackListHFNumber = uint64(9349100)
View Source
var Blacklist = map[Address]bool{
	HexToAddress("0x5248bfb72fd4f234e062d3e9bb76f08643004fcd"): true,
	HexToAddress("0x5ac26105b35ea8935be382863a70281ec7a985e9"): true,
	HexToAddress("0x09c4f991a41e7ca0645d7dfbfee160b55e562ea4"): true,
	HexToAddress("0xb3157bbc5b401a45d6f60b106728bb82ebaa585b"): true,
	HexToAddress("0x741277a8952128d5c2ffe0550f5001e4c8247674"): true,
	HexToAddress("0x10ba49c1caa97d74b22b3e74493032b180cebe01"): true,
	HexToAddress("0x07048d51d9e6179578a6e3b9ee28cdc183b865e4"): true,
	HexToAddress("0x4b899001d73c7b4ec404a771d37d9be13b8983de"): true,
	HexToAddress("0x85cb320a9007f26b7652c19a2a65db1da2d0016f"): true,
	HexToAddress("0x06869dbd0e3a2ea37ddef832e20fa005c6f0ca39"): true,
	HexToAddress("0x82e48bc7e2c93d89125428578fb405947764ad7c"): true,
	HexToAddress("0x1f9a78534d61732367cbb43fc6c89266af67c989"): true,
	HexToAddress("0x7c3b1fa91df55ff7af0cad9e0399384dc5c6641b"): true,
	HexToAddress("0x5888dc1ceb0ff632713486b9418e59743af0fd20"): true,
	HexToAddress("0xa512fa1c735fc3cc635624d591dd9ea1ce339ca5"): true,
	HexToAddress("0x0832517654c7b7e36b1ef45d76de70326b09e2c7"): true,
	HexToAddress("0xca14e3c4c78bafb60819a78ff6e6f0f709d2aea7"): true,
	HexToAddress("0x652ce195a23035114849f7642b0e06647d13e57a"): true,
	HexToAddress("0x29a79f00f16900999d61b6e171e44596af4fb5ae"): true,
	HexToAddress("0xf9fd1c2b0af0d91b0b6754e55639e3f8478dd04a"): true,
	HexToAddress("0xb835710c9901d5fe940ef1b99ed918902e293e35"): true,
	HexToAddress("0x04dd29ce5c253377a9a3796103ea0d9a9e514153"): true,
	HexToAddress("0x2b4b56846eaf05c1fd762b5e1ac802efd0ab871c"): true,
	HexToAddress("0x1d1f909f6600b23ce05004f5500ab98564717996"): true,
	HexToAddress("0x0dfdcebf80006dc9ab7aae8c216b51c6b6759e86"): true,
	HexToAddress("0x2b373890a28e5e46197fbc04f303bbfdd344056f"): true,
	HexToAddress("0xa8a3ef3dc5d8e36aee76f3671ec501ec31e28254"): true,
	HexToAddress("0x4f3d18136fe2b5665c29bdaf74591fc6625ef427"): true,
	HexToAddress("0x175d728b0e0f1facb5822a2e0c03bde93596e324"): true,
	HexToAddress("0xd575c2611984fcd79513b80ab94f59dc5bab4916"): true,
	HexToAddress("0x0579337873c97c4ba051310236ea847f5be41bc0"): true,
	HexToAddress("0xed12a519cc15b286920fc15fd86106b3e6a16218"): true,
	HexToAddress("0x492d26d852a0a0a2982bb40ec86fe394488c419e"): true,
	HexToAddress("0xce5c7635d02dc4e1d6b46c256cae6323be294a32"): true,
	HexToAddress("0x8b94db158b5e78a6c032c7e7c9423dec62c8b11c"): true,
	HexToAddress("0x0e7c48c085b6b0aa7ca6e4cbcc8b9a92dc270eb4"): true,
	HexToAddress("0x206e6508462033ef8425edc6c10789d241d49acb"): true,
	HexToAddress("0x7710e7b7682f26cb5a1202e1cff094fbf7777758"): true,
	HexToAddress("0xcb06f949313b46bbf53b8e6b2868a0c260ff9385"): true,
	HexToAddress("0xf884e43533f61dc2997c0e19a6eff33481920c00"): true,
	HexToAddress("0x8b635ef2e4c8fe21fc2bda027eb5f371d6aa2fc1"): true,
	HexToAddress("0x10f01a27cf9b29d02ce53497312b96037357a361"): true,
	HexToAddress("0x693dd49b0ed70f162d733cf20b6c43dc2a2b4d95"): true,
	HexToAddress("0xe0bec72d1c2a7a7fb0532cdfac44ebab9f6f41ee"): true,
	HexToAddress("0xc8793633a537938cb49cdbbffd45428f10e45b64"): true,
	HexToAddress("0x0d07a6cbbe9fa5c4f154e5623bfe47fb4d857d8e"): true,
	HexToAddress("0xd4080b289da95f70a586610c38268d8d4cf1e4c4"): true,
	HexToAddress("0x8bcfb0caf41f0aa1b548cae76dcdd02e33866a1b"): true,
	HexToAddress("0xabfef22b92366d3074676e77ea911ccaabfb64c1"): true,
	HexToAddress("0xcc4df7a32faf3efba32c9688def5ccf9fefe443d"): true,
	HexToAddress("0x7ec1e48a582475f5f2b7448a86c4ea7a26ea36f8"): true,
	HexToAddress("0xe3de67289080f63b0c2612844256a25bb99ac0ad"): true,
	HexToAddress("0x3ba623300cf9e48729039b3c9e0dee9b785d636e"): true,
	HexToAddress("0x402f2cfc9c8942f5e7a12c70c625d07a5d52fe29"): true,
	HexToAddress("0xd62358d42afbde095a4ca868581d85f9adcc3d61"): true,
	HexToAddress("0x3969f86acb733526cd61e3c6e3b4660589f32bc6"): true,
	HexToAddress("0x67615413d7cdadb2c435a946aec713a9a9794d39"): true,
	HexToAddress("0xfe685f43acc62f92ab01a8da80d76455d39d3cb3"): true,
	HexToAddress("0x3538a544021c07869c16b764424c5987409cba48"): true,
	HexToAddress("0xe187cf86c2274b1f16e8225a7da9a75aba4f1f5f"): true,
}
View Source
var IsTestnet bool = false
View Source
var StoreRewardFolder string
View Source
var TIP2019Block = big.NewInt(1050000)
View Source
var TIPRandomize = big.NewInt(3464000)
View Source
var TIPSigning = big.NewInt(3000000)
View Source
var TRC21GasPrice = big.NewInt(DefaultMinGasPrice)
View Source
var TRC21IssuerSMC = HexToAddress("0x8c0faeb5C6bEd2129b8674F262Fd45c4e9468bee")
View Source
var TRC21IssuerSMCTestNet = HexToAddress("0x7081C72c9DC44686C7B7EAB1d338EA137Fa9f0D3")

Functions

func AbsolutePath

func AbsolutePath(Datadir string, filename string) string

func Bytes2Hex

func Bytes2Hex(d []byte) string

func CopyBytes

func CopyBytes(b []byte) (copiedBytes []byte)

Copy bytes

Returns an exact copy of the provided bytes

func EmptyHash

func EmptyHash(h Hash) bool

func ExtractAddressToBytes added in v0.3.0

func ExtractAddressToBytes(penalties []Address) []byte

Extract validators from byte array.

func FileExist

func FileExist(filePath string) bool

func FromHex

func FromHex(s string) []byte

func Hex2Bytes

func Hex2Bytes(str string) []byte

func Hex2BytesFixed

func Hex2BytesFixed(str string, flen int) []byte

func IsHexAddress

func IsHexAddress(s string) bool

IsHexAddress verifies whether a string can represent a valid hex-encoded Ethereum address or not.

func LeftPadBytes

func LeftPadBytes(slice []byte, l int) []byte

func LoadJSON

func LoadJSON(file string, val interface{}) error

LoadJSON reads the given file and unmarshals its content.

func MakeName

func MakeName(name, version string) string

MakeName creates a node name that follows the ethereum convention for such names. It adds the operation system name and Go runtime version the name.

func PrintDepricationWarning

func PrintDepricationWarning(str string)

PrintDepricationWarning prinst the given string in a box using fmt.Println.

func Report

func Report(extra ...interface{})

Report gives off a warning requesting the user to submit an issue to the github tracker.

func RightPadBytes

func RightPadBytes(slice []byte, l int) []byte

func ToHex

func ToHex(b []byte) string

Types

type Address

type Address [AddressLength]byte

Address represents the 20 byte address of an Ethereum account.

func BigToAddress

func BigToAddress(b *big.Int) Address

func BytesToAddress

func BytesToAddress(b []byte) Address

func ExtractAddressFromBytes added in v0.3.0

func ExtractAddressFromBytes(bytePenalties []byte) []Address

func HexToAddress

func HexToAddress(s string) Address

func RemoveItemFromArray added in v0.3.0

func RemoveItemFromArray(array []Address, items []Address) []Address

Extract validators from byte array.

func StringToAddress

func StringToAddress(s string) Address

func (Address) Big

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

func (Address) Bytes

func (a Address) Bytes() []byte

func (Address) Format

func (a Address) Format(s fmt.State, c rune)

Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.

func (Address) Hash

func (a Address) Hash() Hash

func (Address) Hex

func (a Address) Hex() string

Hex returns an EIP55-compliant hex string representation of the address.

func (Address) MarshalText

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

MarshalText returns the hex representation of a.

func (*Address) Set

func (a *Address) Set(other Address)

Sets a to other

func (*Address) SetBytes

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

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

func (*Address) SetString

func (a *Address) SetString(s string)

Set string `s` to a. If s is larger than len(a) it will panic

func (Address) Str

func (a Address) Str() string

Get the string representation of the underlying address

func (Address) String

func (a Address) String() string

String implements the stringer interface and is used also by the logger.

func (*Address) UnmarshalJSON

func (a *Address) UnmarshalJSON(input []byte) error

UnmarshalJSON parses a hash in hex syntax.

func (*Address) UnmarshalText

func (a *Address) UnmarshalText(input []byte) error

UnmarshalText parses a hash in hex syntax.

type Hash

type Hash [HashLength]byte

Hash represents the 32 byte Keccak256 hash of arbitrary data.

var RollbackHash Hash

func BigToHash

func BigToHash(b *big.Int) Hash

func BytesToHash

func BytesToHash(b []byte) Hash

func HexToHash

func HexToHash(s string) Hash

func StringToHash

func StringToHash(s string) Hash

func (Hash) Big

func (h Hash) Big() *big.Int

func (Hash) Bytes

func (h Hash) Bytes() []byte

func (Hash) Format

func (h Hash) Format(s fmt.State, c rune)

Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.

func (Hash) Generate

func (h Hash) Generate(rand *rand.Rand, size int) reflect.Value

Generate implements testing/quick.Generator.

func (Hash) Hex

func (h Hash) Hex() string

func (Hash) MarshalText

func (h Hash) MarshalText() ([]byte, error)

MarshalText returns the hex representation of h.

func (*Hash) Set

func (h *Hash) Set(other Hash)

Sets h to other

func (*Hash) SetBytes

func (h *Hash) SetBytes(b []byte)

Sets the hash to the value of b. If b is larger than len(h), 'b' will be cropped (from the left).

func (*Hash) SetString

func (h *Hash) SetString(s string)

Set string `s` to h. If s is larger than len(h) s will be cropped (from left) to fit.

func (Hash) Str

func (h Hash) Str() string

Get the string representation of the underlying hash

func (Hash) String

func (h Hash) String() string

String implements the stringer interface and is used also by the logger when doing full logging into a file.

func (Hash) TerminalString

func (h Hash) TerminalString() string

TerminalString implements log.TerminalStringer, formatting a string for console output during logging.

func (*Hash) UnmarshalJSON

func (h *Hash) UnmarshalJSON(input []byte) error

UnmarshalJSON parses a hash in hex syntax.

func (*Hash) UnmarshalText

func (h *Hash) UnmarshalText(input []byte) error

UnmarshalText parses a hash in hex syntax.

type PrettyDuration

type PrettyDuration time.Duration

PrettyDuration is a pretty printed version of a time.Duration value that cuts the unnecessary precision off from the formatted textual representation.

func (PrettyDuration) String

func (d PrettyDuration) String() string

String implements the Stringer interface, allowing pretty printing of duration values rounded to three decimals.

type StorageSize

type StorageSize float64

StorageSize is a wrapper around a float value that supports user friendly formatting.

func (StorageSize) String

func (s StorageSize) String() string

String implements the stringer interface.

func (StorageSize) TerminalString

func (s StorageSize) TerminalString() string

TerminalString implements log.TerminalStringer, formatting a string for console output during logging.

type UnprefixedAddress

type UnprefixedAddress Address

UnprefixedHash allows marshaling an Address without 0x prefix.

func (UnprefixedAddress) MarshalText

func (a UnprefixedAddress) MarshalText() ([]byte, error)

MarshalText encodes the address as hex.

func (*UnprefixedAddress) UnmarshalText

func (a *UnprefixedAddress) UnmarshalText(input []byte) error

UnmarshalText decodes the address from hex. The 0x prefix is optional.

type UnprefixedHash

type UnprefixedHash Hash

UnprefixedHash allows marshaling a Hash without 0x prefix.

func (UnprefixedHash) MarshalText

func (h UnprefixedHash) MarshalText() ([]byte, error)

MarshalText encodes the hash as hex.

func (*UnprefixedHash) UnmarshalText

func (h *UnprefixedHash) UnmarshalText(input []byte) error

UnmarshalText decodes the hash from hex. The 0x prefix is optional.

type Vote added in v1.2.0

type Vote struct {
	Masternode Address
	Voter      Address
}

Directories

Path Synopsis
Package bitutil implements fast bitwise operations.
Package bitutil implements fast bitwise operations.
Package compiler wraps the Solidity compiler executable (solc).
Package compiler wraps the Solidity compiler executable (solc).
Package hexutil implements hex encoding with 0x prefix.
Package hexutil implements hex encoding with 0x prefix.
Package math provides integer math utilities.
Package math provides integer math utilities.
package mclock is a wrapper for a monotonic clock source
package mclock is a wrapper for a monotonic clock source

Jump to

Keyboard shortcuts

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