Documentation ¶
Index ¶
- Constants
- Variables
- func AppendZeroes(in []byte, l int) []byte
- func Blake2b128(in []byte) ([]byte, error)
- func Blake2b8(data []byte) (digest [8]byte, err error)
- func BytesToHex(in []byte) string
- func BytesToStringArray(in [][]byte) []string
- func BytesToUint(b []byte) (n uint)
- func Concat(s1 []byte, s2 ...byte) []byte
- func HashValidator(field reflect.Value) interface{}
- func HexToBytes(in string) (b []byte, err error)
- func HexToUint(hexString string) (n uint, err error)
- func MustBlake2b8(data []byte) (digest [8]byte)
- func MustHexToBytes(in string) []byte
- func Read32Bytes(r io.Reader) ([32]byte, error)
- func Read4Bytes(r io.Reader) ([]byte, error)
- func Read64Bytes(r io.Reader) ([64]byte, error)
- func Read8Bytes(r io.Reader) ([8]byte, error)
- func ReadByte(r io.Reader) (byte, error)
- func ReadBytes(r io.Reader, n int) ([]byte, error)
- func ReadUint32(r io.Reader) (uint32, error)
- func ReadUint64(r io.Reader) (uint64, error)
- func StringArrayToBytes(in []string) [][]byte
- func StringToInts(in string) (res []int, err error)
- func SwapByteNibbles(b byte) byte
- func SwapNibbles(k []byte) []byte
- func Twox128Hash(msg []byte) (result []byte, err error)
- func Twox64(in []byte) ([]byte, error)
- func Uint16ToBytes(in uint16) (out []byte)
- func UintToBytes(n uint) (b []byte)
- func UintToHex(n uint) (hexString string)
- type Address
- type Hash
- func Blake2bHash(in []byte) (Hash, error)
- func BytesToHash(b []byte) Hash
- func HexToHash(in string) (Hash, error)
- func Keccak256(in []byte) (Hash, error)
- func MustBlake2bHash(in []byte) Hash
- func MustHexToHash(in string) Hash
- func NewHash(in []byte) (res Hash)
- func ReadHash(r io.Reader) (Hash, error)
- func Sha256(in []byte) Hash
- func Twox256(in []byte) (Hash, error)
- type Health
- type NetworkRole
- type NetworkState
- type PeerInfo
Constants ¶
const (
// HashLength is the expected length of the common.Hash type
HashLength = 32
)
Variables ¶
var ( // BestBlockHashKey is the db location the hash of the best (unfinalised) block header. BestBlockHashKey = []byte("best_hash") // LatestStorageHashKey is the db location of the hash of the latest storage trie. LatestStorageHashKey = []byte("latest_storage_hash") // FinalizedBlockHashKey is the db location of the hash of the latest finalised block header. FinalizedBlockHashKey = []byte("finalised_head") // GenesisDataKey is the db location of the genesis data. GenesisDataKey = []byte("genesis_data") // BlockTreeKey is the db location of the encoded block tree structure. BlockTreeKey = []byte("block_tree") // LatestFinalizedRoundKey is the key where the last finalised grandpa round is stored LatestFinalizedRoundKey = []byte("latest_finalised_round") // WorkingStorageHashKey is the storage key that the runtime uses to store the latest working state root. WorkingStorageHashKey = []byte("working_storage_hash") // NodeNameKey is the storage key to store de current node name and avoid create a new name every initialization NodeNameKey = []byte("node_name") // PruningKey is the storage key to store the current pruning configuration. PruningKey = []byte("prune") // CodeSubstitutedBlock is the storage key to store block hash of substituted (if there is currently code substituted) CodeSubstitutedBlock = []byte("code_substituted_block") )
var ( // CodeKey is the key where runtime code is stored in the trie CodeKey = []byte(":code") // UpgradedToDualRefKey is set to true (0x01) if the account format has been upgraded to v0.9 // it's set to empty or false (0x00) otherwise UpgradedToDualRefKey = MustHexToBytes("0x26aa394eea5630e07c48ae0c9558cef7c21aab032aaa6e946ca50ad39ab66603") )
var EmptyHash = Hash{}
var ErrNoPrefix = errors.New("could not byteify non 0x prefixed string")
ErrNoPrefix is returned when trying to convert a hex-encoded string with no 0x prefix
Functions ¶
func AppendZeroes ¶
AppendZeroes appends zeroes to the input byte array up until it has length l
func Blake2b128 ¶
Blake2b128 returns the 128-bit blake2b hash of the input data
func Blake2b8 ¶ added in v0.7.0
Blake2b8 returns the first 8 bytes of the Blake2b hash of the input data
func BytesToHex ¶
BytesToHex turns a byte slice into a 0x prefixed hex string
func BytesToStringArray ¶
BytesToStringArray turns an array of byte arrays into an array strings
func BytesToUint ¶ added in v0.7.0
BytesToUint converts a bytes slice in Big Endian compact format to a uint. This is to imitate the big.NewInt(0).SetBytes(b) behaviour.
func Concat ¶
Concat concatenates two byte arrays used instead of append to prevent modifying the original byte array
func HashValidator ¶ added in v0.3.0
HashValidator validates hash fields
func HexToBytes ¶
HexToBytes turns a 0x prefixed hex string into a byte slice
func HexToUint ¶ added in v0.7.0
HexToUint converts a hex string of bytes in Big Endian compact format to a uint. See BytesToUint for more details.
func MustBlake2b8 ¶ added in v0.7.0
MustBlake2b8 returns the first 8 bytes of the Blake2b hash of the input data
func MustHexToBytes ¶ added in v0.2.0
MustHexToBytes turns a 0x prefixed hex string into a byte slice it panic if it cannot decode the string
func Read32Bytes ¶
Read32Bytes reads 32 bytes from the reader and returns it
func Read4Bytes ¶ added in v0.3.0
Read4Bytes reads 4 bytes from the reader and returns it
func Read64Bytes ¶ added in v0.3.0
Read64Bytes reads 64 bytes from the reader and returns it
func Read8Bytes ¶ added in v0.3.0
Read8Bytes reads 8 bytes from the reader and returns it
func ReadBytes ¶ added in v0.3.0
ReadBytes reads the given number bytes from the reader and returns it
func ReadUint32 ¶
ReadUint32 reads a 4-byte uint32 from the reader and returns it
func ReadUint64 ¶
ReadUint64 reads an 8-byte uint32 from the reader and returns it
func StringArrayToBytes ¶
StringArrayToBytes turns an array of strings into an array of byte arrays
func StringToInts ¶
StringToInts turns a string consisting of ints separated by commas into an int array
func SwapByteNibbles ¶
SwapByteNibbles swaps the two nibbles of a byte
func SwapNibbles ¶
SwapNibbles swaps the nibbles for each byte in the byte array
func Twox128Hash ¶ added in v0.2.0
Twox128Hash computes xxHash64 twice with seeds 0 and 1 applied on given byte array
func Uint16ToBytes ¶
Uint16ToBytes converts a uint16 into a 2-byte slice
func UintToBytes ¶ added in v0.7.0
UintToBytes converts a uint into a Big Endian byte slice using a compact number of bytes. This is to imitate the big.Int().Bytes() behaviour.
Types ¶
type Hash ¶
type Hash [32]byte
Hash used to store a blake2b hash
func Blake2bHash ¶
Blake2bHash returns the 256-bit blake2b hash of the input data
func BytesToHash ¶
BytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.
func MustBlake2bHash ¶ added in v0.3.0
MustBlake2bHash returns the 256-bit blake2b hash of the input data. It panics if it fails to hash.
func MustHexToHash ¶ added in v0.2.0
MustHexToHash turns a 0x prefixed hex string into type Hash it panics if it cannot turn the string into a Hash
func NewHash ¶
NewHash casts a byte array to a Hash if the input is longer than 32 bytes, it takes the first 32 bytes
func (Hash) MarshalJSON ¶ added in v0.3.0
MarshalJSON converts hash to hex data
func (*Hash) SetBytes ¶
SetBytes sets the hash to the value of b. If b is larger than len(h), b will be cropped from the left.
func (Hash) Short ¶ added in v0.7.0
Short returns the first 4 bytes and the last 4 bytes of the hex string for the hash
func (*Hash) UnmarshalJSON ¶ added in v0.3.0
UnmarshalJSON converts hex data to hash
type NetworkRole ¶ added in v0.8.0
type NetworkRole byte
NetworkRole is the type of node.
const ( // NoNetworkRole runs a node without networking NoNetworkRole NetworkRole = 0 // FullNodeRole allow you to read the current state of the chain and to submit and validate // extrinsics directly on the network without relying on a centralised infrastructure provider. FullNodeRole NetworkRole = 1 // LightClientRole node has only the runtime and the current state, but does not store past // blocks and so cannot read historical data without requesting it from a node that has it. LightClientRole NetworkRole = 2 // AuthorityRole runs the node as a block-producing and finalising node AuthorityRole NetworkRole = 4 )
type NetworkState ¶
NetworkState is network information about host needed for the rpc server and the runtime