dcrd/wire
Dave Collins ad02d8f300
multi: Go 1.19 doc comment formatting.
This modifies the entire repository to use the new formatting of doc
comments in the upcoming Go 1.19 release.

The primary motivating factors for this are:

- Builds check that files are formatted per gofmt and that will no
  longer be true as of Go 1.19 without these changes
- Separating all the updates into a single commit ensures these
  documentation only formatting changes do not clutter up diffs that
  actually change code

For the most part, the changes are just the automated changes suggested
by the Go 1.19 version of gofmt, but there are also a few cases where
the comments were reworded a bit to play nicely with the new formatting
requirements.

For example, the new version of gofmt reformats and collapses nested
lists where as the existing version does not.  Thus, instances of nested
lists have been changed to either eliminate them or use mixed markers
which produce expect results.
2022-07-30 04:08:58 -05:00
..
bench_test.go multi: Don't use deprecated ioutil package. 2021-09-01 06:09:37 -05:00
blockheader_test.go wire: formatting fixes - no functional change 2020-07-21 12:33:51 -05:00
blockheader.go multi: Properly capitalize Decred. 2018-03-01 17:41:35 -06:00
common_test.go wire: Introduce InitState messages 2020-09-23 14:01:30 -05:00
common.go wire: Introduce InitState messages 2020-09-23 14:01:30 -05:00
doc.go multi: Go 1.19 doc comment formatting. 2022-07-30 04:08:58 -05:00
error_test.go wire: Introduce InitState messages 2020-09-23 14:01:30 -05:00
error.go multi: add spend pruner. 2021-09-14 16:26:51 -05:00
fakeconn_test.go wire: Consolidate tests into the wire pkg. 2016-11-14 15:29:40 -06:00
fakemessage_test.go multi: define wire error types. 2020-02-14 13:31:58 -06:00
fixedIO_test.go multi: Correct typos. 2019-08-22 10:20:03 -05:00
go.mod multi: Support module graph prune and lazy load. 2022-03-25 07:20:01 -05:00
go.sum wire: Prepare v1.3.0. 2019-10-14 13:19:05 -05:00
invvect_test.go multi: remove whitespace 2019-11-21 18:31:30 -06:00
invvect.go multi: Properly capitalize Decred. 2018-03-01 17:41:35 -06:00
message_test.go wire: Deprecate reject message. 2021-02-08 16:11:19 -06:00
message.go wire: Write message header directly. 2021-11-10 07:27:31 -06:00
msgaddr_test.go wire: Use new errors.Is capabilities in tests. 2020-05-02 23:40:00 -05:00
msgaddr.go multi: define wire error types. 2020-02-14 13:31:58 -06:00
msgblock_test.go wire: formatting fixes - no functional change 2020-07-21 12:33:51 -05:00
msgblock.go multi: define wire error types. 2020-02-14 13:31:58 -06:00
msgcfheaders_test.go wire: Use new errors.Is capabilities in tests. 2020-05-02 23:40:00 -05:00
msgcfheaders.go multi: define wire error types. 2020-02-14 13:31:58 -06:00
msgcfilter_test.go wire: Use new errors.Is capabilities in tests. 2020-05-02 23:40:00 -05:00
msgcfilter.go multi: define wire error types. 2020-02-14 13:31:58 -06:00
msgcfilterv2_test.go wire: Use new errors.Is capabilities in tests. 2020-05-02 23:40:00 -05:00
msgcfilterv2.go multi: define wire error types. 2020-02-14 13:31:58 -06:00
msgcftypes_test.go wire: formatting fixes - no functional change 2020-07-21 12:33:51 -05:00
msgcftypes.go multi: define wire error types. 2020-02-14 13:31:58 -06:00
msgfeefilter_test.go wire: Use new errors.Is capabilities in tests. 2020-05-02 23:40:00 -05:00
msgfeefilter.go multi: define wire error types. 2020-02-14 13:31:58 -06:00
msggetaddr_test.go wire: assert MaxMessagePayload limit in tests. 2019-06-20 12:28:41 -05:00
msggetaddr.go multi: Properly capitalize Decred. 2018-03-01 17:41:35 -06:00
msggetblocks_test.go wire: Use new errors.Is capabilities in tests. 2020-05-02 23:40:00 -05:00
msggetblocks.go multi: define wire error types. 2020-02-14 13:31:58 -06:00
msggetcfheaders_test.go wire: Use new errors.Is capabilities in tests. 2020-05-02 23:40:00 -05:00
msggetcfheaders.go wire: Use new errors.Is capabilities in tests. 2020-05-02 23:40:00 -05:00
msggetcfilter_test.go wire: Use new errors.Is capabilities in tests. 2020-05-02 23:40:00 -05:00
msggetcfilter.go multi: define wire error types. 2020-02-14 13:31:58 -06:00
msggetcfilterv2_test.go wire: Use new errors.Is capabilities in tests. 2020-05-02 23:40:00 -05:00
msggetcfilterv2.go multi: define wire error types. 2020-02-14 13:31:58 -06:00
msggetcftypes_test.go wire: assert MaxMessagePayload limit in tests. 2019-06-20 12:28:41 -05:00
msggetcftypes.go multi: define wire error types. 2020-02-14 13:31:58 -06:00
msggetdata_test.go wire: Use new errors.Is capabilities in tests. 2020-05-02 23:40:00 -05:00
msggetdata.go multi: define wire error types. 2020-02-14 13:31:58 -06:00
msggetheaders_test.go wire: Use new errors.Is capabilities in tests. 2020-05-02 23:40:00 -05:00
msggetheaders.go multi: define wire error types. 2020-02-14 13:31:58 -06:00
msggetinitstate_test.go wire: Introduce InitState messages 2020-09-23 14:01:30 -05:00
msggetinitstate.go wire: Introduce InitState messages 2020-09-23 14:01:30 -05:00
msggetminingstate.go multi: Properly capitalize Decred. 2018-03-01 17:41:35 -06:00
msgheaders_test.go wire: formatting fixes - no functional change 2020-07-21 12:33:51 -05:00
msgheaders.go multi: define wire error types. 2020-02-14 13:31:58 -06:00
msginitstate_test.go wire: Introduce InitState messages 2020-09-23 14:01:30 -05:00
msginitstate.go multi: Address some linter complaints. 2021-07-26 20:51:03 -05:00
msginv_test.go wire: Use new errors.Is capabilities in tests. 2020-05-02 23:40:00 -05:00
msginv.go multi: define wire error types. 2020-02-14 13:31:58 -06:00
msgmempool_test.go wire: assert MaxMessagePayload limit in tests. 2019-06-20 12:28:41 -05:00
msgmempool.go multi: Properly capitalize Decred. 2018-03-01 17:41:35 -06:00
msgminingstate_test.go wire: assert MaxMessagePayload limit in tests. 2019-06-20 12:28:41 -05:00
msgminingstate.go multi: define wire error types. 2020-02-14 13:31:58 -06:00
msgnotfound_test.go wire: Use new errors.Is capabilities in tests. 2020-05-02 23:40:00 -05:00
msgnotfound.go multi: define wire error types. 2020-02-14 13:31:58 -06:00
msgping_test.go wire: use std errors api 2020-05-01 22:56:35 -05:00
msgping.go multi: Properly capitalize Decred. 2018-03-01 17:41:35 -06:00
msgpong_test.go wire: Use new errors.Is capabilities in tests. 2020-05-02 23:40:00 -05:00
msgpong.go multi: Properly capitalize Decred. 2018-03-01 17:41:35 -06:00
msgreject_test.go wire: Deprecate reject message. 2021-02-08 16:11:19 -06:00
msgreject.go wire: Deprecate reject message. 2021-02-08 16:11:19 -06:00
msgsendheaders_test.go wire: assert MaxMessagePayload limit in tests. 2019-06-20 12:28:41 -05:00
msgsendheaders.go multi: define wire error types. 2020-02-14 13:31:58 -06:00
msgtx_test.go wire: use std errors api 2020-05-01 22:56:35 -05:00
msgtx.go multi: Add decentralized treasury support. 2020-09-21 12:15:31 -05:00
msgverack_test.go wire: assert MaxMessagePayload limit in tests. 2019-06-20 12:28:41 -05:00
msgverack.go multi: Properly capitalize Decred. 2018-03-01 17:41:35 -06:00
msgversion_test.go wire: Use new errors.Is capabilities in tests. 2020-05-02 23:40:00 -05:00
msgversion.go wire: Deprecate reject message. 2021-02-08 16:11:19 -06:00
netaddress_test.go wire: use std errors api 2020-05-01 22:56:35 -05:00
netaddress.go multi: Properly capitalize Decred. 2018-03-01 17:41:35 -06:00
protocol_test.go multi: Remove testnet version 2 defs and refs. 2018-08-08 08:10:22 -05:00
protocol.go wire: Deprecate reject message. 2021-02-08 16:11:19 -06:00
README.md multi: Update README.md files for go modules. 2021-01-22 14:39:23 -06:00

wire

Build Status ISC License Doc

Package wire implements the Decred wire protocol. A comprehensive suite of tests with 100% test coverage is provided to ensure proper functionality.

This package has intentionally been designed so it can be used as a standalone package for any projects needing to interface with Decred peers at the wire protocol level.

Installation and Updating

This package is part of the github.com/decred/dcrd/wire module. Use the standard go tooling for working with modules to incorporate it.

Decred Message Overview

The Decred protocol consists of exchanging messages between peers. Each message is preceded by a header which identifies information about it such as which decred 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 Decred 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 Decred messages are provided. For these supported messages, all of the details of marshalling and unmarshalling to and from the wire using Decred encoding are handled so the caller doesn't have to concern themselves with the specifics.

Reading Messages Example

In order to unmarshal Decred 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 Decred peer. Example syntax is:

	// Use the most recent protocol version supported by the package and the
	// main Decred network.
	pver := wire.ProtocolVersion
	dcrnet := wire.MainNet

	// Reads and validates the next Decred message from conn using the
	// protocol version pver and the Decred network dcrnet.  The returns
	// are a wire.Message, a []byte which contains the unmarshalled
	// raw payload, and a possible error.
	msg, rawPayload, err := wire.ReadMessage(conn, pver, dcrnet)
	if err != nil {
		// Log and handle the error
	}

See the package documentation for details on determining the message type.

Writing Messages Example

In order to marshal Decred 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 Decred peer. Example syntax to request addresses from a remote peer is:

	// Use the most recent protocol version supported by the package and the
	// main Decred network.
	pver := wire.ProtocolVersion
	dcrnet := wire.MainNet

	// Create a new getaddr Decred message.
	msg := wire.NewMsgGetAddr()

	// Writes a Decred message msg to conn using the protocol version
	// pver, and the Decred network dcrnet.  The return is a possible
	// error.
	err := wire.WriteMessage(conn, msg, pver, dcrnet)
	if err != nil {
		// Log and handle the error
	}

License

Package wire is licensed under the copyfree ISC License.