node

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Copyright © 2023 AMIS Technologies

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 GetPeerAddr

func GetPeerAddr(port int64, peerId string) string

getPeerAddr gets peer full address from port.

func MakeBasicHost

func MakeBasicHost(port int64, priv crypto.PrivKey) (host.Host, error)

MakeBasicHost creates a LibP2P host.

func New

func New[M Message, R any](backend Backend[M, R], l Listener, pm types.PeerManager) *node[M, R]

func NewListener

func NewListener() *listener

func NewPeerManager

func NewPeerManager(id string, host host.Host, protocol protocol.ID) *peerManager

Types

type Backend

type Backend[M Message, R any] interface {
	AddMessage(senderId string, msg types.Message) error
	Start()
	Stop()
	GetResult() (R, error)
}

type Listener

type Listener interface {
	types.StateChangedListener

	Done() <-chan error
}

type Message

type Message interface {
	types.Message
	proto.Message
}

type PeerConfig

type PeerConfig struct {
	Port     int64  `yaml:"port"`
	Identity string `yaml:"identity"`
	Peers    []struct {
		Id   string `yaml:"id"`
		Port int64  `yaml:"port"`
	} `yaml:"peers"`
}

Jump to

Keyboard shortcuts

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