Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Commit

Permalink
deprecate this repo (#320)
Browse files Browse the repository at this point in the history
* deprecate this repo

* release v0.11.0
  • Loading branch information
marten-seemann committed May 25, 2022
1 parent b8f7f39 commit acda65c
Show file tree
Hide file tree
Showing 30 changed files with 513 additions and 5,524 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
go-libp2p-swarm
# DEPRECATION NOTICE

This package has moved into go-libp2p as a sub-package, github.com/libp2p/go-libp2p/p2p/net/swarm.

# go-libp2p-swarm
==================

[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](https://protocol.ai)
Expand Down
35 changes: 0 additions & 35 deletions addrs.go

This file was deleted.

68 changes: 5 additions & 63 deletions dial_error.go
Original file line number Diff line number Diff line change
@@ -1,71 +1,13 @@
package swarm

import (
"fmt"
"os"
"strings"

"github.com/libp2p/go-libp2p-core/peer"

ma "github.com/multiformats/go-multiaddr"
"github.com/libp2p/go-libp2p/p2p/net/swarm"
)

// maxDialDialErrors is the maximum number of dial errors we record
const maxDialDialErrors = 16

// DialError is the error type returned when dialing.
type DialError struct {
Peer peer.ID
DialErrors []TransportError
Cause error
Skipped int
}

func (e *DialError) Timeout() bool {
return os.IsTimeout(e.Cause)
}

func (e *DialError) recordErr(addr ma.Multiaddr, err error) {
if len(e.DialErrors) >= maxDialDialErrors {
e.Skipped++
return
}
e.DialErrors = append(e.DialErrors, TransportError{
Address: addr,
Cause: err,
})
}

func (e *DialError) Error() string {
var builder strings.Builder
fmt.Fprintf(&builder, "failed to dial %s:", e.Peer)
if e.Cause != nil {
fmt.Fprintf(&builder, " %s", e.Cause)
}
for _, te := range e.DialErrors {
fmt.Fprintf(&builder, "\n * [%s] %s", te.Address, te.Cause)
}
if e.Skipped > 0 {
fmt.Fprintf(&builder, "\n ... skipping %d errors ...", e.Skipped)
}
return builder.String()
}

// Unwrap implements https://godoc.org/golang.org/x/xerrors#Wrapper.
func (e *DialError) Unwrap() error {
return e.Cause
}

var _ error = (*DialError)(nil)
// Deprecated: use github.com/libp2p/go-libp2p/p2p/net/swarm.DialError instead.
type DialError = swarm.DialError

// TransportError is the error returned when dialing a specific address.
type TransportError struct {
Address ma.Multiaddr
Cause error
}

func (e *TransportError) Error() string {
return fmt.Sprintf("failed to dial %s: %s", e.Address, e.Cause)
}

var _ error = (*TransportError)(nil)
// Deprecated: use github.com/libp2p/go-libp2p/p2p/net/swarm.TransportError instead.
type TransportError = swarm.TransportError
109 changes: 0 additions & 109 deletions dial_sync.go

This file was deleted.

Loading

0 comments on commit acda65c

Please sign in to comment.