From d18509152a6606ab0660ed625400343d60064b3c Mon Sep 17 00:00:00 2001 From: Ganesha Upadhyaya Date: Tue, 17 Oct 2023 19:05:12 -0500 Subject: [PATCH] fix links and references --- p2p/p2p.md | 14 ++++++++++++-- specs/src/README.md | 26 +++++++++++++------------- store/store.md | 4 ++++ sync/sync.md | 4 ++++ 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/p2p/p2p.md b/p2p/p2p.md index ca4aa3e9..c84de748 100644 --- a/p2p/p2p.md +++ b/p2p/p2p.md @@ -38,7 +38,7 @@ An exchange is a combination of: ### Exchange Client -Exchange defines a client for requesting headers from the p2p network. An exchange client is initialized using self [host.Host][host], list of peers in the form of slice [peer.IDSlice][peer], and [connection gater][gater] for blocking and allowing nodes. Optional parameters like `ChainID` and `NetworkID` can also be passed. The exchange client also maintains a list of trusted peers via a peer tracker. +Exchange defines a client for requesting headers from the p2p network. An exchange client is initialized using self [host.Host][host], a list of peers in the form of slice [peer.IDSlice][peer], and a [connection gater][gater] for blocking and allowing nodes. Optional parameters like `ChainID` and `NetworkID` can also be passed. The exchange client also maintains a list of trusted peers via a peer tracker. #### Peer Tracker @@ -86,7 +86,7 @@ type Head[H Header[H]] interface { } ``` -`Head()` method requests the latest header from trusted peers. The `Head()` requests utilizes 90% of the set deadline (in the form of context deadline) for requests and remaining for determining the best head from gathered responses. The `Head()` call also allows passing an option `TrustedHead` which allows the caller to specify a trusted header against which the untrusted headers received from a list of tracked peers (limited to `maxUntrustedHeadRequests` of 4) can be verified against, in the absence of trusted peers. Upon receiving headers from peers (either trusted or tracked), the best head is determined as the head: +`Head()` method requests the latest header from trusted peers. The `Head()` requests utilizes 90% of the set deadline (in the form of context deadline) for requests and remaining for determining the best head from gathered responses. The `Head()` call also allows passing an optional `TrustedHead` which allows the caller to specify a trusted header against which the untrusted headers received from a list of tracked peers (limited to `maxUntrustedHeadRequests` of 4) can be verified against, in the absence of trusted peers. Upon receiving headers from peers (either trusted or tracked), the best head is determined as the head: * with max height among the received * which is received from at least `minHeadResponses` of 2 peers @@ -205,6 +205,16 @@ Currently only following metrics are collected: # References +[1] [libp2p][libp2p] + +[2] [pubsub][pubsub] + +[3] [host.Host][host] + +[4] [peer.IDSlice][peer] + +[5] [connection gater][gater] + [libp2p]: https://github.com/libp2p/go-libp2p [pubsub]: https://github.com/libp2p/go-libp2p-pubsub [host]: https://github.com/libp2p/go-libp2p/core/host diff --git a/specs/src/README.md b/specs/src/README.md index 26dd5d7c..1585cf2b 100644 --- a/specs/src/README.md +++ b/specs/src/README.md @@ -6,38 +6,38 @@ go-header is a library for syncing blockchain data such as block headers over th |Component|Description| |---|---| -|[p2p.Subscriber](specs/p2p.md)|listens for new headers from the p2p network| -|[p2p.ExchangeServer](specs/p2p.md)|serve header requests from other nodes in the p2p network| -|[p2p.Exchange](specs/p2p.md)|client that requests headers from other nodes in the p2p network| -|[store.Store](specs/store.md)|storing headers and making them available for access by other services such as exchange and syncer| -|[sync.Syncer](specs/sync.md)|syncing of historical and new headers from the p2p network| +|[p2p.Subscriber](../../p2p/p2p.md)|listens for new headers from the p2p network| +|[p2p.ExchangeServer](../../p2p/p2p.md)|serve header requests from other nodes in the p2p network| +|[p2p.Exchange](../../p2p/p2p.md)|client that requests headers from other nodes in the p2p network| +|[store.Store](../../store/store.md)|storing headers and making them available for access by other services such as exchange and syncer| +|[sync.Syncer](../../sync/sync.md)|syncing of historical and new headers from the p2p network| -The go-header library makes it easy to consume by other projects by defining a clear interface (as described below). An example consumer is defined in [headertest/dummy_header.go][dummy header] +The go-header library makes it easy to be used by other projects by defining a clear interface (as described below). An example usage is defined in [headertest/dummy_header.go][dummy header] ``` type Header[H any] interface { // New creates new instance of a header. New() H - // IsZero reports whether Header is a zero value of it's concrete type. + // IsZero reports whether Header is a zero value of it's concrete type. IsZero() bool - // ChainID returns identifier of the chain. + // ChainID returns identifier of the chain. ChainID() string - // Hash returns hash of a header. + // Hash returns hash of a header. Hash() Hash - // Height returns the height of a header. + // Height returns the height of a header. Height() uint64 - // LastHeader returns the hash of last header before this header (aka. previous header hash). + // LastHeader returns the hash of last header before this header (aka. previous header hash). LastHeader() Hash - // Time returns time when header was created. + // Time returns time when header was created. Time() time.Time - // Verify validates given untrusted Header against trusted Header. + // Verify validates given untrusted Header against trusted Header. Verify(H) error // Validate performs stateless validation to check for missed/incorrect fields. diff --git a/store/store.md b/store/store.md index b2169362..bb1a8dc9 100644 --- a/store/store.md +++ b/store/store.md @@ -102,5 +102,9 @@ The store runs a flush loop during the start which performs writing task to the # References +[1] [datastore][go-datastore] + +[2] [lru.ARCCache][lru.ARCCache] + [go-datastore]: https://github.com/ipfs/go-datastore [lru.ARCCache]: https://github.com/hashicorp/golang-lru diff --git a/sync/sync.md b/sync/sync.md index 7b029293..05ead750 100644 --- a/sync/sync.md +++ b/sync/sync.md @@ -87,5 +87,9 @@ When a new network head is received which gets validated and set as subjective h # References +[1] [Exchange][exchange] + +[2] [Subscriber][subscriber] + [exchange]: https://github.com/celestiaorg/go-header/blob/main/p2p/exchange.go [subscriber]: https://github.com/celestiaorg/go-header/blob/main/p2p/subscriber.go