Documentation ¶
Index ¶
- Constants
- Variables
- func BigToDecimal(amount *big.Int) string
- func ConvertInt64ToBytes(num int64) []byte
- func CopyBytes(src []byte) []byte
- func Deserialize(data []byte, value interface{}) error
- func FileOrFolderExists(fileOrFolder string) bool
- func GetDefaultDataFolder() string
- func GetDefaultIPCPath() string
- func GetPassword() (string, error)
- func GetTempFolder() string
- func IsShardEnabled() bool
- func LeftPadBytes(slice []byte, l int) []byte
- func MustNewCache(size int) *lru.Cache
- func RightPadBytes(slice []byte, l int) []byte
- func SaveFile(filePath string, content []byte) error
- func Serialize(in interface{}) ([]byte, error)
- func SerializePanic(in interface{}) []byte
- func SetPassword() (string, error)
- func Shuffle(slice interface{})
- type Address
- func (id Address) Big() *big.Int
- func (id Address) Bytes() []byte
- func (id *Address) CreateContractAddress(nonce uint64, hashFunc func(interface{}) Hash) Address
- func (id *Address) CreateContractAddressWithHash(h Hash) Address
- func (id *Address) Equal(b Address) bool
- func (id Address) Hex() string
- func (id *Address) IsEVMContract() bool
- func (id *Address) IsEmpty() bool
- func (id *Address) IsReserved() bool
- func (id Address) MarshalText() ([]byte, error)
- func (id *Address) Shard() uint
- func (id Address) String() string
- func (id *Address) Type() AddressType
- func (id *Address) UnmarshalText(json []byte) error
- func (id *Address) Validate() error
- type AddressType
- type BaseHeapItem
- type Bytes
- type Hash
- func (a Hash) Big() *big.Int
- func (a Hash) Bytes() []byte
- func (a *Hash) Equal(b Hash) bool
- func (a Hash) Hex() string
- func (a Hash) IsEmpty() bool
- func (a Hash) MarshalText() ([]byte, error)
- func (a *Hash) SetBytes(b []byte)
- func (a Hash) String() string
- func (a *Hash) UnmarshalText(json []byte) error
- type Heap
- type HeapItem
Constants ¶
const ( // AddressLen length in bytes AddressLen = 20 // AddressTypeExternal is the address type for external account. AddressTypeExternal = AddressType(1) // AddressTypeContract is the address type for contract account. AddressTypeContract = AddressType(2) // AddressTypeReserved is the reserved address type for system contract. // Note, the address type (4 bits) value ranges [0,15], so the system reserved // address type value should greater than 15. AddressTypeReserved = AddressType(16) )
const ( // SeeleProtoName protoName of Seele service SeeleProtoName = "seele" // SeeleVersion Version number of Seele protocol SeeleVersion uint = 1 // SeeleVersion for simpler display SeeleNodeVersion string = "v1.2.4" // ShardCount represents the total number of shards. ShardCount = 4 // MetricsRefreshTime is the time of metrics sleep 1 minute MetricsRefreshTime = time.Minute // CPUMetricsRefreshTime is the time of metrics monitor cpu CPUMetricsRefreshTime = time.Second // ConfirmedBlockNumber is the block number for confirmed a block, it should be more than 12 in product ConfirmedBlockNumber = 120 // ForkHeight after this height we change the content of block: hardFork ForkHeight = 130000 // ForkHeight after this height we change the content of block: hardFork SecondForkHeight = 145000 // ForkHeight after this height we change the validation of tx: hardFork ThirdForkHeight = 735000 SmartContractNonceForkHeight = 1100000 // LightChainDir lightchain data directory based on config.DataRoot LightChainDir = "/db/lightchain" // EthashAlgorithm miner algorithm ethash EthashAlgorithm = "ethash" // Sha256Algorithm miner algorithm sha256 Sha256Algorithm = "sha256" // spow miner algorithm SpowAlgorithm = "spow" // BFT mineralgorithm BFTEngine = "bft" // BFT data folder BFTDataFolder = "bftdata" // EVMStackLimit increase evm stack limit to 8192 EVMStackLimit = 8192 // BlockPackInterval it's an estimate time. BlockPackInterval = 15 * time.Second // Height: fix the issue caused by forking from collapse database HeightFloor = uint64(707989) HeightRoof = uint64(707996) WindowsPipeDir = `\\.\pipe\` )
const (
// HashLength the leghth of hash
HashLength = 32
)
const UndefinedShardNumber = uint(0)
UndefinedShardNumber is the default value if shard number not specified.
Variables ¶
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
var EmptyAddress = Address{}
EmptyAddress presents an empty address
var EmptyHash = Hash{}
EmptyHash empty hash
var ErrOnly0xPrefix = errors.New("the string is invalid length only 0x or 0X prefix")
ErrOnly0xPrefix the string is invalid length only 0x or 0X prefix
var LocalShardNumber uint
LocalShardNumber defines the shard number of coinbase. Generally, it must be initialized during program startup.
var MaxSystemContractAddress = BytesToAddress([]byte{4, 255})
MaxSystemContractAddress max system contract address
var ( //SeeleToFan base feifan coin number SeeleToFan = big.NewInt(100000000) )
Functions ¶
func BigToDecimal ¶
BigToDecimal simply changes big int to decimal which will miss additional 0 in the last
func ConvertInt64ToBytes ¶
ConvertInt64ToBytes converts a int64 value into a byte array
func Deserialize ¶
Deserialize wrapper decode
func FileOrFolderExists ¶
FileOrFolderExists checks if a file or folder exists
func GetDefaultDataFolder ¶
func GetDefaultDataFolder() string
GetDefaultDataFolder gets the default data Folder
func GetDefaultIPCPath ¶
func GetDefaultIPCPath() string
func GetPassword ¶
GetPassword ask user for password interactively
func IsShardEnabled ¶
func IsShardEnabled() bool
IsShardEnabled returns true if the LocalShardNumber is set. Otherwise, false.
func LeftPadBytes ¶
LeftPadBytes zero-pads slice to the left up to length l.
func MustNewCache ¶
func MustNewCache(size int) *lru.Cache
MustNewCache creates a LRU cache with specified size. Panics on any error.
func RightPadBytes ¶
RightPadBytes zero-pads slice to the right up to length l.
func SerializePanic ¶
func SerializePanic(in interface{}) []byte
SerializePanic serialize the input data to byte array. Panics on error, e.g. unsupported data type for RLP encoding.
func SetPassword ¶
SetPassword ask user input password twice and get the password interactively
Types ¶
type Address ¶
type Address [AddressLen]byte
Address we use public key as node id
func BigToAddress ¶
BigToAddress converts a big int to address.
func BytesToAddress ¶
BytesToAddress converts the specified byte array to Address.
func HexMustToAddres ¶
HexMustToAddres converts the specified HEX string to address. Panics on any error.
func HexToAddress ¶
HexToAddress converts the specified HEX string to address.
func NewAddress ¶
NewAddress converts a byte slice to a Address
func PubKeyToAddress ¶
PubKeyToAddress converts a ECC public key to an external address.
func (Address) Bytes ¶
Bytes get the actual bytes
Note: if we want to use pointer type, need to change the code snippet in unit test:
BytesToAddress([]byte{1, 2}).Bytes() -> addrBytes := BytesToAddress([]byte{1, 2}) (&addrBytes).Bytes()
refer link: https://stackoverflow.com/questions/10535743/address-of-a-temporary-in-go
func (*Address) CreateContractAddress ¶
CreateContractAddress returns a contract address that in the same shard of this address.
func (*Address) CreateContractAddressWithHash ¶
CreateContractAddressWithHash returns a contract address that in the same shard of this address.
func (*Address) IsEVMContract ¶
IsEVMContract indicates whether the address is EVM contract address.
func (*Address) IsReserved ¶
IsReserved returns true if the address is reserved
func (Address) MarshalText ¶
MarshalText marshals the address to HEX string.
func (*Address) UnmarshalText ¶
UnmarshalText unmarshals address from HEX string.
type BaseHeapItem ¶
type BaseHeapItem struct {
// contains filtered or unexported fields
}
BaseHeapItem is base struct of any heap item.
func (*BaseHeapItem) GetHeapIndex ¶
func (item *BaseHeapItem) GetHeapIndex() int
GetHeapIndex returns the item index in heap.
type Bytes ¶
type Bytes []byte
Bytes is a array byte that is converted to hex string display format when marshal
func (Bytes) MarshalText ¶
MarshalText implement the TextMarshaler interface
func (*Bytes) UnmarshalText ¶
UnmarshalText implement the TextUnmarshaler interface
type Hash ¶
type Hash [HashLength]byte
Hash the hash value generated by sha-3
func MustHexToHash ¶
func (*Hash) Equal ¶
Equal returns a boolean value indicating whether the hash a is equal to the input hash b.
func (Hash) MarshalText ¶
MarshalText marshals the Hash to HEX string.
func (*Hash) UnmarshalText ¶
UnmarshalText unmarshals Hash from HEX string.
type Heap ¶
type Heap struct {
// contains filtered or unexported fields
}
Heap is a common used heap for generic type purpose.