@@ -720,7 +720,7 @@ class submitblock_StateCatcher : public CValidationInterface
720
720
721
721
UniValue submitblock (const JSONRPCRequest& request)
722
722
{
723
- if (request.fHelp || request.params .size () < 1 || request.params .size () > 2 )
723
+ if (request.fHelp || request.params .size () < 1 || request.params .size () > 2 ) {
724
724
throw std::runtime_error (
725
725
" submitblock \" hexdata\" ( \" jsonparametersobject\" )\n "
726
726
" \n Attempts to submit new block to network.\n "
@@ -738,11 +738,13 @@ UniValue submitblock(const JSONRPCRequest& request)
738
738
+ HelpExampleCli (" submitblock" , " \" mydata\" " )
739
739
+ HelpExampleRpc (" submitblock" , " \" mydata\" " )
740
740
);
741
+ }
741
742
742
743
std::shared_ptr<CBlock> blockptr = std::make_shared<CBlock>();
743
744
CBlock& block = *blockptr;
744
- if (!DecodeHexBlk (block, request.params [0 ].get_str ()))
745
+ if (!DecodeHexBlk (block, request.params [0 ].get_str ())) {
745
746
throw JSONRPCError (RPC_DESERIALIZATION_ERROR, " Block decode failed" );
747
+ }
746
748
747
749
if (block.vtx .empty () || !block.vtx [0 ]->IsCoinBase ()) {
748
750
throw JSONRPCError (RPC_DESERIALIZATION_ERROR, " Block does not start with a coinbase" );
@@ -755,10 +757,12 @@ UniValue submitblock(const JSONRPCRequest& request)
755
757
BlockMap::iterator mi = mapBlockIndex.find (hash);
756
758
if (mi != mapBlockIndex.end ()) {
757
759
CBlockIndex *pindex = mi->second ;
758
- if (pindex->IsValid (BLOCK_VALID_SCRIPTS))
760
+ if (pindex->IsValid (BLOCK_VALID_SCRIPTS)) {
759
761
return " duplicate" ;
760
- if (pindex->nStatus & BLOCK_FAILED_MASK)
762
+ }
763
+ if (pindex->nStatus & BLOCK_FAILED_MASK) {
761
764
return " duplicate-invalid" ;
765
+ }
762
766
// Otherwise, we might only have the header - process the block before returning
763
767
fBlockPresent = true ;
764
768
}
@@ -776,14 +780,15 @@ UniValue submitblock(const JSONRPCRequest& request)
776
780
RegisterValidationInterface (&sc);
777
781
bool fAccepted = ProcessNewBlock (Params (), blockptr, true , NULL );
778
782
UnregisterValidationInterface (&sc);
779
- if (fBlockPresent )
780
- {
781
- if (fAccepted && !sc.found )
783
+ if (fBlockPresent ) {
784
+ if (fAccepted && !sc.found ) {
782
785
return " duplicate-inconclusive" ;
786
+ }
783
787
return " duplicate" ;
784
788
}
785
- if (!sc.found )
789
+ if (!sc.found ) {
786
790
return " inconclusive" ;
791
+ }
787
792
return BIP22ValidationResult (sc.state );
788
793
}
789
794
0 commit comments