p2p

package
v0.0.0-...-69e5406 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

*

  • Description:
  • Author: Yihen.Liu
  • Create: 2019-07-22

Index

Constants

View Source
const DefaultSleepInterval = 100 * time.Millisecond

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Protocol             string   `protobuf:"bytes,1,opt,name=protocol,proto3" json:"protocol,omitempty"`
	Ip                   string   `protobuf:"bytes,2,opt,name=ip,proto3" json:"ip,omitempty"`
	Port                 int32    `protobuf:"varint,3,opt,name=port,proto3" json:"port,omitempty"`
	PubId                string   `protobuf:"bytes,4,opt,name=pub_id,json=pubId,proto3" json:"pub_id,omitempty"`
	Seedlist             []*Seed  `protobuf:"bytes,5,rep,name=seedlist,proto3" json:"seedlist,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Config) Descriptor

func (*Config) Descriptor() ([]byte, []int)

func (*Config) GetIp

func (m *Config) GetIp() string

func (*Config) GetPort

func (m *Config) GetPort() int32

func (*Config) GetProtocol

func (m *Config) GetProtocol() string

func (*Config) GetPubId

func (m *Config) GetPubId() string

func (*Config) GetSeedlist

func (m *Config) GetSeedlist() []*Seed

func (*Config) ProtoMessage

func (*Config) ProtoMessage()

func (*Config) Reset

func (m *Config) Reset()

func (*Config) String

func (m *Config) String() string

func (*Config) XXX_DiscardUnknown

func (m *Config) XXX_DiscardUnknown()

func (*Config) XXX_Marshal

func (m *Config) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Config) XXX_Merge

func (m *Config) XXX_Merge(src proto.Message)

func (*Config) XXX_Size

func (m *Config) XXX_Size() int

func (*Config) XXX_Unmarshal

func (m *Config) XXX_Unmarshal(b []byte) error

type Instance

type Instance struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Instance is a log.Handler that handles logs.

func New

func New(ctx context.Context, config *Config) (*Instance, error)

New creates a new log.Instance based on the given config.

func (*Instance) Close

func (g *Instance) Close() error

Close implements common.Closable.Close().

func (*Instance) Handle

func (g *Instance) Handle(msg log.Message)

Handle implements log.Handler.

func (*Instance) Start

func (g *Instance) Start() error

Start implements common.Runnable.Start().

func (*Instance) Type

func (*Instance) Type() interface{}

Type implements common.HasType.

type P2PNode

type P2PNode struct {
	Host      core.Host
	Protocols protocol.Protocol

	Config *Config
	// contains filtered or unexported fields
}

func NewP2PNode

func NewP2PNode(config *Config) *P2PNode

func (*P2PNode) Bootstrap

func (this *P2PNode) Bootstrap()

func (*P2PNode) DoSeedListRequest

func (this *P2PNode) DoSeedListRequest(pid peer.ID)

func (*P2PNode) SayHello

func (s *P2PNode) SayHello(ctx context.Context, in *wire.HelloSeedList) (*wire.HelloReply, error)

SayHello implements helloworld.GreeterServer

func (*P2PNode) StartGrpcServer

func (this *P2PNode) StartGrpcServer()

func (*P2PNode) StartListen

func (this *P2PNode) StartListen(done chan struct{})

func (*P2PNode) StartService

func (this *P2PNode) StartService()

type Seed

type Seed struct {
	Protocol             string   `protobuf:"bytes,1,opt,name=protocol,proto3" json:"protocol,omitempty"`
	Ip                   string   `protobuf:"bytes,2,opt,name=ip,proto3" json:"ip,omitempty"`
	Port                 int32    `protobuf:"varint,3,opt,name=port,proto3" json:"port,omitempty"`
	PubId                string   `protobuf:"bytes,4,opt,name=pub_id,json=pubId,proto3" json:"pub_id,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Seed) Descriptor

func (*Seed) Descriptor() ([]byte, []int)

func (*Seed) GetIp

func (m *Seed) GetIp() string

func (*Seed) GetPort

func (m *Seed) GetPort() int32

func (*Seed) GetProtocol

func (m *Seed) GetProtocol() string

func (*Seed) GetPubId

func (m *Seed) GetPubId() string

func (*Seed) ProtoMessage

func (*Seed) ProtoMessage()

func (*Seed) Reset

func (m *Seed) Reset()

func (*Seed) String

func (m *Seed) String() string

func (*Seed) XXX_DiscardUnknown

func (m *Seed) XXX_DiscardUnknown()

func (*Seed) XXX_Marshal

func (m *Seed) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Seed) XXX_Merge

func (m *Seed) XXX_Merge(src proto.Message)

func (*Seed) XXX_Size

func (m *Seed) XXX_Size() int

func (*Seed) XXX_Unmarshal

func (m *Seed) XXX_Unmarshal(b []byte) error

Directories

Path Synopsis
*
Package main implements a client for Greeter service.
Package main implements a client for Greeter service.
*
*
*
*

Jump to

Keyboard shortcuts

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