Commit Graph

58 Commits

Author SHA1 Message Date
goodfirm
9f93dc1842
chore: fix function names in comment (#2163)
Signed-off-by: goodfirm <fanyishang@yeah.net>
2024-04-10 12:59:42 -04:00
mattn
3cb9f602e8
fix typos (#2100) 2024-03-25 09:44:25 -04:00
theedtron
b66f5b8379
multi: fix ioutil deprecated function
update i/o functions to use os / io package functions instead
2024-03-08 17:41:41 -08:00
vuittont60
048a7ef40b
database: fix typo 2024-01-09 17:12:09 +08:00
Calvin Kim
84bdd0180e ffldb: change export_test.go to export.go
The testing function in export_test.go is changed to just export.go so
that callers outside the ffldb package will be able to call the
function.

The main use for this is so that the prune code can be triggered from
the blockchain package.  This allows testing code to have less than
1.5GB worth of blocks to trigger the prune.
2023-12-16 16:53:17 +09:00
Calvin Kim
d387d162f3 database/ffldb: make PruneBlocks atomic
PruneBlocks used to delete files immediately before the database
transaction finished.  By making the prune atomic, we can guarantee that
the database flush will happen before the utxo cache is flushed,
ensuring that the utxo cache is never in an irrecoverable state.
2023-12-16 16:53:17 +09:00
Calvin Kim
aaedc11887 database, database/ffldb: add BeenPruned() method
This change is part of the effort to add pruning support to btcd.

BeenPruned will return true if the database has ever been pruned.  This
allows for accurate prune status to be reported as well as ux
improvements by disallowing the user to accidently remove or enable
indexes.
2023-08-23 00:46:53 +09:00
Calvin Kim
5c1dd21e79 database/ffldb: Add PruneBlocks to db interface
This change is part of the effort to add pruning support to btcd.

PruneBlocks will prune the earliest block files until it reaches the
given target size.  The returned hashes are the hashes of the blocks
that were pruned.
2023-08-22 15:48:46 +09:00
Calvin Kim
f258d0c8d2 database/ffldb: Change scanBlockFiles behavior
This change is part of the effort to add pruning support to btcd.

scanBlockFiles nows supports scanning files from an arbitrary block
number.  When blocks are pruned, the file number may not start from 0.
To account for this, scanBlockFiles now scans and retreives the start
and the end block file numbers and scans those files.
2023-08-04 17:40:34 +09:00
cui fliter
e160bb6922 multi: remove repetitive the
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-06-26 15:40:51 +08:00
Calvin Kim
ba5407615d multi: Run gofmt on the entire repository
The doc formatting changes introduced in the recent go version is
increasing the diff for all of the new commits.  Formatting it all in
this commit will help the readability of future PRs by reducing the
diff.
2023-06-21 22:31:09 +09:00
Anup Chenthamarakshan
87e3d7e278 Replace github.com/btcsuite/goleveldb with github.com/syndtr/goleveldb 2022-03-08 10:07:52 -08:00
Olaoluwa Osuntokun
caac0f821a
multi: update btcutil imports to point to new sub-module
In this commit, we update all the btcutil imports to point to the new
sub-module.

In the same commit, we also modify the recently added `btcutil/go.mod`
file as we need to continue pointing to the _old_ version of btcd, until
we merge this PR and push a new tag.
2022-01-10 18:44:58 -08:00
Jake Sylvestre
d08785547a docs: update shields 2021-03-05 07:45:19 -05:00
Iskander Sharipov
0886f1e5c1 simplify s[:] to s where s is a slice
Found using https://go-critic.github.io/overview#unslice-ref
2020-11-20 15:43:12 -05:00
ipriver
42782bba18 removed unnecessary GOMAXPROCS function calls 2020-09-14 09:57:30 -04:00
David Hill
f7399e6157 build: clean linter warnings 2020-05-13 08:58:39 -04:00
tpkeeper
8512affc59 readme: remove duplicate word 2020-05-06 08:32:44 -04:00
Murray Nesbitt
9f15a7e6af Alphabetize --help output; add missing options to doc.go 2020-04-14 05:09:43 -05:00
Yash Bhutwala
318c89dfed fix comment of database.Tx to match code 2020-03-04 09:21:27 -05:00
Nisen
0c76fbd26f Fix comment error 2020-03-04 08:40:20 -05:00
Olaoluwa Osuntokun
3d1caa2f83 multi: update to point to roasbeef forks 2018-05-23 16:46:15 -07:00
Jim Posen
ad00e7ff82 database: Stop writing block header data to LevelDB.
Now that all headers are stored in the in-memory index, the database
bucket managed by blockchain, and in the flat files, it makes sense to
drop the redundant data from the block index bucket in ffldb.

To avoid modifying the database interface, this reimplements
FetchBlockHeader(s) to use header data stored in flat files. This can
be trivially implemented by delegating to FetchBlockRegion.
2018-01-28 23:34:56 -06:00
Leonardo Lazzaro
78d12c33f0 database: Update rpcclient link in README.md. 2018-01-25 22:43:53 -06:00
Dave Collins
01cb59c67d
multi: Simplify code per gosimple linter.
This simplifies the code based on the recommendations of the gosimple
lint tool.
2017-07-01 02:25:10 -05:00
Josh Rickmar
a6965d493f all: Remove seelog logger.
The btclog package has been changed to defining its own logging
interface (rather than seelog's) and provides a default implementation
for callers to use.

There are two primary advantages to the new logger implementation.

First, all log messages are created before the call returns.  Compared
to seelog, this prevents data races when mutable variables are logged.

Second, the new logger does not implement any kind of artifical rate
limiting (what seelog refers to as "adaptive logging").  Log messages
are outputted as soon as possible and the application will appear to
perform much better when watching standard output.

Because log rotation is not a feature of the btclog logging
implementation, it is handled by the main package by importing a file
rotation package that provides an io.Reader interface for creating
output to a rotating file output.  The rotator has been configured
with the same defaults that btcd previously used in the seelog config
(10MB file limits with maximum of 3 rolls) but now compresses newly
created roll files.  Due to the high compressibility of log text, the
compressed files typically reduce to around 15-30% of the original
10MB file.
2017-06-19 16:46:50 -04:00
Steven Roose
3d0dfed40b Fix a ton of typos accumulated over time 2017-05-30 16:59:51 +02:00
Dave Collins
9918e2a561
multi: Update markdown files for GFM changes.
The github markdown interpreter has been changed such that it no longer
allows spaces in between the brackets and parenthesis of links and now
requires a newline in between anchors and other formatting.  This
updates all of the markdown files accordingly.

While here, it also corrects a couple of inconsistencies in some of the
README.md files.
2017-05-25 12:06:16 -05:00
Dave Collins
f8673776ab
database: Update overview documentation in doc.go.
This updates the overview documentation to remove reference of the
outside Namespace bits.
2017-05-21 18:22:33 -05:00
David Hill
4f12c97d0f Drop btcsuite/go-flags in favor of upstream 2017-01-09 14:10:18 -06:00
Dave Collins
915fa6639b
multi: Simplify code per gosimple linter.
This simplifies the code based on the recommendations of the gosimple
lint tool.
2016-11-03 13:00:35 -05:00
Dave Collins
af524fb3e7
multi: Remove unnecessary convs found by unconvert.
This removes all unnecessary typecast conversions as found by the
unconvert linter.
2016-11-03 11:59:38 -05:00
Dave Collins
bd4e64d1d4 chainhash: Abstract hash logic to new package. (#729)
This is mostly a backport of some of the same modifications made in
Decred along with a few additional things cleaned up.  In particular,
this updates the code to make use of the new chainhash package.

Also, since this required API changes anyways and the hash algorithm is
no longer tied specifically to SHA, all other functions throughout the
code base which had "Sha" in their name have been changed to Hash so
they are not incorrectly implying the hash algorithm.

The following is an overview of the changes:

- Remove the wire.ShaHash type
- Update all references to wire.ShaHash to the new chainhash.Hash type
- Rename the following functions and update all references:
  - wire.BlockHeader.BlockSha -> BlockHash
  - wire.MsgBlock.BlockSha -> BlockHash
  - wire.MsgBlock.TxShas -> TxHashes
  - wire.MsgTx.TxSha -> TxHash
  - blockchain.ShaHashToBig -> HashToBig
  - peer.ShaFunc -> peer.HashFunc
- Rename all variables that included sha in their name to include hash
  instead
- Update for function name changes in other dependent packages such as
  btcutil
- Update copyright dates on all modified files
- Update glide.lock file to use the required version of btcutil
2016-08-08 14:04:33 -05:00
Dave Collins
b580cdb7d3 database: Replace with new version.
This commit removes the old database package, moves the new package into
its place, and updates all imports accordingly.
2016-04-12 14:55:15 -05:00
Dave Collins
eb882f39f8 multi: Fix several misspellings in the comments.
This commit corrects several typos in the comments found by misspell.
2016-02-25 11:17:12 -06:00
Dave Collins
3942a116e4 docs: Make various README.md files consistent.
First, it removes the documentation section from all the README.md files
and instead puts a web-based godoc badge and link at the top with the
other badges.  This is being done since the local godoc tool no longer
ships with Go by default, so the instructions no longer work without
first installing godoc. Due to this, pretty much everyone uses the
web-based godoc these days anyways.  Anyone who has manually installed
godoc won't need instructions.

Second, it makes sure the ISC license badge is at the top with the other
badges and removes the textual reference in the overview section.

Finally, it's modifies the Installation section to Installation and
Updating and adds a '-u' to the 'go get' command since it works for both
and thus is simpler.
2015-10-23 14:51:36 -05:00
Dario Nieuwenhuis
0190c349aa Add reverse order option to searchrawtransactions rpc 2015-10-08 16:31:39 +02:00
Dario Nieuwenhuis
1806557d14 Fix skip not being applied to mempool txns in searchrawtransactions 2015-09-08 15:17:43 +02:00
Dave Collins
0280fa0264 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 and disk space usage.  However, for now, in order to
avoid having to reserialize a bunch of database information, the heights
are still serialized to the database as 8-byte uint64s.

This is being mainly being done in preparation for further upcoming
infrastructure changes which will use the smaller and more efficient
4-byte serialization in the database as well.
2015-08-11 11:13:17 -05:00
Dave Collins
6e402deb35 Relicense to the btcsuite developers.
This commit relicenses all code in this repository to the btcsuite
developers.
2015-05-01 12:00:56 -05:00
Dave Collins
a4a52ae24f wire: Remove errs from BlockHeader/MsgBlock/MsgTx.
This commit removes the error returns from the BlockHeader.BlockSha,
MsgBlock.BlockSha, and MsgTx.TxSha functions since they can never fail and
end up causing a lot of unneeded error checking throughout the code base.

It also updates all call sites for the change.
2015-04-17 01:27:12 -05:00
Dave Collins
88fd338420 Update tests for btcutil Block.Sha API change. 2015-04-17 00:58:58 -05:00
Dave Collins
750d657666 Update for recent btcutil Block.Sha API change. 2015-04-17 00:44:15 -05:00
Dave Collins
167afc5304 database: Correct test logging found by go vet. 2015-04-09 00:23:40 -05:00
Dave Collins
f5cdf2d6a8 Minor hashing-related optimizations.
This commit contains three classes of optimizations:
 - Reducing the number of unnecessary hash copies
 - Improve the performance of the DoubleSha256 function
 - A couple of minor optimizations of the ShaHash functions

The first class is a result of the Bytes function on a ShaHash making a
copy of the bytes before returning them.  It really should have been named
CloneBytes, but that would break the API now.

To address this, a comment has been added to the function which explicitly
calls out the copy behavior.  In addition, all call sites of .Bytes on a
ShaHash in the code base have been updated to simply slice the array when
a copy is not needed.  This saves a significant amount of data copying.

The second optimization modifies the DoubleSha256 function to directly use
fastsha256.Sum256 instead of the hasher interface.  This reduces the
number of allocations needed.  A benchmark for the function has been added
as well.

old: BenchmarkDoubleSha256  500000   3691 ns/op   192 B/op   3 allocs/op
new: BenchmarkDoubleSha256  500000   3081 ns/op    32 B/op   1 allocs/op

The final optimizations are for the ShaHash IsEqual and SetBytes functions
which have been modified to make use of the fact the type is an array and
remove an unneeded subslice.
2015-04-06 11:33:58 -05:00
Alex Akselrod
7c46f213e1 Fix #340 and DropAfterBlockBySha/NewestSha bug.
- Delete spent TX in setclearSpentData when unspent by block
  disconnect on reorg; return an error when there's more than
  one record to delete in the spent TX as that should never
  happen.

- Test spent TX deletion when reorg causes block disconnect.

- Test for correct NewestSha results after DropAfterBlockBySha.

- Fix DropAfterBlockBySha to update info for NewestSha.

- Updated copyright statements in modified files
2015-03-30 16:35:38 -05:00
Alex Akselrod
ead39153af Fix #303 and #346 and change addrindex sort order
Fix #303 by changing the addrindex key prefix to 3 characters so that
it's easy to check length when dropping the index. To drop the old
index, check to make sure we aren't dropping any entries that end in
"sx" or "tx" as those aren't part of the addrindex. Update test to
deal with the new prefix length.

Fix #346 by changing the pointers in the mempool's addrindex map to
wire.ShaHash 32-byte values. This lets them be deleted even if the
transaction data changes places in memory upon expanding the maps.

Change the way addrindex uint32s are stored to big-endian in order to
sort the transactions on disk in chronological/dependency order.

Change the "searchrawtransactions" RPC call to return transactions
from the database before the memory pool so that they're returned in
order. This commit DOES NOT do topological sorting of the memory pool
transactions to ensure they're returned in dependency order. This may
be a good idea for a future enhancement.

Add addrindex versioning to automatically drop the old/incompatible
version of the index and rebuild with the new sort method and key
prefix.
2015-03-23 13:05:54 -04:00
David Hill
ccc3a9b979 Do a little addrindex database cleanup.
- Use explicit index values for byte slices
- Fix a bug in FetchTxsForAddr that allocated an extra 10 bytes
  for each address index
- Add missing iterator release in error path
- Check for iterator errors.
2015-03-14 22:09:51 -04:00
Dave Collins
e0bb106646 Update golang.org/x/crypto imports to new location (round 2). 2015-03-03 21:25:53 -06:00
Dave Collins
a765bbff5a Update golang.org/x/crypto import paths to new location. 2015-03-03 21:10:38 -06:00