Update for recent btcwire API changes.

This commit is contained in:
Dave Collins 2014-01-18 20:59:07 -06:00
parent b651766231
commit 4edc4ceb9e
2 changed files with 3 additions and 4 deletions

View file

@ -93,7 +93,7 @@ func (b *Block) Sha() (*btcwire.ShaHash, error) {
// properties such as caching the hash so subsequent calls are more efficient. // properties such as caching the hash so subsequent calls are more efficient.
func (b *Block) Tx(txNum int) (*Tx, error) { func (b *Block) Tx(txNum int) (*Tx, error) {
// Ensure the requested transaction is in range. // Ensure the requested transaction is in range.
numTx := b.msgBlock.Header.TxnCount numTx := uint64(len(b.msgBlock.Transactions))
if txNum < 0 || uint64(txNum) > numTx { if txNum < 0 || uint64(txNum) > numTx {
str := fmt.Sprintf("transaction index %d is out of range - max %d", str := fmt.Sprintf("transaction index %d is out of range - max %d",
txNum, numTx-1) txNum, numTx-1)
@ -131,7 +131,7 @@ func (b *Block) Transactions() []*Tx {
// Generate slice to hold all of the wrapped transactions if needed. // Generate slice to hold all of the wrapped transactions if needed.
if len(b.transactions) == 0 { if len(b.transactions) == 0 {
b.transactions = make([]*Tx, b.msgBlock.Header.TxnCount) b.transactions = make([]*Tx, len(b.msgBlock.Transactions))
} }
// Generate and cache the wrapped transactions for all that haven't // Generate and cache the wrapped transactions for all that haven't
@ -184,7 +184,7 @@ func (b *Block) TxShas() ([]*btcwire.ShaHash, error) {
// Generate slice to hold all of the transaction hashes if needed. // Generate slice to hold all of the transaction hashes if needed.
if len(b.txShas) == 0 { if len(b.txShas) == 0 {
b.txShas = make([]*btcwire.ShaHash, b.msgBlock.Header.TxnCount) b.txShas = make([]*btcwire.ShaHash, len(b.msgBlock.Transactions))
} }
// Generate and cache the transaction hashes for all that haven't already // Generate and cache the transaction hashes for all that haven't already

View file

@ -380,7 +380,6 @@ var Block100000 = btcwire.MsgBlock{
Timestamp: time.Unix(1293623863, 0), // 2010-12-29 11:57:43 +0000 UTC Timestamp: time.Unix(1293623863, 0), // 2010-12-29 11:57:43 +0000 UTC
Bits: 0x1b04864c, // 453281356 Bits: 0x1b04864c, // 453281356
Nonce: 0x10572b0f, // 274148111 Nonce: 0x10572b0f, // 274148111
TxnCount: 4,
}, },
Transactions: []*btcwire.MsgTx{ Transactions: []*btcwire.MsgTx{
&btcwire.MsgTx{ &btcwire.MsgTx{