Documentation ¶
Index ¶
- Constants
- func BytesToAddress(b []byte) types.Address
- func BytesToHash(b []byte) types.Hash
- func FromHex(s string) []byte
- func HashAlg() hash.Hash
- func HeaderHash(block *types.Block) (hash types.Hash)
- func Hex2Bytes(str string) []byte
- func HexToAddress(s string) types.Address
- func HexToHash(s string) types.Hash
- func TxHash(tx *types.Transaction) (hash types.Hash)
- type NetAddress
- type RingBuffer
Constants ¶
const ( HashLength = 32 AddressLength = 20 )
Lengths of hashes and addresses in bytes.
Variables ¶
This section is empty.
Functions ¶
func BytesToAddress ¶
BytesToAddress returns Address with value b. If b is larger than len(h), b will be cropped from the left.
func BytesToHash ¶
BytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.
func FromHex ¶
FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".
func HeaderHash ¶
HeaderHash calculate block's hash
func HexToAddress ¶
HexToAddress returns Address with byte values of s. If s is larger than len(h), s will be cropped from the left.
Types ¶
type NetAddress ¶
NetAddress network address
func NewNetAddress ¶
func NewNetAddress(proto, ip string, port int32) *NetAddress
NewNetAddress create a new net address instance
func ParseNetAddress ¶
func ParseNetAddress(addrStr string) (*NetAddress, error)
ParseNetAddress parse net address from address string
func (*NetAddress) Equal ¶
func (addr *NetAddress) Equal(another *NetAddress) bool
Equal check wheter two is equal
func (*NetAddress) IsLoopback ¶
func (addr *NetAddress) IsLoopback() bool
IsLoopback reports whether ip is a loopback address.
func (*NetAddress) ToString ¶
func (addr *NetAddress) ToString() string
ToString encode netaddress to string
type RingBuffer ¶
type RingBuffer struct {
// contains filtered or unexported fields
}
RingBuffer is a ring buffer implementation.
func NewRingBuffer ¶
func NewRingBuffer(size int) *RingBuffer
NewRingBuffer create a ring buffer instance
func (*RingBuffer) AddElement ¶
func (ring *RingBuffer) AddElement(hash types.Hash, elem interface{})
AddElement add a element to ring buffer