util

package
v0.0.0-...-cc45bd3 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBucketSize = 20
)

Variables

View Source
var IDLength = 16

IDLength is here as a variable so that it can be decreased for tests with mocknet where IDs are way shorter. The call to FmtPeerID would panic if this value stayed at 16.

Functions

func BucketIdForPeer

func BucketIdForPeer(localPeer, remotePeer peer.ID) int16

func ErrorStr

func ErrorStr(err error) *string

func FmtPeerID

func FmtPeerID(id peer.ID) string

func NowPtr

func NowPtr() *time.Time

func StrPtr

func StrPtr(str string) *string

func TimeToStr

func TimeToStr(t *time.Time) *string

func UniqueInt

func UniqueInt(input []int) *int

func UniqueStr

func UniqueStr(input []string) *string

Types

type Content

type Content struct {
	CID cid.Cid
	// contains filtered or unexported fields
}

Content encapsulates multiple representations of the same data.

func NewRandomContent

func NewRandomContent() (*Content, error)

NewRandomContent reads 1024 bytes from crypto/rand and builds a content struct.

func (*Content) DistanceTo

func (c *Content) DistanceTo(peerID peer.ID) []byte

DistanceTo returns the XOR distance of the content to the provided peer ID as it is used in the libp2p Kademlia DHT.

Jump to

Keyboard shortcuts

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