Commit Graph

1220 Commits

Author SHA1 Message Date
tomFlowee 6405ff2bad Finish up some metadata details. 2021-03-12 09:35:27 +01:00
tomFlowee bd5baa7133 Add ability to retrieve fees for a transaction.
This adds an option to the GetTransaction Flowee API to return the fees
for a whole transaction.
Support for this is added in the Blockchain (searcher) and the
RestService components.

Notice that no fees will be returned if the BlockMetaData was not
created properly.
2021-03-12 09:06:06 +01:00
tomFlowee 97e2ddbc87 Code meta-replacement tech
Make sure that if we validate a block again (reindex?), we don't create
a new meta object if a perfectly fine one already exists.
2021-03-11 10:22:45 +01:00
tomFlowee a7fd89c360 Make sure we record the lack of fee info. 2021-03-10 20:11:04 +01:00
tomFlowee 2a52ee3fe6 Use meta when available for finding tx.
This implements the getrawtransaction API/RPC calls to now use the meta
object, when available, for much faster finding of a transaction by txid.
2021-03-10 20:11:04 +01:00
tomFlowee 8a846d3a7b Add option -enableblockindex=true
this allows the user to ensure the metadata blocks fetch the previous
transaction in order to calculate the transaction-fee.
Normally this is skipped for transactions we don't need to do the script
validation for (old blocks).
2021-03-10 20:11:04 +01:00
tomFlowee b1daf37b43 Make reindex find the metadata blocks. 2021-03-10 20:11:04 +01:00
tomFlowee a4351c2f95 Write the meta block to disk. 2021-03-10 20:11:04 +01:00
tomFlowee 376a4ef9b5 Make block validation create a block metadata object.
This also changes the raw pointers to unique pointers for undo data.
2021-03-10 20:11:04 +01:00
tomFlowee 2395764bde Start new class BlockMetaData 2021-03-10 20:11:04 +01:00
tomFlowee 0cd6469efa Don't repeat default log section 2021-03-10 18:09:35 +01:00
tomFlowee 07c4922d71 Avoid copy 2021-03-10 18:09:32 +01:00
tomFlowee 51e671fefd Allow eliding by the compiler. 2021-03-08 13:48:33 +01:00
tomFlowee 78a01bb4b7 Take action on a static code checker finding an issue.
[code-quality]
We got a warning about a dereference of a nullptr. But that implied we
have an impossible combination of member variables.
So, lets assert on that being impossible so;
a) we get a fail-fast if this ever happens.
b) the static code checker will stop warning us.

Notice that asserts are compiled out of release executables. So this is
effectively a no-op for releases.
2021-03-08 13:48:30 +01:00
tomFlowee bc945ffaaf Remove silly code. 2021-03-08 13:48:20 +01:00
tomFlowee 018a855e03 Avoid confusion.
People all over the Internet, including on the BCH spec, seem confused
about these enum values. They think they are opcodes.
So lets be clear and rename them to the thing they are. Placeholders or
a return-code.
2021-03-06 14:50:40 +01:00
tomFlowee a2969b1e5d Fix compile with BENCHMARK define on. 2021-03-06 14:44:58 +01:00
tomFlowee b697a17168 Add 'validationOnly' option to API 2021-03-04 15:48:56 +01:00
tomFlowee 630b8422ed Upgrade RPC method to take a blockhash
This also moves the code to search linearly in a block onto the
FastBlock class, for reusal.
2021-03-03 10:17:14 +01:00
tomFlowee 07626a3f3e Fix loading an empty chain 2021-03-03 10:10:57 +01:00
tomFlowee 4d5e7bfb09 Protect node with user-limits for the API.
This introduces several options for public node operators to limit their
nodes usage by 3rd parties, this is aimed at usage of resource-hungry
areas.

We allow limiting the amount of connections any single IP can keep open
with us.
We limit the amount of reconnects we allow in a short number of seconds.
We allow limiting the number of addresses (or scriptHashes) a peer can
register for the node to scan.
The last one is for both the addressMonitorService as well as for the
getBlock filters.

For node operators these items become available using command line
options or config-file options. By default these limits are unlimited as
we assume default usage to be private.
2021-02-26 15:14:14 +01:00
tomFlowee 020c16c27a Put binding info in logfile. 2021-02-26 15:08:23 +01:00
tomFlowee 379e950cde Share code between projects
Move from the rest-server the method returnTemplatePath to the library
and reuse that in the bitcore-proxy client.
2021-02-23 17:55:26 +01:00
tomFlowee 048d5b83a8 make defaults more sane 2021-02-23 17:12:59 +01:00
TomZ b1f8372b10 Improve error messaging for services
We now no longer show the full help page after we've seen a service at
least once. Because we know its not a lack of config that caused the
issue.
2021-02-22 16:31:09 +01:00
TomZ 74be8f9304 Register losing services better
This implements two TODOs, we now unset the services in our registry
when they disconnect.
This allows us to run with multiple backends as failover more stable.
2021-02-22 16:31:09 +01:00
TomZ 3dbb2672b9 Api Docs 2021-02-22 15:53:32 +01:00
TomZ 046c956230 Avoid sideeffects after a move. 2021-02-22 15:52:34 +01:00
TomZ 1de1496350 UX fix for servers
We only have the option for `--debug` when it is regarding a client (as
oppossed to a server) and when we build a debug build.
Only add the option for users to set when we actually process it.
2021-02-22 14:09:19 +01:00
tomFlowee b83fd08789 Add chainReorged msg to BlockNotificationService
When blocks are reverted clients likely want to know. This gives them
the information the moment it becomes clear.
2021-02-19 13:43:56 +01:00
tomFlowee 29082a1066 Follow coding guide; lowercase method names 2021-02-19 13:43:56 +01:00
tomFlowee 9a33788090 Properly expire older items. 2021-02-18 12:03:56 +01:00
tomFlowee 64bfb5d02d Stop using boost ptime
Its overly complex and too difficult to even inspect for debugging.
2021-02-18 10:06:25 +01:00
tomFlowee 950ca2569a Refactor global threadpool usage.
Use C++11 features instead of boost, and force calling the reserve
method in the getter since its too easy to forget reserve otherwise.
2021-02-18 09:59:00 +01:00
tomFlowee abfc90d99a assert -> if 2021-02-17 22:59:35 +01:00
tomFlowee 9c3d7ddaf1 Add net protection for APIServer 2021-02-17 22:49:19 +01:00
tomFlowee 85e089b155 Calculate needed space better
We calculate the needed space for the network buffers before we fill them,
as new features are added guestimating ended up short.
Lets do the real calculation.
2021-02-17 17:11:24 +01:00
tomFlowee 8eeea08f99 Add support for BitcoinScriptHashed filtering
Server already added it before, lets allow more clients to use it.
2021-02-17 17:09:43 +01:00
tomFlowee b6fd629892 Replace boost mutex with std 2021-02-16 22:08:16 +01:00
tomFlowee bf88ee6218 Check inputs better 2021-02-16 19:22:33 +01:00
tomFlowee 08c04b3b25 Assume less and check the inputs better
Should an Tx::Iterator be created on some random data we are now
checking the read values better.
2021-02-16 18:56:13 +01:00
tomFlowee aea317cf71 Be better at handling bad input.
When the transaction offset is wrong and doesn't parse we turn the
generic runtime_exception into one that goes back to the API caller.
Also catch those generic exceptions on the server level to avoid this
kind of error from disconnecting a peer.
2021-02-16 18:36:40 +01:00
tomFlowee afdaff5188 whitespace 2021-02-15 14:09:35 +01:00
tomFlowee 4f37f4ea2f Don't spam 2021-02-12 20:59:41 +01:00
tomFlowee da2a8843ec call addressUsedInOutput callback more
When getting data from the mempool based on address, we also want to call
the addressUsedInOutput() callback, in order to be consistent.

We pass in the blockheight and offset in block being -1, though.
2021-02-11 22:52:17 +01:00
tomFlowee b4df28bd90 Avoid programming errors, add assert. 2021-02-11 15:23:35 +01:00
tomFlowee efa23bd2db Extend Live::GetTransaction to search on address too
This allows API users to search the mempool on address or on txid.

This also adds a new unit test testing this functionality
2021-02-11 15:21:54 +01:00
tomFlowee 47702ad4a4 Port getaddress to be a native call. 2021-02-11 14:15:23 +01:00
tomFlowee 6a2dc97e25 Search harder for logs.conf 2021-02-07 18:07:22 +01:00
tomFlowee d3f1d7f454 Whitepace and minor fixes. 2021-02-05 17:32:36 +01:00