This commit modifies the RandomUint64 function so that rather than
returning an io.ErrShortBuffer when the system does not have enough
entropy available, it now blocks until it does have enough. This means
that RandomUint64 will now always eventually succeed unless the entropy
source is closed (which only really ever happens when the operating system
is shutting down).
The tests have also been updated for the change in semantics to maintain
100% coverage.
Closes#23.
Since the result might not be set when the response does not contain one,
such as in the case when the command is not implemented by the server,
don't attempt to modify it until ensuring it exists.
This commit extends the same logic in the previous commit to the
comparison of offsets returned from the median time source in the tests.
In particular it modifies the tests to allow for the offsets to differ by
a second due to a boundary condition to prevent false positives.
The new median time tests perform a comparsion of the adjusted time
returned from the median time source to the expected value. However,
since time is always moving, it is possible the current time between the
call to the adjusted time function and the current time taken in the tests
for comparison just after the call differ by a second due to a boundary
condition. So, this commit modifies the tests to allow for this
condition.
This commit changes the internal testing mechanism from returning the
unexported timeSorter type directly to insted returning sort.Interface.
This has been done because the latest version of golint complains about
return unexported types.
This commit provides a new interface, MedianTimeSource, along with a
concrete implementation which allows improved accuracy of time by making
use of the median network time as calculated from multiple time samples.
The time samples are to be provided by callers and are intended to come
from remote clients.
The calculations performed in this implementation exactly mirror those in
Bitcoin Core because time calculations are part of the consensus rules and
hence need to match exactly.
This commit uses the new MedianTimeSource API in btcchain to create a
median time source which is stored in the server and is fed time samples
from all remote nodes that are connected. It also modifies all call sites
which now require the the time source to pass it in.
Code uses a windowing/precomputing strategy to minimize ECC math.
Every 8-bit window of the 256 bits that compose a possible scalar multiple has a complete map that's pre-computed.
The precomputed data is in secp256k1.go and the generator for that file is in gensecp256k1.go
Also fixed a spelling error in a benchmark test.
Results so far seem to indicate the time taken is about 35% of what it was before.
Closes#2
This change removes transactions from a newly connected block
from the orphan pool if they exist. Additionally, any orphan
transactions that are no longer orphan transactions are moved
to the mempool and inv'd to the currently connected peers.
This commit adds a couple of options which were not details in the sample
config file. It also fixes a couple of typos and makes the example default
maxpeers setting in the config file match the actual default used in btcd.
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 code to use a constant definition cast to
a ShaHash to overcome the limitation of go vet.