utils

package
v0.0.0-...-6333696 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxChunkLength         = 4096
	FileNameLength         = 50
	MaxDirectoryNameLength = 50
	PathSeperator          = string(os.PathSeparator)
	MaxPodNameLength       = 25
	SpanLength             = 8
)
View Source
const (
	AddressLength = 20
)
View Source
const (
	ReferenceLength = 32
)

Variables

View Source
var (
	ErrEmptyString   = &decError{"empty hex string"}
	ErrMissingPrefix = &decError{"hex string without 0x prefix"}
	ErrSyntax        = &decError{"invalid hex string"}
	ErrOddLength     = &decError{"hex string of odd length"}
	ErrUint64Range   = &decError{"hex number > 64 bits"}
)
View Source
var ZeroAddress = NewAddress(nil)

Functions

func Decode

func Decode(input string) ([]byte, error)

Decode decodes a hex string with 0x prefix.

func Encode

func Encode(b []byte) string

Encode encodes b as a hex string with 0x prefix.

func FromHex

func FromHex(s string) []byte

func HashString

func HashString(path string) []byte

func Hex2Bytes

func Hex2Bytes(str string) []byte

func XORBytes

func XORBytes(dst, a, b []byte) int

Types

type Address

type Address [AddressLength]byte

func BytesToAddress

func BytesToAddress(b []byte) Address

func HexToAddress

func HexToAddress(s string) Address

func NewAddress

func NewAddress(b []byte) Address

func (Address) Hex

func (a Address) Hex() string

func (*Address) ParseAddress

func (a *Address) ParseAddress(s string) (Address, error)

func (*Address) SetBytes

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

func (*Address) String

func (a *Address) String() string

func (Address) StringToAddress

func (a Address) StringToAddress(addr string) error

func (Address) ToBytes

func (a Address) ToBytes() []byte

type Reference

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

func NewReference

func NewReference(b []byte) Reference

func ParseHexReference

func ParseHexReference(s string) (a Reference, err error)

func (Reference) Bytes

func (ref Reference) Bytes() []byte

func (Reference) String

func (ref Reference) String() string

type SharingReference

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

func NewSharingReference

func NewSharingReference(b []byte, n int64) SharingReference

func ParseSharingReference

func ParseSharingReference(s string) (a SharingReference, err error)

func (SharingReference) GetNonce

func (ref SharingReference) GetNonce() int64

func (SharingReference) GetRef

func (ref SharingReference) GetRef() []byte

func (SharingReference) String

func (ref SharingReference) String() string

Jump to

Keyboard shortcuts

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