Rewrite startup/shutdown logic to simplify shutdown signaling. All
cleanup is now run from deferred functions in the main function.
Add two new config options to set the read and write ends of a pair of
pipes. This is used as a simple mechanism for a parent process to
communicate with, observe, and manage the lifetime of a child dcrd
process. When the RX (read end) pipe is closed, clean shutdown
automatically begins.
Add a new flag --lifetimeevents to create and send lifetime event
notifications over the TX (write end) pipe during bringup and
shutdown. This allows the parent process to observe which subsystems
are currently starting, running, and stopping.
Fixes#297.
Fixes#298.
A simple printf shows dozens of AfterFuncs being generated, especially
on testnet where the connectable node count is currently low. By
resetting the timer, it prevents needless wakeups from filling the
channel.
Before this fix, if a peer disconnected before the chain was marked
current, its goroutine and memory would hang around until the chain
was marked current. This would cause out-of-memory errors.
This should also speed up blockchain processing since there are
no longer many goroutines calling IsCurrent every 3 seconds.
* Fix the coin supply calculation
The coin supply calculation was inaccurate. It has been fixed to
exactly calculate the coin supply based on the history of the
blockchain.
* Final block exception
* <=
addrindex does not currently work so do not allow it as an option.
The code for it is still currently there, but no longer hooked in
to something users can set.
Closes#282
The configuration autogenerator currently does not work well
and tries to read the sample file based on where the compiled
source's data directory was. This has been fixed so that dcrd
only checks the %PROGRAMFILES% directory on Windows where the
sample configuration file might be stored. Configuration
autogeneration has been disabled for toehr operating systems.
having 3 int32s above the uint64s in the struct
will cause misalignment for some 32-bit architectures.
see https://golang.org/pkg/sync/atomic/#pkg-note-BUG
This aligns bytesReceived and bytesSent.
Ticket voting selection and validation require fast access to a
lexicographically sorted list of all available tickets. The current
implementation stores these tickets in bucketized maps which are
unordered. This means the data has to be sorted every time it is needed
in order to select a ticket and validate a block. On my hardware, the
process of removing tickets that have been voted and adding new tickets
takes ~27ms with the current implementation.
In order to speed this up, this introduces a new internal package named
tickettreap that provides a tailored treap data structure that is
intended to be used for the in-memory live ticket pool when the new
database and blockchain enhancements have been synced from upstream.
Since it maintains the data in sorted order, it provides a significant
speedup over the current map-based implementation. On my hardware, this
implementation is able to remove the tickets that have voted and add the
new tickets in ~0.083ms and iterate the entire structure for selecting the
tickets in ~1.88ms for a total of ~1.96ms. That equates to roughly 14x
faster access.
In addition, it would also be possible for the stake code to keep a map
for height-based lookups (while still relying on this new data structure
for keeping the lexicographic sort ordering requirements) for an even
greater speedup since it would eliminate the need to iterate the
structure to remove tickets at a given height.
Finally, when evaluating forks, the current code is quite inefficient
because it needs to make a copy of all of the live ticket maps. This
new structure provides O(1) snapshot/copy capabilities so it is much
more efficient in that regard as well.
Benchmarks:
ImmutableCopy 30000000 40.7 ns/op 0 B/op 0 allocs/op
ImmutableIterate 1000 1881738 ns/op 0 B/op 0 allocs/op
* Fix median of slice of Amounts for ticketfeeinfo.
The median function was not operating on a sorted array, so the
result was a random transaction. The modified function sorts
the slice, so a copy may be needed.
Upstream commit 123ff368f4.
NOTE: This does not separate the new Decred-specific mempool
policy-related variables into the new policy structure. That needs to
be done as a separate pull request.
Upstream commit d1e493f4ee.
Since Decred has supported the ability to disable transaction relaying
since the first version, this removes the additional checks which dealt
with only disconnecting peers that were at a high enough protocol
version to always disconnect when peers are announcing transactions when
they were instructed not to.
Upstream commit 8a58f8cf3a.
Modified the supported protocol version passed to peer to
wire.BIP0111Version which is the version in Decred just before the new
protocol version for wire.SendHeadersVersion.
Contains the following upstream commits:
- e08038115b
- This commit has already been cherry-picked so it is a NOOP
- 391d5e4a01
- This commit has been replaced by a new commit that was cherry-picked
so it has been converted to a NOOP
- c1861bc8fa