Commit graph

19 commits

Author SHA1 Message Date
Dave Collins
1c7f05922f Convert block heights to int32.
This commit converts all block height references to int32 instead of
int64.  The current target block production rate is 10 mins per block
which means it will take roughly 40,800 years to reach the maximum
height an int32 affords.  Even if the target rate were lowered to one
block per minute, it would still take roughly another 4,080 years to
reach the maximum.

In the mean time, there is no reason to use a larger type which results
in higher memory usage.
2015-08-07 22:30:27 -05:00
Dave Collins
1b73e9828d Relicense to the btcsuite developers. 2015-05-01 12:41:58 -05:00
Dave Collins
9556412b01 Update for recent wire API hash error changes. 2015-04-17 01:13:40 -05:00
Dave Collins
e330838900 Remove error return from Block.Sha function.
This commit remove the error return from the Block.Sha function since it
can never fail and ends up causing a lot of unneeded error checking
throughout the code base.
2015-04-17 00:42:08 -05:00
Dave Collins
80b97479bd Update btcwire path import paths to new location. 2015-02-05 14:48:38 -06:00
Dave Collins
fdc00f8eff Update btcwire import paths to new location. 2015-01-16 15:26:50 -06:00
Dave Collins
6c4b5928ab goimports -w . 2014-07-02 19:29:48 -05:00
Josh Rickmar
b3e031c1f9 Add NewBlockFromReader and NewTxFromReader.
While here, remove the serializedTx field from Tx.  This field was
originally intended to be used to cache the bytes of the serialized
transaction, but it was never used and can effectively leak memory if
the Tx was created with a call to NewTxFromBytes.

ok @davecgh
2014-06-24 18:46:06 -05:00
Josh Rickmar
9a3f83d493 Switch bytes.Buffer to Reader where possible.
bytes.Reader is a little bit more efficient than a bytes.Buffer when
just reading, so in situations where only an io.Reader is needed (for
Block and Tx deserialization), switch to a bytes.Reader.

ok @davecgh
2014-06-23 21:39:04 -05:00
Dave Collins
2db41b1f56 Remove deprecated TxShas func from btcutil.Block.
This commit removes the previously deprecated TxShas function from
btcutil.Block.  The preferred method to access transaction hashes is via
the Sha function on each btcutil.Tx contained within the block.

For example, the following illustrates how convert the old TxShas approach
to the new method:

OLD:

for i, sha := range block.TxShas() {
	// use sha
}

NEW:

for i, tx := range block.Transactions() {
	// use tx.Sha()
}

This commit also updates the tests for the removed function.
2014-03-24 13:56:43 -05:00
Dave Collins
4edc4ceb9e Update for recent btcwire API changes. 2014-01-18 20:59:07 -06:00
Dave Collins
2af3c8263a Add 2014 to copyright dates. 2014-01-08 23:46:05 -06:00
Dave Collins
8e97f32e68 Add funcs to Block API for wrapped transactions.
This commit adds two new functions to the Block API for working with the
recently added Tx type from the Block.

These new functions are named Tx and Transactions.  Tx returns a
transactions for the specified index as a Tx and also memoizes it so
subsequent calls are more efficient.  Transactions returns a slice of all
transactions in the Block wrapped in a Tx.

This is part of the ongoing transaction hash optimization effort
noted in conformal/btcd#25.
2013-10-28 10:34:27 -05:00
Dave Collins
43095c66bc Remove dependency on protocol version.
This commit unfortunately changes the public API of Block which I
ordinarily don't like to do, but in this case, I felt it was necessary.

The blocks used throughout the database and elsewhere should be indepedent
of the protocol version which is used to encode the block to wire format.
Each block has its own Version field which should be the deciding factor
for the serialization and deserialization of blocks.  In practice, they
are currently the same encoding, but that may not always be the case, and
it's important the blocks are stable depending on their own version
regardless of the protocol version.

This makes use of the new Serialize and Deserialize functions on MsgBlock
which are intended for long-term storage as opposed to wire encoding.
2013-08-05 16:28:55 -05:00
Dave Collins
b8843a0fb6 Make TxLoc comment consistent with others. 2013-05-30 11:39:43 -05:00
Dave Collins
e98dc50b69 Convert TxLoc to use normal returns. 2013-05-30 11:31:22 -05:00
Dave Collins
969fbd1500 Cleanup TxLoc function variable names. 2013-05-30 11:13:08 -05:00
Dave Collins
af89ed1c2e Correct documentation of the Block.TxLoc function. 2013-05-28 18:43:13 -05:00
Dave Collins
ef6c01960f Initial implementation. 2013-05-28 18:21:26 -05:00