dcrd/wire
Dave Collins 637e6d9e10
multi: Implement block size hard fork demo voting.
This implements a new voting agenda for the testnet and simnet networks
for increasing the maximum block size from 1MiB to 1.25MB.

The following is an overview of the changes:

- Bump the maximum protocol block size limit to 1.25MB
- Bump the protocol version to 4
- Add wire tests for v3 protocol sizes and update tests for latest
- Update all wire values that are defined in terms of the max block size
  to respect the protocol version
- Update the MaxSigOpsPerBlock constant to maintain existing value
  regardless of the raised max protocol block size
- Decouple the maximum tx size from the block size by creating a chain
  parameter for it with the current sizes so it is not a part of the
  hard fork vote
- Add definition for new version 4 stake vote along with agenda to vote
  on block size to the testnet and simnet networks
- Convert the MaximumBlockSize chain parameter to a slice in order to
  hold the different possible sizes
- Adds a new function that returns the maximum block size based upon the
  result of the vote
- Change the existing context-free block size check to enforce the max
  protocol size and introduce a context-specific check which enforces a
  restricted size based upon the network consensus parameters and the
  result of the vote
- Set the max allowed size in generated block templates based upon the
  network params and result of the vote
- Generate version 4 blocks and reject version 3 blocks after a super
  majority has been reached
2017-02-13 13:28:21 -06:00
..
bench_test.go multi: Upstream chainhash abstraction sync 2016-11-16 12:48:40 -06:00
blockheader_test.go multi: Upstream chainhash abstraction sync 2016-11-16 12:48:40 -06:00
blockheader.go multi: Upstream chainhash abstraction sync 2016-11-16 12:48:40 -06:00
common_test.go multi: Upstream chainhash abstraction sync 2016-11-16 12:48:40 -06:00
common.go multi: Upstream chainhash abstraction sync 2016-11-16 12:48:40 -06:00
doc.go blockchain: Rework to use new db interface. 2016-08-18 15:42:18 -04:00
error.go blockchain: Rework to use new db interface. 2016-08-18 15:42:18 -04:00
fakeconn_test.go wire: Consolidate tests into the wire pkg. 2016-11-14 15:29:40 -06:00
fakemessage_test.go wire: Consolidate tests into the wire pkg. 2016-11-14 15:29:40 -06:00
fixedIO_test.go wire: Consolidate tests into the wire pkg. 2016-11-14 15:29:40 -06:00
invvect_test.go multi: Upstream chainhash abstraction sync 2016-11-16 12:48:40 -06:00
invvect.go multi: Upstream chainhash abstraction sync 2016-11-16 12:48:40 -06:00
message_test.go wire: Consolidate tests into the wire pkg. 2016-11-14 15:29:40 -06:00
message.go multi: Upstream chainhash abstraction sync 2016-11-16 12:48:40 -06:00
msgaddr_test.go wire: Consolidate tests into the wire pkg. 2016-11-14 15:29:40 -06:00
msgaddr.go Merge in btcd commit '2adfb3b56acd280e84451e94dd0c06203eef9832' 2016-09-23 18:02:41 -04:00
msgalert_test.go wire: Consolidate tests into the wire pkg. 2016-11-14 15:29:40 -06:00
msgalert.go blockchain: Rework to use new db interface. 2016-08-18 15:42:18 -04:00
msgblock_test.go multi: Implement block size hard fork demo voting. 2017-02-13 13:28:21 -06:00
msgblock.go multi: Implement block size hard fork demo voting. 2017-02-13 13:28:21 -06:00
msgfilteradd_test.go wire: Consolidate tests into the wire pkg. 2016-11-14 15:29:40 -06:00
msgfilteradd.go blockchain: Rework to use new db interface. 2016-08-18 15:42:18 -04:00
msgfilterclear_test.go wire: Consolidate tests into the wire pkg. 2016-11-14 15:29:40 -06:00
msgfilterclear.go blockchain: Rework to use new db interface. 2016-08-18 15:42:18 -04:00
msgfilterload_test.go wire: Consolidate tests into the wire pkg. 2016-11-14 15:29:40 -06:00
msgfilterload.go blockchain: Rework to use new db interface. 2016-08-18 15:42:18 -04:00
msggetaddr_test.go wire: Consolidate tests into the wire pkg. 2016-11-14 15:29:40 -06:00
msggetaddr.go blockchain: Rework to use new db interface. 2016-08-18 15:42:18 -04:00
msggetblocks_test.go multi: Upstream chainhash abstraction sync 2016-11-16 12:48:40 -06:00
msggetblocks.go multi: Upstream chainhash abstraction sync 2016-11-16 12:48:40 -06:00
msggetdata_test.go multi: Upstream chainhash abstraction sync 2016-11-16 12:48:40 -06:00
msggetdata.go Merge in btcd commit '2adfb3b56acd280e84451e94dd0c06203eef9832' 2016-09-23 18:02:41 -04:00
msggetheaders_test.go multi: Upstream chainhash abstraction sync 2016-11-16 12:48:40 -06:00
msggetheaders.go multi: Upstream chainhash abstraction sync 2016-11-16 12:48:40 -06:00
msggetminingstate.go blockchain: Rework to use new db interface. 2016-08-18 15:42:18 -04:00
msgheaders_test.go wire: Consolidate tests into the wire pkg. 2016-11-14 15:29:40 -06:00
msgheaders.go Merge in btcd commit '2adfb3b56acd280e84451e94dd0c06203eef9832' 2016-09-23 18:02:41 -04:00
msginv_test.go multi: Upstream chainhash abstraction sync 2016-11-16 12:48:40 -06:00
msginv.go Merge in btcd commit '2adfb3b56acd280e84451e94dd0c06203eef9832' 2016-09-23 18:02:41 -04:00
msgmempool_test.go wire: Consolidate tests into the wire pkg. 2016-11-14 15:29:40 -06:00
msgmempool.go blockchain: Rework to use new db interface. 2016-08-18 15:42:18 -04:00
msgmerkleblock_test.go multi: Implement block size hard fork demo voting. 2017-02-13 13:28:21 -06:00
msgmerkleblock.go multi: Implement block size hard fork demo voting. 2017-02-13 13:28:21 -06:00
msgminingstate_test.go wire: Consolidate tests into the wire pkg. 2016-11-14 15:29:40 -06:00
msgminingstate.go multi: Upstream chainhash abstraction sync 2016-11-16 12:48:40 -06:00
msgnotfound_test.go multi: Upstream chainhash abstraction sync 2016-11-16 12:48:40 -06:00
msgnotfound.go Merge in btcd commit '2adfb3b56acd280e84451e94dd0c06203eef9832' 2016-09-23 18:02:41 -04:00
msgping_test.go wire: Consolidate tests into the wire pkg. 2016-11-14 15:29:40 -06:00
msgping.go blockchain: Rework to use new db interface. 2016-08-18 15:42:18 -04:00
msgpong_test.go wire: Consolidate tests into the wire pkg. 2016-11-14 15:29:40 -06:00
msgpong.go blockchain: Rework to use new db interface. 2016-08-18 15:42:18 -04:00
msgreject_test.go wire: Consolidate tests into the wire pkg. 2016-11-14 15:29:40 -06:00
msgreject.go multi: Upstream chainhash abstraction sync 2016-11-16 12:48:40 -06:00
msgsendheaders_test.go wire: Consolidate tests into the wire pkg. 2016-11-14 15:29:40 -06:00
msgsendheaders.go wire: Implement sendheaders command 2016-05-27 23:07:05 -05:00
msgtx_test.go multi: Implement block size hard fork demo voting. 2017-02-13 13:28:21 -06:00
msgtx.go multi: Implement block size hard fork demo voting. 2017-02-13 13:28:21 -06:00
msgverack_test.go wire: Consolidate tests into the wire pkg. 2016-11-14 15:29:40 -06:00
msgverack.go blockchain: Rework to use new db interface. 2016-08-18 15:42:18 -04:00
msgversion_test.go wire: Consolidate tests into the wire pkg. 2016-11-14 15:29:40 -06:00
msgversion.go Merge in btcd commit '5de5b7354ca458d6e7677d6b4629214d3f871b59' 2016-09-23 16:24:02 -04:00
netaddress_test.go wire: Consolidate tests into the wire pkg. 2016-11-14 15:29:40 -06:00
netaddress.go Merge in btcd commit '5de5b7354ca458d6e7677d6b4629214d3f871b59' 2016-09-23 16:24:02 -04:00
protocol_test.go wire: Consolidate tests into the wire pkg. 2016-11-14 15:29:40 -06:00
protocol.go multi: Implement block size hard fork demo voting. 2017-02-13 13:28:21 -06:00
README.md docs: Make various README.md files consistent. 2016-05-20 16:00:12 -05:00

wire

[Build Status] (https://travis-ci.org/decred/dcrd) ![ISC License] (http://img.shields.io/badge/license-ISC-blue.svg) [GoDoc] (http://godoc.org/github.com/decred/dcrd/wire)

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

$ go get -u github.com/decred/dcrd/wire

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.