Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13115058
D3755.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D3755.diff
View Options
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -816,6 +816,25 @@
return blockheaderToJSON(chainActive.Tip(), pblockindex);
}
+static CBlock GetBlockChecked(const Config &config,
+ const CBlockIndex *pblockindex) {
+ CBlock block;
+ if (fHavePruned && !pblockindex->nStatus.hasData() &&
+ pblockindex->nTx > 0) {
+ throw JSONRPCError(RPC_MISC_ERROR, "Block not available (pruned data)");
+ }
+
+ if (!ReadBlockFromDisk(block, pblockindex, config)) {
+ // Block not found on disk. This could be because we have the block
+ // header in our index but don't have the block (for example if a
+ // non-whitelisted node sends us an unrequested long chain of valid
+ // blocks, we add the headers to our index, but don't accept the block).
+ throw JSONRPCError(RPC_MISC_ERROR, "Block not found on disk");
+ }
+
+ return block;
+}
+
static UniValue getblock(const Config &config, const JSONRPCRequest &request) {
if (request.fHelp || request.params.size() < 1 ||
request.params.size() > 2) {
@@ -901,19 +920,7 @@
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
}
- CBlock block;
- if (fHavePruned && !pblockindex->nStatus.hasData() &&
- pblockindex->nTx > 0) {
- throw JSONRPCError(RPC_MISC_ERROR, "Block not available (pruned data)");
- }
-
- if (!ReadBlockFromDisk(block, pblockindex, config)) {
- // Block not found on disk. This could be because we have the block
- // header in our index but don't have the block (for example if a
- // non-whitelisted node sends us an unrequested long chain of valid
- // blocks, we add the headers to our index, but don't accept the block).
- throw JSONRPCError(RPC_MISC_ERROR, "Block not found on disk");
- }
+ const CBlock block = GetBlockChecked(config, pblockindex);
if (verbosity <= 0) {
CDataStream ssBlock(SER_NETWORK,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 1, 09:31 (1 m, 28 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5187210
Default Alt Text
D3755.diff (2 KB)
Attached To
D3755: Refactor: RPC: Separate GetBlockChecked() from getblock()
Event Timeline
Log In to Comment