p2putil

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2020 License: Apache-2.0 Imports: 8 Imported by: 9

Documentation

Overview

Copyright 2020 PhysarumSM Development Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadMsg

func ReadMsg(stream network.Stream) (data []byte, err error)

Read from stream

func WriteMsg

func WriteMsg(stream network.Stream, data []byte) (err error)

Write to stream

Types

type PeerInfo

type PeerInfo struct {
	ID       peer.ID
	Perf     PerfInd
	ServName string
	ServHash string
}

PeerInfo holds information relative peer performance and contact information

func SortPeers

func SortPeers(peerChan <-chan peer.AddrInfo, node p2pnode.Node) []PeerInfo

Get performance indicators and return sorted peers based on it

type PerfInd

type PerfInd struct {
	RTT time.Duration
}

Performance indicator

func (PerfInd) Equal

func (l PerfInd) Equal(r PerfInd) bool

func (PerfInd) GreaterThan

func (l PerfInd) GreaterThan(r PerfInd) bool

func (PerfInd) LessThan

func (l PerfInd) LessThan(r PerfInd) bool

Compares whether l performance is less than r performance TODO: Figure out how to handle comparison if PerfInd contains more

than a single metric

Jump to

Keyboard shortcuts

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