Commit graph

3 commits

Author SHA1 Message Date
Dave Collins
dbca1d59c3 Add a new behavior flag to provide a dry run.
This commit adds a new behavior flag, BFDryRun which allows the caller
to indicate all checks should be performed against the block as normal
except it will not modify any state.  This is useful to test that a block
is valid without actually modifying the current chain or memory state.

This commit also adds a few additional checks which were elided before
since they are implicitly handled by btcwire.  However, with the ability
to propose blocks which didn't necessarily come through the btcwire path,
these checks need to be enforced in the chain code as well.

As a part of adding the checks, three new error codes named
ErrBlockTooBig, ErrTooManyTransactions, and ErrTxTooBig have been
introduced.

Closes #5.
2014-06-29 17:49:16 -05:00
Dave Collins
a22da99f91 Convert script errors to RuleErrors.
This commit modifies the error return type for errors during script
validation to use the RuleError so they are consistent with the rest of
the errors.  This also helps the calling code differentiate blocks
rejected due to script parsing and validation errors as opposed to
internal issues such as inability to read from the disk.

To accomplish this, two new two new RuleErrors, ErrScriptMalformed and
ErrScriptValidation, have been added.

Also, the errors for script parsing issues and script validation errors
have been improved to include both transaction hashes and indexes involved
in the validation effort.  Previously script parsing issues had almost no
additional information as to which transaction input/outputs the failing
script came from.
2014-06-26 23:47:14 -05:00
Dave Collins
0550bbbdc5 Add tests for new RuleError and ErrorCode types. 2014-06-24 19:14:30 -05:00