dht

package
v1.65.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2020 License: BSD-3-Clause Imports: 35 Imported by: 1

Documentation

Overview

Package dht 基于libp2p实现p2p 插件

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenPrivPubkey

func GenPrivPubkey() ([]byte, []byte, error)

GenPrivPubkey return key and pubkey in bytes

func GenPubkey

func GenPubkey(key string) (string, error)

GenPubkey generate public key

func New

func New(mgr *p2p.Manager, subCfg []byte) p2p.IP2P

New new dht p2p network

func PeerIDToPubkey added in v1.65.0

func PeerIDToPubkey(id string) (string, error)

PeerIDToPubkey 提供节点ID转换为pubkey,进而通过pubkey创建chain33 地址的功能

Types

type AddrBook

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

AddrBook peer address manager

func NewAddrBook

func NewAddrBook(cfg *types.P2P) *AddrBook

NewAddrBook new addr book

func (*AddrBook) AddrsInfo

func (a *AddrBook) AddrsInfo() []peer.AddrInfo

AddrsInfo get addr infos

func (*AddrBook) GetPrivPubKey

func (a *AddrBook) GetPrivPubKey() (string, string)

GetPrivPubKey return privkey and pubkey

func (*AddrBook) GetPrivkey

func (a *AddrBook) GetPrivkey() p2pcrypto.PrivKey

GetPrivkey get private key

func (*AddrBook) Randkey added in v1.65.0

func (a *AddrBook) Randkey() p2pcrypto.PrivKey

Randkey Rand keypair

func (*AddrBook) SaveAddr

func (a *AddrBook) SaveAddr(addrinfos []peer.AddrInfo) error

SaveAddr save addr

func (*AddrBook) StoreHostID

func (a *AddrBook) StoreHostID(id peer.ID, path string)

StoreHostID store host id into file

type P2P

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

P2P p2p struct

func (*P2P) CloseP2P

func (p *P2P) CloseP2P()

CloseP2P close p2p

func (*P2P) StartP2P

func (p *P2P) StartP2P()

StartP2P start p2p

Directories

Path Synopsis
Package manage p2p manage
Package manage p2p manage
Package net net utils
Package net net utils
Package protocol p2p protocol
Package protocol p2p protocol
broadcast
Package broadcast broadcast protocol
Package broadcast broadcast protocol
types
Package types protocol and stream register `
Package types protocol and stream register `
Package types dht public types Package types 外部公用类型
Package types dht public types Package types 外部公用类型

Jump to

Keyboard shortcuts

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