Unverified Commit dee88d75 authored by Steven Allen's avatar Steven Allen Committed by GitHub

Merge pull request #95 from libp2p/chore/update-deps

chore(dep): update deps
parents f4c9af19 334bc6f8
...@@ -4,8 +4,8 @@ import ( ...@@ -4,8 +4,8 @@ import (
"bytes" "bytes"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
mafmt "github.com/multiformats/go-multiaddr-fmt"
manet "github.com/multiformats/go-multiaddr-net" manet "github.com/multiformats/go-multiaddr-net"
mafmt "github.com/whyrusleeping/mafmt"
) )
func isFDCostlyTransport(a ma.Multiaddr) bool { func isFDCostlyTransport(a ma.Multiaddr) bool {
......
This diff is collapsed.
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
proto "github.com/gogo/protobuf/proto" proto "github.com/gogo/protobuf/proto"
io "io" io "io"
math "math" math "math"
math_bits "math/bits"
) )
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
...@@ -20,7 +21,7 @@ var _ = math.Inf ...@@ -20,7 +21,7 @@ var _ = math.Inf
// is compatible with the proto package it is being compiled against. // is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the // A compilation error at this line likely means your copy of the
// proto package needs to be updated. // proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// AddrBookRecord represents a record for a peer in the address book. // AddrBookRecord represents a record for a peer in the address book.
type AddrBookRecord struct { type AddrBookRecord struct {
...@@ -44,7 +45,7 @@ func (m *AddrBookRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, erro ...@@ -44,7 +45,7 @@ func (m *AddrBookRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, erro
return xxx_messageInfo_AddrBookRecord.Marshal(b, m, deterministic) return xxx_messageInfo_AddrBookRecord.Marshal(b, m, deterministic)
} else { } else {
b = b[:cap(b)] b = b[:cap(b)]
n, err := m.MarshalTo(b) n, err := m.MarshalToSizedBuffer(b)
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -93,7 +94,7 @@ func (m *AddrBookRecord_AddrEntry) XXX_Marshal(b []byte, deterministic bool) ([] ...@@ -93,7 +94,7 @@ func (m *AddrBookRecord_AddrEntry) XXX_Marshal(b []byte, deterministic bool) ([]
return xxx_messageInfo_AddrBookRecord_AddrEntry.Marshal(b, m, deterministic) return xxx_messageInfo_AddrBookRecord_AddrEntry.Marshal(b, m, deterministic)
} else { } else {
b = b[:cap(b)] b = b[:cap(b)]
n, err := m.MarshalTo(b) n, err := m.MarshalToSizedBuffer(b)
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -156,7 +157,7 @@ var fileDescriptor_f96873690e08a98f = []byte{ ...@@ -156,7 +157,7 @@ var fileDescriptor_f96873690e08a98f = []byte{
func (m *AddrBookRecord) Marshal() (dAtA []byte, err error) { func (m *AddrBookRecord) Marshal() (dAtA []byte, err error) {
size := m.Size() size := m.Size()
dAtA = make([]byte, size) dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA) n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -164,39 +165,48 @@ func (m *AddrBookRecord) Marshal() (dAtA []byte, err error) { ...@@ -164,39 +165,48 @@ func (m *AddrBookRecord) Marshal() (dAtA []byte, err error) {
} }
func (m *AddrBookRecord) MarshalTo(dAtA []byte) (int, error) { func (m *AddrBookRecord) MarshalTo(dAtA []byte) (int, error) {
var i int size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *AddrBookRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i _ = i
var l int var l int
_ = l _ = l
if m.Id != nil {
dAtA[i] = 0xa
i++
i = encodeVarintPstore(dAtA, i, uint64(m.Id.Size()))
n1, err := m.Id.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n1
}
if len(m.Addrs) > 0 { if len(m.Addrs) > 0 {
for _, msg := range m.Addrs { for iNdEx := len(m.Addrs) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.Addrs[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintPstore(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x12 dAtA[i] = 0x12
i++ }
i = encodeVarintPstore(dAtA, i, uint64(msg.Size())) }
n, err := msg.MarshalTo(dAtA[i:]) if m.Id != nil {
if err != nil { {
size := m.Id.Size()
i -= size
if _, err := m.Id.MarshalTo(dAtA[i:]); err != nil {
return 0, err return 0, err
} }
i += n i = encodeVarintPstore(dAtA, i, uint64(size))
} }
i--
dAtA[i] = 0xa
} }
return i, nil return len(dAtA) - i, nil
} }
func (m *AddrBookRecord_AddrEntry) Marshal() (dAtA []byte, err error) { func (m *AddrBookRecord_AddrEntry) Marshal() (dAtA []byte, err error) {
size := m.Size() size := m.Size()
dAtA = make([]byte, size) dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA) n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -204,46 +214,55 @@ func (m *AddrBookRecord_AddrEntry) Marshal() (dAtA []byte, err error) { ...@@ -204,46 +214,55 @@ func (m *AddrBookRecord_AddrEntry) Marshal() (dAtA []byte, err error) {
} }
func (m *AddrBookRecord_AddrEntry) MarshalTo(dAtA []byte) (int, error) { func (m *AddrBookRecord_AddrEntry) MarshalTo(dAtA []byte) (int, error) {
var i int size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *AddrBookRecord_AddrEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i _ = i
var l int var l int
_ = l _ = l
if m.Addr != nil { if m.Ttl != 0 {
dAtA[i] = 0xa i = encodeVarintPstore(dAtA, i, uint64(m.Ttl))
i++ i--
i = encodeVarintPstore(dAtA, i, uint64(m.Addr.Size())) dAtA[i] = 0x18
n2, err := m.Addr.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n2
} }
if m.Expiry != 0 { if m.Expiry != 0 {
dAtA[i] = 0x10
i++
i = encodeVarintPstore(dAtA, i, uint64(m.Expiry)) i = encodeVarintPstore(dAtA, i, uint64(m.Expiry))
i--
dAtA[i] = 0x10
} }
if m.Ttl != 0 { if m.Addr != nil {
dAtA[i] = 0x18 {
i++ size := m.Addr.Size()
i = encodeVarintPstore(dAtA, i, uint64(m.Ttl)) i -= size
if _, err := m.Addr.MarshalTo(dAtA[i:]); err != nil {
return 0, err
}
i = encodeVarintPstore(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0xa
} }
return i, nil return len(dAtA) - i, nil
} }
func encodeVarintPstore(dAtA []byte, offset int, v uint64) int { func encodeVarintPstore(dAtA []byte, offset int, v uint64) int {
offset -= sovPstore(v)
base := offset
for v >= 1<<7 { for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80) dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7 v >>= 7
offset++ offset++
} }
dAtA[offset] = uint8(v) dAtA[offset] = uint8(v)
return offset + 1 return base
} }
func NewPopulatedAddrBookRecord(r randyPstore, easy bool) *AddrBookRecord { func NewPopulatedAddrBookRecord(r randyPstore, easy bool) *AddrBookRecord {
this := &AddrBookRecord{} this := &AddrBookRecord{}
this.Id = NewPopulatedProtoPeerID(r) this.Id = NewPopulatedProtoPeerID(r)
if r.Intn(10) != 0 { if r.Intn(5) != 0 {
v1 := r.Intn(5) v1 := r.Intn(5)
this.Addrs = make([]*AddrBookRecord_AddrEntry, v1) this.Addrs = make([]*AddrBookRecord_AddrEntry, v1)
for i := 0; i < v1; i++ { for i := 0; i < v1; i++ {
...@@ -382,14 +401,7 @@ func (m *AddrBookRecord_AddrEntry) Size() (n int) { ...@@ -382,14 +401,7 @@ func (m *AddrBookRecord_AddrEntry) Size() (n int) {
} }
func sovPstore(x uint64) (n int) { func sovPstore(x uint64) (n int) {
for { return (math_bits.Len64(x|1) + 6) / 7
n++
x >>= 7
if x == 0 {
break
}
}
return n
} }
func sozPstore(x uint64) (n int) { func sozPstore(x uint64) (n int) {
return sovPstore(uint64((x << 1) ^ uint64((int64(x) >> 63)))) return sovPstore(uint64((x << 1) ^ uint64((int64(x) >> 63))))
...@@ -645,6 +657,7 @@ func (m *AddrBookRecord_AddrEntry) Unmarshal(dAtA []byte) error { ...@@ -645,6 +657,7 @@ func (m *AddrBookRecord_AddrEntry) Unmarshal(dAtA []byte) error {
func skipPstore(dAtA []byte) (n int, err error) { func skipPstore(dAtA []byte) (n int, err error) {
l := len(dAtA) l := len(dAtA)
iNdEx := 0 iNdEx := 0
depth := 0
for iNdEx < l { for iNdEx < l {
var wire uint64 var wire uint64
for shift := uint(0); ; shift += 7 { for shift := uint(0); ; shift += 7 {
...@@ -676,10 +689,8 @@ func skipPstore(dAtA []byte) (n int, err error) { ...@@ -676,10 +689,8 @@ func skipPstore(dAtA []byte) (n int, err error) {
break break
} }
} }
return iNdEx, nil
case 1: case 1:
iNdEx += 8 iNdEx += 8
return iNdEx, nil
case 2: case 2:
var length int var length int
for shift := uint(0); ; shift += 7 { for shift := uint(0); ; shift += 7 {
...@@ -700,55 +711,30 @@ func skipPstore(dAtA []byte) (n int, err error) { ...@@ -700,55 +711,30 @@ func skipPstore(dAtA []byte) (n int, err error) {
return 0, ErrInvalidLengthPstore return 0, ErrInvalidLengthPstore
} }
iNdEx += length iNdEx += length
if iNdEx < 0 {
return 0, ErrInvalidLengthPstore
}
return iNdEx, nil
case 3: case 3:
for { depth++
var innerWire uint64
var start int = iNdEx
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowPstore
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
innerWire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
innerWireType := int(innerWire & 0x7)
if innerWireType == 4 {
break
}
next, err := skipPstore(dAtA[start:])
if err != nil {
return 0, err
}
iNdEx = start + next
if iNdEx < 0 {
return 0, ErrInvalidLengthPstore
}
}
return iNdEx, nil
case 4: case 4:
return iNdEx, nil if depth == 0 {
return 0, ErrUnexpectedEndOfGroupPstore
}
depth--
case 5: case 5:
iNdEx += 4 iNdEx += 4
return iNdEx, nil
default: default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType) return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
} }
if iNdEx < 0 {
return 0, ErrInvalidLengthPstore
}
if depth == 0 {
return iNdEx, nil
}
} }
panic("unreachable") return 0, io.ErrUnexpectedEOF
} }
var ( var (
ErrInvalidLengthPstore = fmt.Errorf("proto: negative length found during unmarshaling") ErrInvalidLengthPstore = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowPstore = fmt.Errorf("proto: integer overflow") ErrIntOverflowPstore = fmt.Errorf("proto: integer overflow")
ErrUnexpectedEndOfGroupPstore = fmt.Errorf("proto: unexpected end of group")
) )
...@@ -41,9 +41,9 @@ func testKeybookPrivKey(kb pstore.KeyBook) func(t *testing.T) { ...@@ -41,9 +41,9 @@ func testKeybookPrivKey(kb pstore.KeyBook) func(t *testing.T) {
t.Error("expected peers to be empty on init") t.Error("expected peers to be empty on init")
} }
priv, _, err := pt.RandTestKeyPair(ic.RSA, 512) priv, _, err := pt.RandTestKeyPair(ic.RSA, 2048)
if err != nil { if err != nil {
t.Error(err) t.Fatal(err)
} }
id, err := peer.IDFromPrivateKey(priv) id, err := peer.IDFromPrivateKey(priv)
...@@ -76,14 +76,14 @@ func testKeyBookPubKey(kb pstore.KeyBook) func(t *testing.T) { ...@@ -76,14 +76,14 @@ func testKeyBookPubKey(kb pstore.KeyBook) func(t *testing.T) {
t.Error("expected peers to be empty on init") t.Error("expected peers to be empty on init")
} }
_, pub, err := pt.RandTestKeyPair(ic.RSA, 512) _, pub, err := pt.RandTestKeyPair(ic.RSA, 2048)
if err != nil { if err != nil {
t.Error(err) t.Fatal(err)
} }
id, err := peer.IDFromPublicKey(pub) id, err := peer.IDFromPublicKey(pub)
if err != nil { if err != nil {
t.Error(err) t.Fatal(err)
} }
if res := kb.PubKey(id); res != nil { if res := kb.PubKey(id); res != nil {
...@@ -114,13 +114,22 @@ func testKeyBookPeers(kb pstore.KeyBook) func(t *testing.T) { ...@@ -114,13 +114,22 @@ func testKeyBookPeers(kb pstore.KeyBook) func(t *testing.T) {
var peers peer.IDSlice var peers peer.IDSlice
for i := 0; i < 10; i++ { for i := 0; i < 10; i++ {
// Add a public key. // Add a public key.
_, pub, _ := pt.RandTestKeyPair(ic.RSA, 512) _, pub, err := pt.RandTestKeyPair(ic.RSA, 2048)
p1, _ := peer.IDFromPublicKey(pub) if err != nil {
t.Fatal(err)
}
p1, err := peer.IDFromPublicKey(pub)
if err != nil {
t.Fatal(err)
}
kb.AddPubKey(p1, pub) kb.AddPubKey(p1, pub)
// Add a private key. // Add a private key.
priv, _, _ := pt.RandTestKeyPair(ic.RSA, 512) priv, _, err := pt.RandTestKeyPair(ic.RSA, 2048)
p2, _ := peer.IDFromPrivateKey(priv) p2, err := peer.IDFromPrivateKey(priv)
if err != nil {
t.Fatal(err)
}
kb.AddPrivKey(p2, priv) kb.AddPrivKey(p2, priv)
peers = append(peers, []peer.ID{p1, p2}...) peers = append(peers, []peer.ID{p1, p2}...)
...@@ -192,14 +201,14 @@ func BenchmarkKeyBook(b *testing.B, factory KeyBookFactory) { ...@@ -192,14 +201,14 @@ func BenchmarkKeyBook(b *testing.B, factory KeyBookFactory) {
func benchmarkPubKey(kb pstore.KeyBook) func(*testing.B) { func benchmarkPubKey(kb pstore.KeyBook) func(*testing.B) {
return func(b *testing.B) { return func(b *testing.B) {
_, pub, err := pt.RandTestKeyPair(ic.RSA, 512) _, pub, err := pt.RandTestKeyPair(ic.RSA, 2048)
if err != nil { if err != nil {
b.Error(err) b.Fatal(err)
} }
id, err := peer.IDFromPublicKey(pub) id, err := peer.IDFromPublicKey(pub)
if err != nil { if err != nil {
b.Error(err) b.Fatal(err)
} }
err = kb.AddPubKey(id, pub) err = kb.AddPubKey(id, pub)
...@@ -216,14 +225,14 @@ func benchmarkPubKey(kb pstore.KeyBook) func(*testing.B) { ...@@ -216,14 +225,14 @@ func benchmarkPubKey(kb pstore.KeyBook) func(*testing.B) {
func benchmarkAddPubKey(kb pstore.KeyBook) func(*testing.B) { func benchmarkAddPubKey(kb pstore.KeyBook) func(*testing.B) {
return func(b *testing.B) { return func(b *testing.B) {
_, pub, err := pt.RandTestKeyPair(ic.RSA, 512) _, pub, err := pt.RandTestKeyPair(ic.RSA, 2048)
if err != nil { if err != nil {
b.Error(err) b.Fatal(err)
} }
id, err := peer.IDFromPublicKey(pub) id, err := peer.IDFromPublicKey(pub)
if err != nil { if err != nil {
b.Error(err) b.Fatal(err)
} }
b.ResetTimer() b.ResetTimer()
...@@ -235,14 +244,14 @@ func benchmarkAddPubKey(kb pstore.KeyBook) func(*testing.B) { ...@@ -235,14 +244,14 @@ func benchmarkAddPubKey(kb pstore.KeyBook) func(*testing.B) {
func benchmarkPrivKey(kb pstore.KeyBook) func(*testing.B) { func benchmarkPrivKey(kb pstore.KeyBook) func(*testing.B) {
return func(b *testing.B) { return func(b *testing.B) {
priv, _, err := pt.RandTestKeyPair(ic.RSA, 512) priv, _, err := pt.RandTestKeyPair(ic.RSA, 2048)
if err != nil { if err != nil {
b.Error(err) b.Fatal(err)
} }
id, err := peer.IDFromPrivateKey(priv) id, err := peer.IDFromPrivateKey(priv)
if err != nil { if err != nil {
b.Error(err) b.Fatal(err)
} }
err = kb.AddPrivKey(id, priv) err = kb.AddPrivKey(id, priv)
...@@ -259,14 +268,14 @@ func benchmarkPrivKey(kb pstore.KeyBook) func(*testing.B) { ...@@ -259,14 +268,14 @@ func benchmarkPrivKey(kb pstore.KeyBook) func(*testing.B) {
func benchmarkAddPrivKey(kb pstore.KeyBook) func(*testing.B) { func benchmarkAddPrivKey(kb pstore.KeyBook) func(*testing.B) {
return func(b *testing.B) { return func(b *testing.B) {
priv, _, err := pt.RandTestKeyPair(ic.RSA, 512) priv, _, err := pt.RandTestKeyPair(ic.RSA, 2048)
if err != nil { if err != nil {
b.Error(err) b.Fatal(err)
} }
id, err := peer.IDFromPrivateKey(priv) id, err := peer.IDFromPrivateKey(priv)
if err != nil { if err != nil {
b.Error(err) b.Fatal(err)
} }
b.ResetTimer() b.ResetTimer()
...@@ -279,14 +288,14 @@ func benchmarkAddPrivKey(kb pstore.KeyBook) func(*testing.B) { ...@@ -279,14 +288,14 @@ func benchmarkAddPrivKey(kb pstore.KeyBook) func(*testing.B) {
func benchmarkPeersWithKeys(kb pstore.KeyBook) func(*testing.B) { func benchmarkPeersWithKeys(kb pstore.KeyBook) func(*testing.B) {
return func(b *testing.B) { return func(b *testing.B) {
for i := 0; i < 10; i++ { for i := 0; i < 10; i++ {
priv, pub, err := pt.RandTestKeyPair(ic.RSA, 512) priv, pub, err := pt.RandTestKeyPair(ic.RSA, 2048)
if err != nil { if err != nil {
b.Error(err) b.Fatal(err)
} }
id, err := peer.IDFromPublicKey(pub) id, err := peer.IDFromPublicKey(pub)
if err != nil { if err != nil {
b.Error(err) b.Fatal(err)
} }
err = kb.AddPubKey(id, pub) err = kb.AddPubKey(id, pub)
......
...@@ -287,8 +287,14 @@ func testBasicPeerstore(ps pstore.Peerstore) func(t *testing.T) { ...@@ -287,8 +287,14 @@ func testBasicPeerstore(ps pstore.Peerstore) func(t *testing.T) {
addrs := getAddrs(t, 10) addrs := getAddrs(t, 10)
for _, a := range addrs { for _, a := range addrs {
priv, _, _ := crypto.GenerateKeyPair(crypto.RSA, 512) priv, _, err := crypto.GenerateKeyPair(crypto.RSA, 2048)
p, _ := peer.IDFromPrivateKey(priv) if err != nil {
t.Fatal(err)
}
p, err := peer.IDFromPrivateKey(priv)
if err != nil {
t.Fatal(err)
}
pids = append(pids, p) pids = append(pids, p)
ps.AddAddr(p, a, pstore.PermanentAddrTTL) ps.AddAddr(p, a, pstore.PermanentAddrTTL)
} }
...@@ -309,8 +315,14 @@ func testMetadata(ps pstore.Peerstore) func(t *testing.T) { ...@@ -309,8 +315,14 @@ func testMetadata(ps pstore.Peerstore) func(t *testing.T) {
return func(t *testing.T) { return func(t *testing.T) {
pids := make([]peer.ID, 10) pids := make([]peer.ID, 10)
for i := range pids { for i := range pids {
priv, _, _ := crypto.GenerateKeyPair(crypto.RSA, 512) priv, _, err := crypto.GenerateKeyPair(crypto.RSA, 2048)
p, _ := peer.IDFromPrivateKey(priv) if err != nil {
t.Fatal(err)
}
p, err := peer.IDFromPrivateKey(priv)
if err != nil {
t.Fatal(err)
}
pids[i] = p pids[i] = p
} }
for _, p := range pids { for _, p := range pids {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment