Skip to content

Commit

Permalink
fix links and references
Browse files Browse the repository at this point in the history
  • Loading branch information
Ganesha Upadhyaya authored and Ganesha Upadhyaya committed Oct 20, 2023
1 parent a889ccc commit f7995c3
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
14 changes: 12 additions & 2 deletions p2p/p2p.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
26 changes: 13 additions & 13 deletions specs/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions store/store.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions sync/sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f7995c3

Please sign in to comment.