Skip to content

Commit

Permalink
Rebrand comment and doc.
Browse files Browse the repository at this point in the history
  • Loading branch information
laudney committed Nov 26, 2014
1 parent 41ec9da commit 9a9b557
Show file tree
Hide file tree
Showing 35 changed files with 282 additions and 282 deletions.
84 changes: 42 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,76 +1,76 @@
btcwire
rddwire
=======

[![Build Status](https://travis-ci.org/conformal/btcwire.png?branch=master)]
(https://travis-ci.org/conformal/btcwire) [![Coverage Status]
(https://coveralls.io/repos/conformal/btcwire/badge.png?branch=master)]
(https://coveralls.io/r/conformal/btcwire?branch=master)
[![Build Status](https://travis-ci.org/reddcoin-project/rddwire.png?branch=master)]
(https://travis-ci.org/reddcoin-project/rddwire) [![Coverage Status]
(https://coveralls.io/repos/reddcoin-project/rddwire/badge.png?branch=master)]
(https://coveralls.io/r/reddcoin-project/rddwire?branch=master)

Package btcwire implements the bitcoin wire protocol. A comprehensive suite of
Package rddwire implements the Reddcoin wire protocol. A comprehensive suite of
tests with 100% test coverage is provided to ensure proper functionality.
Package btcwire is licensed under the liberal ISC license.
Package rddwire is licensed under the liberal ISC license.

There is an associated blog post about the release of this package
[here](https://blog.conformal.com/btcwire-the-bitcoin-wire-protocol-package-from-btcd/).

This package is one of the core packages from btcd, an alternative full-node
implementation of bitcoin which is under active development by Conformal.
Although it was primarily written for btcd, this package has intentionally been
This package is one of the core packages from rddd, an alternative full-node
implementation of Reddcoin which is under active development by Conformal.
Although it was primarily written for rddd, this package has intentionally been
designed so it can be used as a standalone package for any projects needing to
interface with bitcoin peers at the wire protocol level.
interface with Reddcoin peers at the wire protocol level.

## Documentation

[![GoDoc](https://godoc.org/github.com/conformal/btcwire?status.png)]
(http://godoc.org/github.com/conformal/btcwire)
[![GoDoc](https://godoc.org/github.com/reddcoin-project/rddwire?status.png)]
(http://godoc.org/github.com/reddcoin-project/rddwire)

Full `go doc` style documentation for the project can be viewed online without
installing this package by using the GoDoc site here:
http://godoc.org/github.com/conformal/btcwire
http://godoc.org/github.com/reddcoin-project/rddwire

You can also view the documentation locally once the package is installed with
the `godoc` tool by running `godoc -http=":6060"` and pointing your browser to
http://localhost:6060/pkg/github.com/conformal/btcwire
http://localhost:6060/pkg/github.com/reddcoin-project/rddwire

## Installation

```bash
$ go get github.com/conformal/btcwire
$ go get github.com/reddcoin-project/rddwire
```

## Bitcoin Message Overview
## Reddcoin Message Overview

The bitcoin protocol consists of exchanging messages between peers. Each message
The Reddcoin protocol consists of exchanging messages between peers. Each message
is preceded by a header which identifies information about it such as which
bitcoin network it is a part of, its type, how big it is, and a checksum to
Reddcoin 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 bitcoin messages named
To accomplish this, there is a generic interface for Reddcoin 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 bitcoin messages are provided. For these
of most of the currently supported Reddcoin messages are provided. For these
supported messages, all of the details of marshalling and unmarshalling to and
from the wire using bitcoin encoding are handled so the caller doesn't have to
from the wire using Reddcoin encoding are handled so the caller doesn't have to
concern themselves with the specifics.

## Reading Messages Example

In order to unmarshal bitcoin messages from the wire, use the `ReadMessage`
In order to unmarshal Reddcoin 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 bitcoin peer. Example syntax is:
to a remote node running a Reddcoin peer. Example syntax is:

```Go
// Use the most recent protocol version supported by the package and the
// main bitcoin network.
pver := btcwire.ProtocolVersion
btcnet := btcwire.MainNet
// main Reddcoin network.
pver := rddwire.ProtocolVersion
rddnet := rddwire.MainNet

// Reads and validates the next bitcoin message from conn using the
// protocol version pver and the bitcoin network btcnet. The returns
// are a btcwire.Message, a []byte which contains the unmarshalled
// Reads and validates the next Reddcoin message from conn using the
// protocol version pver and the Reddcoin network rddnet. The returns
// are a rddwire.Message, a []byte which contains the unmarshalled
// raw payload, and a possible error.
msg, rawPayload, err := btcwire.ReadMessage(conn, pver, btcnet)
msg, rawPayload, err := rddwire.ReadMessage(conn, pver, rddnet)
if err != nil {
// Log and handle the error
}
Expand All @@ -80,24 +80,24 @@ See the package documentation for details on determining the message type.

## Writing Messages Example

In order to marshal bitcoin messages to the wire, use the `WriteMessage`
In order to marshal Reddcoin 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 bitcoin peer. Example syntax to request addresses
to a remote node running a Reddcoin peer. Example syntax to request addresses
from a remote peer is:

```Go
// Use the most recent protocol version supported by the package and the
// main bitcoin network.
pver := btcwire.ProtocolVersion
btcnet := btcwire.MainNet
// main Reddcoin network.
pver := rddwire.ProtocolVersion
rddnet := rddwire.MainNet

// Create a new getaddr bitcoin message.
msg := btcwire.NewMsgGetAddr()
// Create a new getaddr Reddcoin message.
msg := rddwire.NewMsgGetAddr()

// Writes a bitcoin message msg to conn using the protocol version
// pver, and the bitcoin network btcnet. The return is a possible
// Writes a Reddcoin message msg to conn using the protocol version
// pver, and the Reddcoin network rddnet. The return is a possible
// error.
err := btcwire.WriteMessage(conn, msg, pver, btcnet)
err := rddwire.WriteMessage(conn, msg, pver, rddnet)
if err != nil {
// Log and handle the error
}
Expand Down Expand Up @@ -125,5 +125,5 @@ signature perform the following:

## License

Package btcwire is licensed under the [copyfree](http://copyfree.org) ISC
Package rddwire is licensed under the [copyfree](http://copyfree.org) ISC
License.
6 changes: 3 additions & 3 deletions blockheader.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const PowBlockVersion = 2
// PrevBlock and MerkleRoot hashes.
const MaxBlockHeaderPayload = 16 + (HashSize * 2)

// BlockHeader defines information about a block and is used in the bitcoin
// BlockHeader defines information about a block and is used in the Reddcoin
// block (MsgBlock) and headers (MsgHeaders) messages.
type BlockHeader struct {
// Version of the block. This is not the same as the protocol version.
Expand Down Expand Up @@ -104,7 +104,7 @@ func NewBlockHeader(prevHash *ShaHash, merkleRootHash *ShaHash, bits uint32,
}
}

// readBlockHeader reads a bitcoin block header from r. See Deserialize for
// readBlockHeader reads a Reddcoin block header from r. See Deserialize for
// decoding block headers stored to disk, such as in a database, as opposed to
// decoding from the wire.
func readBlockHeader(r io.Reader, pver uint32, bh *BlockHeader) error {
Expand All @@ -119,7 +119,7 @@ func readBlockHeader(r io.Reader, pver uint32, bh *BlockHeader) error {
return nil
}

// writeBlockHeader writes a bitcoin block header to w. See Serialize for
// writeBlockHeader writes a Reddcoin block header to w. See Serialize for
// encoding block headers to be stored to disk, such as in a database, as
// opposed to encoding for the wire.
func writeBlockHeader(w io.Writer, pver uint32, bh *BlockHeader) error {
Expand Down
6 changes: 3 additions & 3 deletions common.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ func readElement(r io.Reader, element interface{}) error {
*e = InvType(binary.LittleEndian.Uint32(b))
return nil

case *BitcoinNet:
case *ReddcoinNet:
b := scratch[0:4]
_, err := io.ReadFull(r, b)
if err != nil {
return err
}
*e = BitcoinNet(binary.LittleEndian.Uint32(b))
*e = ReddcoinNet(binary.LittleEndian.Uint32(b))
return nil

case *BloomUpdateType:
Expand Down Expand Up @@ -273,7 +273,7 @@ func writeElement(w io.Writer, element interface{}) error {
}
return nil

case BitcoinNet:
case ReddcoinNet:
b := scratch[0:4]
binary.LittleEndian.PutUint32(b, uint32(e))
_, err := w.Write(b)
Expand Down
4 changes: 2 additions & 2 deletions common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func TestElementWire(t *testing.T) {
[]byte{0x01, 0x00, 0x00, 0x00},
},
{
rddwire.BitcoinNet(rddwire.MainNet),
rddwire.ReddcoinNet(rddwire.MainNet),
[]byte{0xfb, 0xc0, 0xb6, 0xdb},
},
// Type not supported by the "fast" path and requires reflection.
Expand Down Expand Up @@ -213,7 +213,7 @@ func TestElementWireErrors(t *testing.T) {
},
{rddwire.ServiceFlag(rddwire.SFNodeNetwork), 0, io.ErrShortWrite, io.EOF},
{rddwire.InvType(rddwire.InvTypeTx), 0, io.ErrShortWrite, io.EOF},
{rddwire.BitcoinNet(rddwire.MainNet), 0, io.ErrShortWrite, io.EOF},
{rddwire.ReddcoinNet(rddwire.MainNet), 0, io.ErrShortWrite, io.EOF},
}

t.Logf("Running %d tests", len(tests))
Expand Down
68 changes: 34 additions & 34 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,40 @@
// license that can be found in the LICENSE file.

/*
Package rddwire implements the bitcoin wire protocol.
Package rddwire implements the Reddcoin wire protocol.
For the complete details of the bitcoin protocol, see the official wiki entry
at https://en.bitcoin.it/wiki/Protocol_specification. The following only serves
For the complete details of the Reddcoin 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 bitcoin messages to and from the wire. This package does not deal
supported Reddcoin 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.
Bitcoin Message Overview
Reddcoin Message Overview
The bitcoin protocol consists of exchanging messages between peers. Each
The Reddcoin protocol consists of exchanging messages between peers. Each
message is preceded by a header which identifies information about it such as
which bitcoin network it is a part of, its type, how big it is, and a checksum
which Reddcoin 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 bitcoin messages named
To accomplish this, there is a generic interface for Reddcoin 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 bitcoin messages are provided. For these supported
of the currently supported Reddcoin messages are provided. For these supported
messages, all of the details of marshalling and unmarshalling to and from the
wire using bitcoin encoding are handled so the caller doesn't have to concern
wire using Reddcoin encoding are handled so the caller doesn't have to concern
themselves with the specifics.
Message Interaction
The following provides a quick summary of how the bitcoin messages are intended
The following provides a quick summary of how the Reddcoin 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 bitcoin protocol wiki entry at
https://en.bitcoin.it/wiki/Protocol_specification.
appropriate interactions, see the official Bitcoin 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
Expand Down Expand Up @@ -65,7 +65,7 @@ interactions in no particular order.
Common Parameters
There are several common parameters that arise when using this package to read
and write bitcoin messages. The following sections provide a quick overview of
and write Reddcoin messages. The following sections provide a quick overview of
these parameters so the next sections can build on them.
Protocol Version
Expand All @@ -77,10 +77,10 @@ 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.
Bitcoin Network
Reddcoin Network
The bitcoin network is a magic number which is used to identify the start of a
message and which bitcoin network the message applies to. This package provides
The Reddcoin network is a magic number which is used to identify the start of a
message and which Reddcoin network the message applies to. This package provides
the following constants:
rddwire.MainNet
Expand All @@ -90,8 +90,8 @@ the following constants:
Determining Message Type
As discussed in the bitcoin message overview section, this package reads
and writes bitcoin messages using a generic interface named Message. In
As discussed in the Reddcoin message overview section, this package reads
and writes Reddcoin 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:
Expand All @@ -108,33 +108,33 @@ switch or type assertion. An example of a type switch follows:
Reading Messages
In order to unmarshall bitcoin messages from the wire, use the ReadMessage
In order to unmarshall Reddcoin 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 bitcoin peer. Example syntax is:
a remote node running a Reddcoin peer. Example syntax is:
// Reads and validates the next bitcoin message from conn using the
// protocol version pver and the bitcoin network btcnet. The returns
// Reads and validates the next Reddcoin message from conn using the
// protocol version pver and the Reddcoin network rddnet. The returns
// are a rddwire.Message, a []byte which contains the unmarshalled
// raw payload, and a possible error.
msg, rawPayload, err := rddwire.ReadMessage(conn, pver, btcnet)
msg, rawPayload, err := rddwire.ReadMessage(conn, pver, rddnet)
if err != nil {
// Log and handle the error
}
Writing Messages
In order to marshall bitcoin messages to the wire, use the WriteMessage
In order to marshall Reddcoin 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 bitcoin peer. Example syntax to request addresses
a remote node running a Reddcoin peer. Example syntax to request addresses
from a remote peer is:
// Create a new getaddr bitcoin message.
// Create a new getaddr Reddcoin message.
msg := rddwire.NewMsgGetAddr()
// Writes a bitcoin message msg to conn using the protocol version
// pver, and the bitcoin network btcnet. The return is a possible
// Writes a Reddcoin message msg to conn using the protocol version
// pver, and the Reddcoin network rddnet. The return is a possible
// error.
err := rddwire.WriteMessage(conn, msg, pver, btcnet)
err := rddwire.WriteMessage(conn, msg, pver, rddnet)
if err != nil {
// Log and handle the error
}
Expand All @@ -151,9 +151,9 @@ Bitcoin Improvement Proposals
This package includes spec changes outlined by the following BIPs:
BIP0014 (https://en.bitcoin.it/wiki/BIP_0014)
BIP0031 (https://en.bitcoin.it/wiki/BIP_0031)
BIP0035 (https://en.bitcoin.it/wiki/BIP_0035)
BIP0037 (https://en.bitcoin.it/wiki/BIP_0037)
BIP0014 (https://en.Bitcoin.it/wiki/BIP_0014)
BIP0031 (https://en.Bitcoin.it/wiki/BIP_0031)
BIP0035 (https://en.Bitcoin.it/wiki/BIP_0035)
BIP0037 (https://en.Bitcoin.it/wiki/BIP_0037)
*/
package rddwire
2 changes: 1 addition & 1 deletion error.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

// MessageError describes an issue with a message.
// An example of some potential issues are messages from the wrong bitcoin
// An example of some potential issues are messages from the wrong Reddcoin
// network, invalid commands, mismatched checksums, and exceeding max payloads.
//
// This provides a mechanism for the caller to type assert the error to
Expand Down
4 changes: 2 additions & 2 deletions invvect.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

const (
// MaxInvPerMsg is the maximum number of inventory vectors that can be in a
// single bitcoin inv message.
// single Reddcoin inv message.
MaxInvPerMsg = 50000

// Maximum payload size for an inventory vector.
Expand Down Expand Up @@ -46,7 +46,7 @@ func (invtype InvType) String() string {
return fmt.Sprintf("Unknown InvType (%d)", uint32(invtype))
}

// InvVect defines a bitcoin inventory vector which is used to describe data,
// InvVect defines a Reddcoin inventory vector which is used to describe data,
// as specified by the Type field, that a peer wants, has, or does not have to
// another peer.
type InvVect struct {
Expand Down
Loading

0 comments on commit 9a9b557

Please sign in to comment.