Top 2.9% dependent repos on proxy.golang.org
proxy.golang.org : github.com/hdfchain/hdfd/wire
Package wire implements the Hdfchain wire protocol. For the complete details of the Hdfchain protocol, see the official wiki entry at https://en.bitcoin.it/wiki/Protocol_specification. The following only serves as a quick overview to provide information on how to use the package. At a high level, this package provides support for marshalling and unmarshalling supported Hdfchain messages to and from the wire. This package does not deal with the specifics of message handling such as what to do when a message is received. This provides the caller with a high level of flexibility. The Hdfchain protocol consists of exchanging messages between peers. Each message is preceded by a header which identifies information about it such as which Hdfchain network it is a part of, its type, how big it is, and a checksum to verify validity. All encoding and decoding of message headers is handled by this package. To accomplish this, there is a generic interface for Hdfchain messages named Message which allows messages of any type to be read, written, or passed around through channels, functions, etc. In addition, concrete implementations of most of the currently supported Hdfchain messages are provided. For these supported messages, all of the details of marshalling and unmarshalling to and from the wire using Hdfchain encoding are handled so the caller doesn't have to concern themselves with the specifics. The following provides a quick summary of how the Hdfchain messages are intended to interact with one another. As stated above, these interactions are not directly handled by this package. For more in-depth details about the appropriate interactions, see the official Hdfchain protocol wiki entry at https://en.bitcoin.it/wiki/Protocol_specification. The initial handshake consists of two peers sending each other a version message (MsgVersion) followed by responding with a verack message (MsgVerAck). Both peers use the information in the version message (MsgVersion) to negotiate things such as protocol version and supported services with each other. Once the initial handshake is complete, the following chart indicates message interactions in no particular order. There are several common parameters that arise when using this package to read and write Hdfchain messages. The following sections provide a quick overview of these parameters so the next sections can build on them. The protocol version should be negotiated with the remote peer at a higher level than this package via the version (MsgVersion) message exchange, however, this package provides the wire.ProtocolVersion constant which indicates the latest protocol version this package supports and is typically the value to use for all outbound connections before a potentially lower protocol version is negotiated. The Hdfchain network is a magic number which is used to identify the start of a message and which Hdfchain network the message applies to. This package provides the following constants: As discussed in the Hdfchain message overview section, this package reads and writes Hdfchain messages using a generic interface named Message. In order to determine the actual concrete type of the message, use a type switch or type assertion. An example of a type switch follows: In order to unmarshall Hdfchain messages from the wire, use the ReadMessage function. It accepts any io.Reader, but typically this will be a net.Conn to a remote node running a Hdfchain peer. Example syntax is: In order to marshall Hdfchain messages to the wire, use the WriteMessage function. It accepts any io.Writer, but typically this will be a net.Conn to a remote node running a Hdfchain peer. Example syntax to request addresses from a remote peer is: Errors returned by this package are either the raw errors provided by underlying calls to read/write from streams such as io.EOF, io.ErrUnexpectedEOF, and io.ErrShortWrite, or of type wire.MessageError. This allows the caller to differentiate between general IO errors and malformed messages through type assertions. This package includes spec changes outlined by the following BIPs:
Registry
-
Source
- Documentation
- JSON
purl: pkg:golang/github.com/hdfchain/hdfd/wire
License: ISC
Latest release: over 4 years ago
First release: over 4 years ago
Namespace: github.com/hdfchain/hdfd
Dependent packages: 28
Dependent repositories: 3
Stars: 1 on GitHub
Forks: 0 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 23 days ago