Commit graph

1732 commits

Author SHA1 Message Date
Dave Collins
dc3a2dbac0 Correct example usage.
The variable to insert is 'genesis', not 'block'.
2013-07-29 12:41:30 -05:00
Dave Collins
e82c97be3b Update examples for recent btcdb changes.
Since creating a new database with btcdb no longer automatically inserts
the main network genesis block, update the examples accordingly.
2013-07-29 12:35:01 -05:00
Dave Collins
25684a2ccb Don't add a genesis block by default.
This commit modifies the way initial database creation is handled.

Previously, the genesis for the main chain was inserted automatically upon
creation of the database.  However, that approach caused an issue since
other networks such as the test network don't use the same genesis block
as the main network.

The new approach introduced by this commit is to leave it up to the caller
to insert the desired genesis block.  In order to support this, the
InsertBlock function has been modified to allow the first (and only the
first) block to be inserted without having an existing parent.  Also, the
NewestSha function has been modified to return a zero hash, -1 for the
height, and no error when the database does not yet have any blocks.  This
allows the caller to determine the difference between no blocks and only
the genesis block (in which case the return values would be the genesis
hash and 0 for the height).
2013-07-29 11:48:10 -05:00
Dave Collins
584481280c Print actual hash on a couple of log warnings.
The blocksha variable is already a pointer.
2013-07-29 10:57:03 -05:00
Dave Collins
761f666c44 Use consistent form for Checkpoint comment. 2013-07-27 16:46:46 -05:00
Dave Collins
ace58495c8 Comment CheckpointConfirmations. 2013-07-27 16:45:59 -05:00
Dave Collins
81120958f0 Comment inventory vector constants. 2013-07-27 16:42:23 -05:00
Dave Collins
69446009b2 Move TxVersion constant definition to msgtx.go.
This moves the definition closer to the associated type and mirrors the
rest of the package.
2013-07-27 16:34:47 -05:00
Dave Collins
035a9c3dc3 Add several comments for exported constants. 2013-07-27 16:31:47 -05:00
Dave Collins
d6752d8f99 Update comments to fix typos and use proper form. 2013-07-27 16:18:13 -05:00
Dave Collins
bfbc08beed Allow var defs to infer type from right-hand side.
Found by golint.
2013-07-27 16:10:38 -05:00
Dave Collins
99b06f8bce Add format specifier in pong test error output.
The error message did not have a format specifier even though it was
passing an argument to show.  Found by go vet.
2013-07-27 15:56:17 -05:00
Dave Collins
562bde6902 Use byte literals in tests to make go vet happy.
The go vet command complains about untagged struct initializers when
defining a ShaHash directly.  This seems to be a limitation where go vet
does not exclude the warning for types which are a constant size byte array
like it does for normal constant size byte array definition.

This commit simply modifies the tests to use a constant definition cast to a
ShaHash to overcome the limitation of go vet.
2013-07-27 15:55:06 -05:00
Dave Collins
90bf9e7449 Update tests for corrected max block payload size. 2013-07-27 15:32:36 -05:00
Dave Collins
9989865fa2 Use correct max block payload size.
The maximum block payload size is actually 1000000 bytes, not 1MB.
2013-07-27 15:25:05 -05:00
Dave Collins
b282678d9a Spend outputs while checking transaction inputs.
This commit modifies the double spend detection to handle double spends
within the same block as well as side chains when doing the checks before
reorganizing the chain.
2013-07-26 11:51:13 -05:00
Dave Collins
ea3107d962 Add comments and doco to clairfy test networks.
There was not much documentation about the difference between testnet and
testnet3, so make it clear that testnet is used for regression tests and
testnet3 is the public test network (version 3).
2013-07-25 19:04:58 -05:00
Dave Collins
4e6b649be6 Add constant for regression test netowrk port. 2013-07-25 19:04:02 -05:00
Owain G. Ainsworth
e7f9415e4f Return 0 for bad scripts from sigops code instead of an error.
matches how bitcoind behaves.
2013-07-25 14:27:58 +01:00
Dave Collins
9787f46f6a Implement testnet specific rules.
This commit adds support for testnet specific rules when a new BlockChain
is created against testnet.
2013-07-24 17:03:29 -05:00
Dave Collins
1deeb05627 Add a few log error messages.
In addition to returning errors to the caller, log the error with a prefix
in a few key places that helps identify the origin for errors.  In some
cases, the underlying error comes from a different subsystem such as the
SQL database driver and the error messages can be fairly generic.
2013-07-24 12:31:14 -05:00
Dave Collins
f219ed5baf Add support for params based on active network.
This commit modifies the code to use params based on the active network
which paves the way for supporting the special rules and different genesis
blocks used by the test networks.
2013-07-24 12:26:17 -05:00
Dave Collins
3c4292fae3 Add parent to info print when adding orphans. 2013-07-24 11:12:25 -05:00
Dave Collins
60dfddc9d0 Use common coinbase transaction for Genesis blocks.
Since the same coinbase transaction is used for the genesis blocks of
all three currently supposed networks, separate it into its own var and
use a reference to it in each of the genesis block defintions.
2013-07-24 09:09:18 -05:00
Dave Collins
ab064fd4d4 Add tests for genesis block of testnet (version 3). 2013-07-24 01:47:11 -05:00
Dave Collins
166123ae79 Add genesis block for the test network (version 3). 2013-07-24 01:45:30 -05:00
Dave Collins
b8f80da512 Add tests for genesis block of regression testnet. 2013-07-24 01:33:24 -05:00
Dave Collins
a90a8bf341 Add genesis block for the regression test network. 2013-07-24 01:32:43 -05:00
Dave Collins
65eae18285 Remove a couple of incorrect comments. 2013-07-24 00:35:16 -05:00
Dave Collins
ebd4af80f0 Make CheckpointConfirmations 2016.
After discussing the criteria used by the core developers on #btc-dev IRC
channel, gmaxwell indicated they like to see at least 2016 blocks.  This
commit updates the checkpoint confirmations accordingly.
2013-07-22 03:20:00 -05:00
Dave Collins
f3e542ff92 Add negative test for duplicate block.
This commit adds tests for the error path when processing a block that is
already in the main chain.
2013-07-22 01:06:53 -05:00
Dave Collins
d6d2b15901 Clarify BIP0034 is supported in package doco. 2013-07-20 02:39:07 -05:00
Dale Rahn
92651c6d13 Fix spent computation on a multiple of 8 txout tx. 2013-07-19 15:49:02 -05:00
Dave Collins
20f7c2ecd0 Add tests for TimeSorter. 2013-07-19 12:49:11 -05:00
Dave Collins
355502c970 Update documentation for IsCheckpointCandidate.
The bulleted list was not indented which caused godoc to show the
documentation improperly.
2013-07-19 10:08:09 -05:00
Dave Collins
aa5847f3cc Initial implementation. 2013-07-19 08:50:13 -05:00
Dale Rahn
bee05db603 Exunge debug code. 2013-07-18 18:19:57 -04:00
Dale Rahn
66731c1a1e Implement TxOut Spend tracking.
Return spent data in TxListReply.

Unspend coins when blocks are removed during DropAfterBlock.
2013-07-18 18:11:37 -04:00
Dave Collins
180c827db3 Initial commit. 2013-07-18 09:39:30 -05:00
Owain G. Ainsworth
a7a9023bc1 Add ExistsTxSha to db interface.
This function may be used to check for existance of a tx sha without having to
fetch the data from the db.
2013-07-10 00:11:02 +01:00
Owain G. Ainsworth
1f773006f0 fix tests building from 166a546078 2013-07-09 22:49:58 +01:00
Dave Collins
eb5de559ff Fix a couple of comment typos for the word execute. 2013-07-06 11:59:07 -05:00
Owain G. Ainsworth
bedaddb790 add GetScriptClass to return the internal script type of a script.
To be used to tell which class a script is (multisig, scripthash, pubkey,
pkhash, or nonstandard)
2013-07-05 15:23:02 +01:00
Owain G. Ainsworth
4d31b2c850 Remove blurb about 100% coverage and replace with comprehensive.
btcscript contains an amount of debug logging that is very useful to
have. We have agreed that testing this isn't realy practical or indeed
really useful and thus is rather unlikely to grow test coverage any time
soon.
2013-06-28 01:15:10 +01:00
Owain G. Ainsworth
c41330e772 Add basic test for if internal opcode definitions are buggy. 2013-06-28 00:46:34 +01:00
Owain G. Ainsworth
89578c985a add basic test for OP_SHA1
yup, it produces the sha of the data.
2013-06-27 16:15:32 +01:00
Owain G. Ainsworth
e5a2756795 Test empty scripts and out of bounds for DisasmScript()
give disasmscript a defined error return for out of bounds.
2013-06-27 15:07:37 +01:00
Owain G. Ainsworth
244ce4b96e add IsPayToScriptHash api
To tell ifa bytestream matches teh p2sh pattern.
2013-06-27 14:20:08 +01:00
Owain G. Ainsworth
bcd8c9d227 gofmt 2013-06-27 14:20:08 +01:00
Owain G. Ainsworth
dd216cef29 Test pushing at and beyond the boundary for largest stack item. 2013-06-26 23:57:49 +01:00