Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

txscript: Fix typo in README #234

Merged
merged 22 commits into from
May 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
87182a2
blockchain: Correct serialized coinbase height error message.
Dirbaio Dec 21, 2015
89af747
peer: remove getaddr msg from stall detection.
Dirbaio Dec 27, 2015
d0cdd53
server: Fix persistent peers not being removed properly
Dirbaio Dec 27, 2015
df20c10
Fix typos in changelog.
wallclockbuilder Dec 29, 2015
ff0c787
Fix inconsistent spacing.
wallclockbuilder Dec 29, 2015
6e133b5
txscript: Fix docs to match function.
wallclockbuilder Dec 29, 2015
34a94b7
txscript: sync Bitcoin Core script tests
dajohi Dec 30, 2015
14ccab8
Review and fix typos in SigCache code.
wallclockbuilder Dec 30, 2015
829e87a
Replace *KoblitzCurve by elliptic.Curve
mvdan Jan 3, 2016
e24fe94
chaincfg: Remove testnet-seed.alexykot.me, it is defunct.
dajohi Jan 5, 2016
7996eb1
peer: drain chans before exiting peerHandler
tuxcanfly Dec 16, 2015
1944637
Bump copyright date to reflect fixes since the beginning of this year.
wallclockbuilder Jan 6, 2016
f5ded65
Change copyright date for code that was updated this year(2016).
wallclockbuilder Jan 7, 2016
407fcc2
Update LICENSE
Jan 23, 2016
e03fa30
peer: Simplify PushAddrMsg method loop.
jongillham Jan 23, 2016
95361a2
wire: Minor code clean up.
jongillham Jan 25, 2016
528ddaf
txscript: Fix typo in README
shphrd Jan 29, 2016
fe65e81
Apply various upstream comment fixes.
davecgh May 27, 2016
77b2c53
Merge upstream copyright date updates.
davecgh May 27, 2016
c9c32d5
peer: Simplify PushAddrMsg method loop.
davecgh May 27, 2016
c44f08b
wire: Minor code clean up.
davecgh May 27, 2016
3117ae7
txscript: Fix typo in README
davecgh May 27, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
============================================================================
User visible changes for btcd
A full-node bitcoin implementation written in Go
User visible changes for dcrd
A full-node decred implementation written in Go
============================================================================

Changes in 0.11.1 (Wed May 27 2015)
Expand Down Expand Up @@ -44,7 +44,7 @@ Changes in 0.11.0 (Wed May 06 2015)
forking from the network on non-standard transactions (#425)
- Add a new checkpoint at block height 352940 (#418)
- Optimized script execution (#395, #400, #404, #409)
- Fix a case that could lead stalled syncs (#138, #296)
- Fix a case that could lead stalled syncs (#138, #296)
- Network address manager changes:
- Implement eclipse attack countermeasures as proposed in
http://cs-people.bu.edu/heilman/eclipse (#370, #373)
Expand Down Expand Up @@ -513,7 +513,7 @@ Changes in 0.7.0 (Thu Feb 20 2014)
- Add getnetworkhashps command
- Add gettransaction command (wallet-specific)
- Add signmessage command (wallet-specific)
- Update getwork command to accept
- Update getwork command to accept
- Continue cleanup and work on implementing the RPC API:
- Implement getnettotals command
(https://github.com/conformal/btcd/issues/84)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2013-2015 The btcsuite developers
Copyright (c) 2013-2016 The btcsuite developers
Copyright (c) 2015-2016 The Decred developers

Permission to use, copy, modify, and distribute this software for any
Expand Down
2 changes: 1 addition & 1 deletion docs/code_contribution_guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ security and performance implications.

- [Effective Go](http://golang.org/doc/effective_go.html) - The entire dcrd
suite follows the guidelines in this document. For your code to be accepted,
it must follow the guidelinestherein.
it must follow the guidelines therein.
- [Original Satoshi Whitepaper](http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&ved=0CCkQFjAA&url=http%3A%2F%2Fbitcoin.org%2Fbitcoin.pdf&ei=os3VUuH8G4SlsASV74GoAg&usg=AFQjCNEipPLigou_1MfB7DQjXCNdlylrBg&sig2=FaHDuT5z36GMWDEnybDJLg&bvm=bv.59378465,d.b2I) - This is the white paper that started it all. Having a solid
foundation to build on will make the code much more comprehensible.

Expand Down
2 changes: 1 addition & 1 deletion params.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2013-2014 The btcsuite developers
// Copyright (c) 2013-2016 The btcsuite developers
// Copyright (c) 2015 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
Expand Down
46 changes: 24 additions & 22 deletions peer/peer.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2013-2015 The btcsuite developers
// Copyright (c) 2013-2016 The btcsuite developers
// Copyright (c) 2016 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
Expand All @@ -11,7 +11,7 @@ import (
"errors"
"fmt"
"io"
prand "math/rand"
"math/rand"
"net"
"strconv"
"sync"
Expand Down Expand Up @@ -821,36 +821,34 @@ func (p *Peer) pushVersionMsg() error {
// addresses. This function is useful over manually sending the message via
// QueueMessage since it automatically limits the addresses to the maximum
// number allowed by the message and randomizes the chosen addresses when there
// are too many. No message will be sent if there are no entries in the
// provided addresses slice.
// It is safe for concurrent access.
// are too many. It returns the addresses that were actually sent and no
// message will be sent if there are no entries in the provided addresses slice.
//
// This function is safe for concurrent access.
func (p *Peer) PushAddrMsg(addresses []*wire.NetAddress) ([]*wire.NetAddress, error) {

// Nothing to send.
if len(addresses) == 0 {
return nil, nil
}

r := prand.New(prand.NewSource(time.Now().UnixNano()))
numAdded := 0
msg := wire.NewMsgAddr()
for _, na := range addresses {
// Randomize the list with the remaining addresses when the
// max addresses limit has been reached.
if numAdded == wire.MaxAddrPerMsg {
msg.AddrList[r.Intn(wire.MaxAddrPerMsg)] = na
continue
msg.AddrList = make([]*wire.NetAddress, len(addresses))
copy(msg.AddrList, addresses)

// Randomize the addresses sent if there are more than the maximum allowed.
if len(msg.AddrList) > wire.MaxAddrPerMsg {
// Shuffle the address list.
for i := range msg.AddrList {
j := rand.Intn(i + 1)
msg.AddrList[i], msg.AddrList[j] = msg.AddrList[j], msg.AddrList[i]
}

// Add the address to the message.
err := msg.AddAddress(na)
if err != nil {
return nil, err
}
numAdded++
}
if numAdded > 0 {
p.QueueMessage(msg, nil)
// Truncate it to the maximum size.
msg.AddrList = msg.AddrList[:wire.MaxAddrPerMsg]
}

p.QueueMessage(msg, nil)
return msg.AddrList, nil
}

Expand Down Expand Up @@ -2065,3 +2063,7 @@ func NewOutboundPeer(cfg *Config, addr string) (*Peer, error) {

return p, nil
}

func init() {
rand.Seed(time.Now().UnixNano())
}
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2013-2015 The btcsuite developers
// Copyright (c) 2013-2016 The btcsuite developers
// Copyright (c) 2015-2016 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
Expand Down
2 changes: 1 addition & 1 deletion txscript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ package for any projects needing to use or validate decred transaction scripts.

## Decred Scripts

Decred provides a stack-based, FORTH-like langauge for the scripts in
Decred provides a stack-based, FORTH-like language for the scripts in
the decred transactions. This language is not turing complete
although it is still fairly powerful.

Expand Down
6 changes: 3 additions & 3 deletions txscript/data/script_valid.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@
["'abcdefghijklmnopqrstuvwxyz'", "HASH256 0x4c 0x20 0x513d6e9cb7f369fa60933bc48818da2cd0c0a079ebdd29a0cce382d4625dcb39 EQUAL", "P2SH,STRICTENC"],


["1","NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 1 EQUAL", "P2SH,STRICTENC"],
["'NOP_1_to_10' NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10","'NOP_1_to_10' EQUAL", "P2SH,STRICTENC"],
["1","NOP1 CHECKLOCKTIMEVERIFY NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 1 EQUAL", "P2SH,STRICTENC"],
["'NOP_1_to_10' NOP1 CHECKLOCKTIMEVERIFY NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10","'NOP_1_to_10' EQUAL", "P2SH,STRICTENC"],

["1", "NOP", "P2SH,STRICTENC,DISCOURAGE_UPGRADABLE_NOPS", "Discourage NOPx flag allows OP_NOP"],

Expand Down Expand Up @@ -467,7 +467,7 @@
["NOP", "1", "P2SH,STRICTENC"],

["NOP", "NOP1 1", "P2SH,STRICTENC"],
["NOP", "NOP2 1", "P2SH,STRICTENC"],
["NOP", "CHECKLOCKTIMEVERIFY 1", "P2SH,STRICTENC"],
["NOP", "NOP3 1", "P2SH,STRICTENC"],
["NOP", "NOP4 1", "P2SH,STRICTENC"],
["NOP", "NOP5 1", "P2SH,STRICTENC"],
Expand Down
4 changes: 2 additions & 2 deletions txscript/sigcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type SigCache struct {

// NewSigCache creates and initializes a new instance of SigCache. Its sole
// parameter 'maxEntries' represents the maximum number of entries allowed to
// exist in the SigCache and any particular moment. Random entries are evicted
// exist in the SigCache at any particular moment. Random entries are evicted
// to make room for new entries that would cause the number of entries in the
// cache to exceed the max.
func NewSigCache(maxEntries uint) *SigCache {
Expand All @@ -64,7 +64,7 @@ func (s *SigCache) Exists(sigHash chainhash.Hash, sig chainec.Signature, pubKey

// Add adds an entry for a signature over 'sigHash' under public key 'pubKey'
// to the signature cache. In the event that the SigCache is 'full', an
// existing entry it randomly chosen to be evicted in order to make space for
// existing entry is randomly chosen to be evicted in order to make space for
// the new entry.
//
// NOTE: This function is safe for concurrent access. Writers will block
Expand Down
6 changes: 3 additions & 3 deletions txscript/sigcache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"github.com/decred/dcrd/chaincfg/chainhash"
)

// genRandomSig returns a random message, public key, and a signature of the
// message under the public key. This function is used to generate randomized
// genRandomSig returns a random message, a signature of the message under the
// public key and the public key. This function is used to generate randomized
// test data.
func genRandomSig() (*chainhash.Hash, chainec.Signature, chainec.PublicKey, error) {
secp256k1 := chainec.Secp256k1
Expand Down Expand Up @@ -94,7 +94,7 @@ func TestSigCacheAddEvictEntry(t *testing.T) {
}

// Add a new entry, this should cause eviction of a randomly chosen
// previously entry.
// previous entry.
msgNew, sigNew, keyNew, err := genRandomSig()
if err != nil {
t.Fatalf("unable to generate random signature test data")
Expand Down
14 changes: 5 additions & 9 deletions wire/message.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2013-2015 The btcsuite developers
// Copyright (c) 2013-2016 The btcsuite developers
// Copyright (c) 2015 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
Expand Down Expand Up @@ -254,19 +254,17 @@ func WriteMessageN(w io.Writer, msg Message, pver uint32, dcrnet CurrencyNet) (i

// Write header.
n, err := w.Write(hw.Bytes())
totalBytes += n
if err != nil {
totalBytes += n
return totalBytes, err
}
totalBytes += n

// Write payload.
n, err = w.Write(payload)
totalBytes += n
if err != nil {
totalBytes += n
return totalBytes, err
}
totalBytes += n

return totalBytes, nil
}
Expand All @@ -289,11 +287,10 @@ func WriteMessage(w io.Writer, msg Message, pver uint32, dcrnet CurrencyNet) err
func ReadMessageN(r io.Reader, pver uint32, dcrnet CurrencyNet) (int, Message, []byte, error) {
totalBytes := 0
n, hdr, err := readMessageHeader(r)
totalBytes += n
if err != nil {
totalBytes += n
return totalBytes, nil, nil, err
}
totalBytes += n

// Enforce maximum message payload.
if hdr.length > MaxMessagePayload {
Expand Down Expand Up @@ -342,11 +339,10 @@ func ReadMessageN(r io.Reader, pver uint32, dcrnet CurrencyNet) (int, Message, [
// Read payload.
payload := make([]byte, hdr.length)
n, err = io.ReadFull(r, payload)
totalBytes += n
if err != nil {
totalBytes += n
return totalBytes, nil, nil, err
}
totalBytes += n

// Test checksum.
checksum := chainhash.HashFuncB(payload)[0:4]
Expand Down
7 changes: 2 additions & 5 deletions wire/msgversion.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2013-2015 The btcsuite developers
// Copyright (c) 2013-2016 The btcsuite developers
// Copyright (c) 2015 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
Expand Down Expand Up @@ -62,10 +62,7 @@ type MsgVersion struct {
// HasService returns whether the specified service is supported by the peer
// that generated the message.
func (msg *MsgVersion) HasService(service ServiceFlag) bool {
if msg.Services&service == service {
return true
}
return false
return msg.Services&service == service
}

// AddService adds service as a supported service by the peer generating the
Expand Down