Ecosyste.ms: Repos

An open API service providing repository metadata for many open source software ecosystems.

Package Usage: go: github.com/decred/dcrd/peer/v3

Package peer provides a common base for creating and managing Decred network peers. This package builds upon the wire package, which provides the fundamental primitives necessary to speak the Decred wire protocol, in order to simplify the process of creating fully functional peers. In essence, it provides a common base for creating concurrent safe fully validating nodes, Simplified Payment Verification (SPV) nodes, proxies, etc. A quick overview of the major features peer provides are as follows: All peer configuration is handled with the Config struct. This allows the caller to specify things such as the user agent name and version, the decred network to use, which services it supports, and callbacks to invoke when decred messages are received. See the documentation for each field of the Config struct for more details. A peer can either be inbound or outbound. The caller is responsible for establishing the connection to remote peers and listening for incoming peers. This provides high flexibility for things such as connecting via proxies, acting as a proxy, creating bridge peers, choosing whether to listen for inbound peers, etc. NewOutboundPeer and NewInboundPeer functions must be followed by calling Connect with a net.Conn instance to the peer. This will start all async I/O goroutines and initiate the protocol negotiation process. Once finished with the peer call Disconnect to disconnect from the peer and clean up all resources. WaitForDisconnect can be used to block until peer disconnection and resource cleanup has completed. In order to do anything useful with a peer, it is necessary to react to decred messages. This is accomplished by creating an instance of the MessageListeners struct with the callbacks to be invoke specified and setting the Listeners field of the Config struct specified when creating a peer to it. For convenience, a callback hook for all of the currently supported decred messages is exposed which receives the peer instance and the concrete message type. In addition, a hook for OnRead is provided so even custom messages types for which this package does not directly provide a hook, as long as they implement the wire.Message interface, can be used. Finally, the OnWrite hook is provided, which in conjunction with OnRead, can be used to track server-wide byte counts. It is often useful to use closures which encapsulate state when specifying the callback handlers. This provides a clean method for accessing that state when callbacks are invoked. The QueueMessage function provides the fundamental means to send messages to the remote peer. As the name implies, this employs a non-blocking queue. A done channel which will be notified when the message is actually sent can optionally be specified. There are certain message types which are better sent using other functions which provide additional functionality. Of special interest are inventory messages. Rather than manually sending MsgInv messages via Queuemessage, the inventory vectors should be queued using the QueueInventory function. It employs batching and trickling along with intelligent known remote peer inventory detection and avoidance through the use of a most-recently used algorithm. In addition to the bare QueueMessage function previously described, the PushAddrMsg, PushGetBlocksMsg, and PushGetHeadersMsg functions are provided as a convenience. While it is of course possible to create and send these messages manually via QueueMessage, these helper functions provided additional useful functionality that is typically desired. For example, the PushAddrMsg function automatically limits the addresses to the maximum number allowed by the message and randomizes the chosen addresses when there are too many. This allows the caller to simply provide a slice of known addresses, such as that returned by the addrmgr package, without having to worry about the details. Finally, the PushGetBlocksMsg and PushGetHeadersMsg functions will construct proper messages using a block locator and ignore back to back duplicate requests. A snapshot of the current peer statistics can be obtained with the StatsSnapshot function. This includes statistics such as the total number of bytes read and written, the remote address, user agent, and negotiated protocol version. This package provides extensive logging capabilities through the UseLogger function which allows a slog.Logger to be specified. For example, logging at the debug level provides summaries of every message sent and received, and logging at the trace level provides full dumps of parsed messages as well as the raw message bytes using a format similar to hexdump -C. This package supports all improvement proposals supported by the wire package. This example demonstrates the basic process for initializing and creating an outbound peer. Peers negotiate by exchanging version and verack messages. For demonstration, a simple handler for version message is attached to the peer.
3 versions
Latest release: about 1 year ago
2 dependent packages

View more package details: https://packages.ecosyste.ms/registries/proxy.golang.org/packages/github.com/decred/dcrd/peer/v3

View more repository details: https://repos.ecosyste.ms/hosts/GitHub/repositories/decred%2Fdcrd

Dependent Repos 12

decred/dcrseeder
Decred Seeder
  • v3.0.0 go.mod
  • v3.0.0 go.sum

Size: 103 KB - Last synced: 24 days ago - Pushed: 24 days ago

decred/dcrlnlpd
  • v3.0.0 go.sum

Size: 185 KB - Last synced: 23 days ago - Pushed: 23 days ago

decred/release
  • v3.0.0 dcrd/go.mod
  • v3.0.0 dcrd/go.sum
  • v3.0.0 dcrlnd/go.sum

Size: 1.01 MB - Last synced: 4 days ago - Pushed: 4 days ago

dcr-bak/dcrd
  • v3.0.0 go.mod

Last synced: 12 months ago

rupesh_virat/decred
  • v3.0.0 go.sum

Last synced: almost 1 year ago

dcr-bak/dcrseeder
  • v3.0.0 go.mod
  • v3.0.0 go.sum

Last synced: over 1 year ago

companyzero/bisonrelay
  • v3.0.0 go.sum

Size: 31.5 MB - Last synced: 3 days ago - Pushed: 3 days ago

decred/dcrtest
  • v3.0.0 dcrdtest/go.mod
  • v3.0.0 dcrdtest/go.sum

Size: 247 KB - Last synced: 25 days ago - Pushed: 26 days ago

matheusd/dcrd Fork of decred/dcrd
Decred daemon in Go (golang).
  • v3.0.0 go.mod

Size: 36.2 MB - Last synced: 26 days ago - Pushed: 27 days ago

decred/dcrlnd Fork of lightningnetwork/lnd
Decred Lightning Network Daemon ⚡️
  • v3.0.0 go.sum

Size: 91.9 MB - Last synced: about 2 months ago - Pushed: about 2 months ago

dajohi/bisonrelay Fork of companyzero/bisonrelay
  • v3.0.0 go.sum

Size: 31.3 MB - Last synced: about 1 month ago - Pushed: about 1 month ago

davecgh/dcrd Fork of decred/dcrd
Decred daemon in Go (golang).
  • v3.0.0 go.mod

Size: 38.6 MB - Last synced: 4 days ago - Pushed: 4 days ago

nikicat/dcrd Fork of decred/dcrd
Decred daemon in Go (golang).
  • v3.0.2 go.mod

Size: 38.3 MB - Last synced: about 1 month ago - Pushed: 10 months ago

dajohi/dcrtest Fork of decred/dcrtest
  • v3.0.0 dcrdtest/go.mod
  • v3.0.0 dcrdtest/go.sum

Size: 247 KB - Last synced: 25 days ago - Pushed: 26 days ago

jholdstock/dcrseeder Fork of decred/dcrseeder
Decred DNS Seeder
  • v3.0.2 go.mod
  • v3.0.2 go.sum

Size: 121 KB - Last synced: about 2 months ago - Pushed: 8 months ago

alexlyp/bisonrelay Fork of companyzero/bisonrelay
  • v3.0.0 go.sum

Size: 31.7 MB - Last synced: 18 days ago - Pushed: 18 days ago

peterzen/dcrd Fork of decred/dcrd
Decred daemon in Go (golang)
  • v3.0.2 go.mod

Size: 38.7 MB - Last synced: 8 months ago - Pushed: 8 months ago

rayman5124/kms
  • v3.0.2 go.mod
  • v3.0.2 go.sum

Size: 163 KB - Last synced: 4 months ago - Pushed: 4 months ago

vinitran/go-stacks-sdk
  • v3.0.2 go.mod
  • v3.0.2 go.sum

Size: 37.1 KB - Last synced: 4 months ago - Pushed: 4 months ago