Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/btcsuite/btcd into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jakesylvestre committed Aug 29, 2020
2 parents c83a451 + 56cc42f commit 177ab76
Show file tree
Hide file tree
Showing 79 changed files with 2,380 additions and 1,386 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build and Test
on: [push, pull_request]
jobs:
build:
name: Go CI
runs-on: ubuntu-latest
strategy:
matrix:
go: [1.13, 1.14]
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Check out source
uses: actions/checkout@v2
- name: Install Linters
run: "curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.26.0"
- name: Build
env:
GO111MODULE: "on"
run: go build ./...
- name: Test
env:
GO111MODULE: "on"
run: |
sh ./goclean.sh
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

155 changes: 155 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,161 @@ User visible changes for btcd
A full-node bitcoin implementation written in Go
============================================================================

Changes in 0.21.0 (Thu Aug 27 2020)
- Network-related changes:
- Handle notfound messages from peers in netsync package (#1603)
- RPC changes:
- Add compatibility for getblock RPC changes in bitcoind 0.15.0 (#1529)
- Add new optional Params field to rpcclient.ConnConfig (#1467)
- Add new error code ErrRPCInWarmup in btcjson (#1541)
- Add compatibility for changes to getmempoolentry response in bitcoind
0.19.0 (#1524)
- Add rpcclient methods for estimatesmartfee and generatetoaddress
commands (#1500)
- Add rpcclient method for getblockstats command (#1500)
- Parse serialized transaction from createrawtransaction command using
both segwit, and legacy format (#1502)
- Support cookie-based authentication in rpcclient (#1460)
- Add rpcclient method for getchaintxstats command (#1571)
- Add rpcclient method for fundrawtransaction command (#1553)
- Add rpcclient method for getbalances command (#1595)
- Add new method rpcclient.GetTransactionWatchOnly (#1592)
- Crypto changes:
- Fix panic in fieldVal.SetByteSlice when called with large values, and
improve the method to be 35% faster (#1602)
- btcctl changes:
- Added -regtest mode to btcctl (#1556)
- Misc changes:
- Fix a bug due to a deadlock in connmgr's dynamic ban scoring (#1509)
- Add blockchain.NewUtxoEntry() to directly create entries for
UtxoViewpoint (#1588)
- Replace LRU cache implementation in peer package with a generic one
from decred/dcrd (#1599)
- Contributors (alphabetical order):
- Anirudha Bose
- Antonin Hildebrand
- Dan Cline
- Daniel McNally
- David Hill
- Federico Bond
- George Tankersley
- Henry
- Henry Harder
- Iskander Sharipov
- Ivan Kuznetsov
- Jake Sylvestre
- Javed Khan
- JeremyRand
- Jin
- John C. Vernaleo
- Kulpreet Singh
- Mikael Lindlof
- Murray Nesbitt
- Nisen
- Olaoluwa Osuntokun
- Oliver Gugger
- Steven Roose
- Torkel Rogstad
- Tyler Chambers
- Wilmer Paulino
- Yash Bhutwala
- adiabat
- jalavosus
- mohanson
- qqjettkgjzhxmwj
- qshuai
- shuai.qi
- tpkeeper

Changes in v0.20.1 (Wed Nov 13 2019)
- RPC changes:
- Add compatibility for bitcoind v0.19.0 in rpcclient and btcjson
packages (#1484)
- Contributors (alphabetical order):
- Eugene Zeigel
- Olaoluwa Osuntokun
- Wilmer Paulino

Changes in v0.20.0 (Tue Oct 15 2019)
- Significant changes made since 0.12.0. See git log or refer to release
notes on GitHub for full details.
- Contributors (alphabetical order):
- Albert Puigsech Galicia
- Alex Akselrod
- Alex Bosworth
- Alex Manuskin
- Alok Menghrajani
- Anatoli Babenia
- Andy Weidenbaum
- Calvin McAnarney
- Chris Martin
- Chris Pacia
- Chris Shepherd
- Conner Fromknecht
- Craig Sturdy
- Cédric Félizard
- Daniel Krawisz
- Daniel Martí
- Daniel McNally
- Dario Nieuwenhuis
- Dave Collins
- David Hill
- David de Kloet
- GeertJohan
- Grace Noah
- Gregory Trubetskoy
- Hector Jusforgues
- Iskander (Alex) Sharipov
- Janus Troelsen
- Jasper
- Javed Khan
- Jeremiah Goyette
- Jim Posen
- Jimmy Song
- Johan T. Halseth
- John C. Vernaleo
- Jonathan Gillham
- Josh Rickmar
- Jon Underwood
- Jonathan Zeppettini
- Jouke Hofman
- Julian Meyer
- Kai
- Kamil Slowikowski
- Kefkius
- Leonardo Lazzaro
- Marco Peereboom
- Marko Bencun
- Mawueli Kofi Adzoe
- Michail Kargakis
- Mitchell Paull
- Nathan Bass
- Nicola 'tekNico' Larosa
- Olaoluwa Osuntokun
- Pedro Martelletto
- Ricardo Velhote
- Roei Erez
- Ruben de Vries
- Rune T. Aune
- Sad Pencil
- Shuai Qi
- Steven Roose
- Tadge Dryja
- Tibor Bősze
- Tomás Senart
- Tzu-Jung Lee
- Vadym Popov
- Waldir Pimenta
- Wilmer Paulino
- benma
- danda
- dskloet
- esemplastic
- jadeblaquiere
- nakagawa
- preminem
- qshuai

Changes in 0.12.0 (Fri Nov 20 2015)
- Protocol and network related changes:
- Add a new checkpoint at block height 382320 (#555)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
btcd
====

[![Build Status](https://travis-ci.org/btcsuite/btcd.png?branch=master)](https://travis-ci.org/btcsuite/btcd)
[![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org)
[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/btcsuite/btcd)
[![Build Status](https://github.com/btcsuite/btcd/workflows/Build%20and%20Test/badge.svg)](https://github.com/btcsuite/btcd/actions)
[![ISC License](https://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org)
[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/github.com/btcsuite/btcd)

btcd is an alternative full node bitcoin implementation written in Go (golang).

Expand Down
13 changes: 2 additions & 11 deletions blockchain/chainio.go
Original file line number Diff line number Diff line change
Expand Up @@ -1149,18 +1149,9 @@ func (b *BlockChain) initChainState() error {

blockIndexBucket := dbTx.Metadata().Bucket(blockIndexBucketName)

// Determine how many blocks will be loaded into the index so we can
// allocate the right amount.
var blockCount int32
cursor := blockIndexBucket.Cursor()
for ok := cursor.First(); ok; ok = cursor.Next() {
blockCount++
}
blockNodes := make([]blockNode, blockCount)

var i int32
var lastNode *blockNode
cursor = blockIndexBucket.Cursor()
cursor := blockIndexBucket.Cursor()
for ok := cursor.First(); ok; ok = cursor.Next() {
header, status, err := deserializeBlockRow(cursor.Value())
if err != nil {
Expand Down Expand Up @@ -1193,7 +1184,7 @@ func (b *BlockChain) initChainState() error {

// Initialize the block node for the block, connect it,
// and add it to the block index.
node := &blockNodes[i]
node := new(blockNode)
initBlockNode(node, header, parent)
node.status = status
b.index.addNode(node)
Expand Down
2 changes: 1 addition & 1 deletion blockchain/difficulty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestCalcWork(t *testing.T) {
}

for x, test := range tests {
bits := uint32(test.in)
bits := test.in

r := CalcWork(bits)
if r.Int64() != test.out {
Expand Down
21 changes: 16 additions & 5 deletions blockchain/indexers/addrindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ func serializeAddrIndexEntry(blockID uint32, txLoc wire.TxLoc) []byte {
// provided region struct according to the format described in detail above and
// uses the passed block hash fetching function in order to conver the block ID
// to the associated block hash.
func deserializeAddrIndexEntry(serialized []byte, region *database.BlockRegion, fetchBlockHash fetchBlockHashFunc) error {
func deserializeAddrIndexEntry(serialized []byte, region *database.BlockRegion,
fetchBlockHash fetchBlockHashFunc) error {

// Ensure there are enough bytes to decode.
if len(serialized) < txEntrySize {
return errDeserialize("unexpected end of data")
Expand All @@ -182,7 +184,9 @@ func keyForLevel(addrKey [addrKeySize]byte, level uint8) [levelKeySize]byte {

// dbPutAddrIndexEntry updates the address index to include the provided entry
// according to the level-based scheme described in detail above.
func dbPutAddrIndexEntry(bucket internalBucket, addrKey [addrKeySize]byte, blockID uint32, txLoc wire.TxLoc) error {
func dbPutAddrIndexEntry(bucket internalBucket, addrKey [addrKeySize]byte,
blockID uint32, txLoc wire.TxLoc) error {

// Start with level 0 and its initial max number of entries.
curLevel := uint8(0)
maxLevelBytes := level0MaxEntries * txEntrySize
Expand Down Expand Up @@ -253,7 +257,10 @@ func dbPutAddrIndexEntry(bucket internalBucket, addrKey [addrKeySize]byte, block
// the given address key and the number of entries skipped since it could have
// been less in the case where there are less total entries than the requested
// number of entries to skip.
func dbFetchAddrIndexEntries(bucket internalBucket, addrKey [addrKeySize]byte, numToSkip, numRequested uint32, reverse bool, fetchBlockHash fetchBlockHashFunc) ([]database.BlockRegion, uint32, error) {
func dbFetchAddrIndexEntries(bucket internalBucket, addrKey [addrKeySize]byte,
numToSkip, numRequested uint32, reverse bool,
fetchBlockHash fetchBlockHashFunc) ([]database.BlockRegion, uint32, error) {

// When the reverse flag is not set, all levels need to be fetched
// because numToSkip and numRequested are counted from the oldest
// transactions (highest level) and thus the total count is needed.
Expand Down Expand Up @@ -356,7 +363,9 @@ func maxEntriesForLevel(level uint8) int {
// dbRemoveAddrIndexEntries removes the specified number of entries from from
// the address index for the provided key. An assertion error will be returned
// if the count exceeds the total number of entries in the index.
func dbRemoveAddrIndexEntries(bucket internalBucket, addrKey [addrKeySize]byte, count int) error {
func dbRemoveAddrIndexEntries(bucket internalBucket, addrKey [addrKeySize]byte,
count int) error {

// Nothing to do if no entries are being deleted.
if count <= 0 {
return nil
Expand Down Expand Up @@ -796,7 +805,9 @@ func (idx *AddrIndex) DisconnectBlock(dbTx database.Tx, block *btcutil.Block,
// that involve a given address.
//
// This function is safe for concurrent access.
func (idx *AddrIndex) TxRegionsForAddress(dbTx database.Tx, addr btcutil.Address, numToSkip, numRequested uint32, reverse bool) ([]database.BlockRegion, uint32, error) {
func (idx *AddrIndex) TxRegionsForAddress(dbTx database.Tx, addr btcutil.Address,
numToSkip, numRequested uint32, reverse bool) ([]database.BlockRegion, uint32, error) {

addrKey, err := addrToKey(addr)
if err != nil {
return nil, 0, err
Expand Down
4 changes: 2 additions & 2 deletions blockchain/indexers/addrindex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (b *addrIndexBucket) printLevels(addrKey [addrKeySize]byte) string {
if !bytes.Equal(k[:levelOffset], addrKey[:]) {
continue
}
level := uint8(k[levelOffset])
level := k[levelOffset]
if level > highestLevel {
highestLevel = level
}
Expand Down Expand Up @@ -105,7 +105,7 @@ func (b *addrIndexBucket) sanityCheck(addrKey [addrKeySize]byte, expectedTotal i
if !bytes.Equal(k[:levelOffset], addrKey[:]) {
continue
}
level := uint8(k[levelOffset])
level := k[levelOffset]
if level > highestLevel {
highestLevel = level
}
Expand Down
16 changes: 16 additions & 0 deletions blockchain/utxoviewpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,22 @@ func (entry *UtxoEntry) Clone() *UtxoEntry {
}
}

// NewUtxoEntry returns a new UtxoEntry built from the arguments.
func NewUtxoEntry(
txOut *wire.TxOut, blockHeight int32, isCoinbase bool) *UtxoEntry {
var cbFlag txoFlags
if isCoinbase {
cbFlag |= tfCoinBase
}

return &UtxoEntry{
amount: txOut.Value,
pkScript: txOut.PkScript,
blockHeight: blockHeight,
packedFlags: cbFlag,
}
}

// UtxoViewpoint represents a view into the set of unspent transaction outputs
// from a specific point of view in the chain. For example, it could be for
// the end of the main chain, some point in the history of the main chain, or
Expand Down
20 changes: 12 additions & 8 deletions btcec/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,20 +226,24 @@ func (f *fieldVal) SetBytes(b *[32]byte) *fieldVal {
return f
}

// SetByteSlice packs the passed big-endian value into the internal field value
// representation. Only the first 32-bytes are used. As a result, it is up to
// the caller to ensure numbers of the appropriate size are used or the value
// will be truncated.
// SetByteSlice interprets the provided slice as a 256-bit big-endian unsigned
// integer (meaning it is truncated to the first 32 bytes), packs it into the
// internal field value representation, and returns the updated field value.
//
// Note that since passing a slice with more than 32 bytes is truncated, it is
// possible that the truncated value is less than the field prime. It is up to
// the caller to decide whether it needs to provide numbers of the appropriate
// size or if it is acceptable to use this function with the described
// truncation behavior.
//
// The field value is returned to support chaining. This enables syntax like:
// f := new(fieldVal).SetByteSlice(byteSlice)
func (f *fieldVal) SetByteSlice(b []byte) *fieldVal {
var b32 [32]byte
for i := 0; i < len(b); i++ {
if i < 32 {
b32[i+(32-len(b))] = b[i]
}
if len(b) > 32 {
b = b[:32]
}
copy(b32[32-len(b):], b)
return f.SetBytes(&b32)
}

Expand Down
Loading

0 comments on commit 177ab76

Please sign in to comment.