Commit Graph

12 Commits

Author SHA1 Message Date
Marten Seemann 4a556c8422
core/peerstore: removed unused provider addr ttl constant (#1848)
Co-authored-by: Dennis Trautwein <git@dtrautwein.eu>
2022-10-31 14:41:35 -07:00
Marten Seemann 4623690009 switch from github.com/libp2p/go-libp2p-core to core 2022-08-17 17:13:02 +03:00
Marten Seemann e467196d68 add RemovePeer method to PeerMetadata, Metrics, ProtoBook and Keybook (#218) 2021-10-24 03:17:52 -07:00
Steven Allen c2821791ba feat: keep addresses for longer (#207)
There's really no reason to expire these after 10 minutes as opposed to
30. Given that our default DHT refresh interval is 10 minutes, setting
this to 30 reduces the chances that we'll "forget" peers.
2021-07-22 14:50:17 -07:00
Steven Allen 79536ece55 feat: add helper functions for working with addr infos (#202)
Specifically, move them _here_ from the peerstore. That way
packages (like the DHT) that currently directly rely on the peerstore,
can just use go-libp2p-core.

Moved from f7f22569f7/peerstore.go (L79-L93)

With some small modifications.
2021-07-21 13:09:49 -07:00
Aarsh Shah 34f061a116 changes as per review 2020-05-11 13:00:05 +05:30
Aarsh Shah 11655978c2 non alloc version 2020-05-08 11:54:39 +05:30
Aarsh Shah 8b984ac519 check if peer supports a protocol without allocation 2020-05-08 11:47:54 +05:30
Vasco Santos 648a5c51b5 docs: uniform comment sentences 2020-03-03 18:16:38 +01:00
Yusef Napora d1feb90b17 Signed envelopes & routing records (#73)
* add SignedEnvelope type

* use struct for SignedEnvelope instead of exposing protobuf directly

* doc comments for envelopes

* tests for SignedEnvelopes

* add helpers to make routing records for Host

* fix doc comment

* go fmt

* add method to peerstore to retrieve signed routing records

* update to match spec changes

* just use nanoseconds

* use proto3  &  rename fields to match spec changes

* use proto3 for routing records

* make envelope fields private & validate on unmarshal

* use buffer pool for envelope signatures

* tests for RoutingState

* go fmt

* rename Equals -> Equal, add some comments

* use test helpers

* get rid of unsigned RoutingState struct, only expose SignedRoutingState

* rm batching SignedRoutingStates accessor in peerstore

the datastore peerstore implementation doesn't support batched reads, so
it's no more efficient to get a bunch of states at once than it
is to call SignedRoutingState multiple times.

* whitespace

* expose struct fields & remove accessors

* use camelCase in protos for consistency

* use multiformats uvarint for length-prefixes

* remove payloadType check when unmarhaling

* rm stray ref to golang/protobuf

* define CertifiedAddrBook to avoid breaking API change

* add events for updated addresses and routing state

* remove SignedRoutingStateFromHost helper

moving this to go-libp2p

* add routing state records, extend peerstore API

* fix: rebuild protos with new gogofaster generator

* filter private addrs from signed routing records

* envelope: use byte slices from pool; adjust interface.

* move envelope to record package.

* move protobuf files; adjust imports everywhere.

* rename RoutingStateRecord -> PeerRecord

also removes embedded reference to Envelope from the record,
as that was confusing.

as a result, the CertifiedAddrBook now accepts/returns
record.SignedEnvelope instead of a specialized type.

* hoist Seq from PeerRecord to SignedEnvelope

* test that PeerRecords can't be signed by wrong key

* commit go.sum

* add Seq field to envelope signature

* fix proto_path in Makefile

* fix import ordering

* comments for PeerRecord proto message

also removes the seq field from PeerMessage proto,
since it was moved to the SignedEnvelope

* use Record type for envelope payloads

* rename SignedEnvelope -> Envelope, unmarshal payload in ConsumeEnvelope

* return buffer to pool before early return

* doc comments

* rename CertifiedAddrBook methods, update comments

* cache unmarshalled Record payload inside Envelope

* doc comments

* store reflect.Type when registering Record

* Revert "return buffer to pool before early return"

8d8da386f26482e06dc21989a6b5ade69f0a46d9

misread this - unsigned will be nil if there's an
error, so it was right the way it was

* use a DefaultRecord for unregistered PayloadTypes

instead of returning an error if we don't have a registered
Record for a given PayloadType, we can have a catch-all
DefaultRecord type that just preserves the original payload
as a []byte

* cleanup DefaultRecord code a bit

- removes unused error return from blankRecordForPayloadType
- just references instead of copying in DefaultRecord.UnmarshalRecord
  I figure this is likely safe, since we'll be unmarshalling from the
  payload of an Envelope, which shouldn't get altered after it's
  created.

* use explicit payloadType in MakeEnvelopeWithRecord

* Revert DefaultRecord commits

ae3bc7bdfb657c232229229706854a56effca80b
a26c845a766b45ceabd87c17c0801d191650f0d4

* doc comments

* move Seq field back to PeerRecord

* make diffs optional in EvtLocalAddressesUpdated

* more envelope tests

* replace MakeEnvelope with record.Seal

also:
- add Domain and Codec fields to Record interface

* fix import

* add interface check

* rename ProcessPeerRecord -> ConsumePeerRecord

also, adds bool `accepted` return value

* rename event field, add doc comment

* peer record protobuf: fix field casing.

* record protobuf: add docs and fix casing.

* cleanup: group imports.

* nit: split test/utils.go => test/{addrs,errors}.go.

Co-authored-by: Raúl Kripalani <raul.kripalani@gmail.com>
2020-02-10 14:53:24 -05:00
Raúl Kripalani ebfb757744 peerstore/protobook: support removing protocols. (#20) 2019-06-19 21:58:27 +01:00
Raúl Kripalani 0a9354a857 Absorb go-libp2p abstractions and core types into this module (#1) 2019-05-22 18:31:11 +01:00