<p>It's part of the JSON code. An <a href="https://www.json.com/json-array" rel="nofollow">Array</a> is a JSON entity that contains an ordered list of zero or more JSON entities. As its name, "params", suggests, this one contains the parameters to the command. So when you see:</p>

<pre><code>std::string strHash = params[0].get_str();
</code></pre>

<p>That gets the first parameter into a <code>string</code> called <code>strHash</code>. This makes sense since the first (and only) parameter to invalidateblock is a hash, as this help text indicates:</p>

<pre><code>        "invalidateblock \"hash\"\n"
        "\nPermanently marks a block as invalid, as if it violated a consensus rule.\n"
        "\nArguments:\n"
        "1. hash   (string, required) the hash of the block to mark as invalid\n"
        "\nResult:\n"
        "\nExamples:\n"
</code></pre>

CC BY-SA 3.0
2015-05-19T10:55:02.747Z
Thanks! But what's the purpose of "&" after "Array"? I think type modifiers, such as "&", are used in programming to convert a data type into another and obviously Array is being converted into a reference type while it's defined in the "invalidateblock"-function so can I assume that this conversion makes references out of Array's params? And if yes, *what variables* are they references to? What do they have to do with `get_str()`?
Aliakbar Ahmadi
CC BY-SA 3.0
2015-05-19T16:41:55.390Z
@AliakbarAhmadi It sounds like you need to learn C++ and then come back and look at this code.
David Schwartz
CC BY-SA 3.0
2015-05-19T17:10:12.603Z
I know I'm not using the best technical terms but would you give me a hint to understand: why I need to put a "&" after "Array" though - to my limited knowledge - you could leave it away and simply write ‍‍‍`Value invalidateblock(const Array params, bool fHelp)
{...‎‎‏}`? - I found [this](http://www.codeproject.com/Articles/20027/JSON-Spirit-A-C-JSON-Parser-Generator-Implemented) but it's not really helping to understand this problem. But I think get_str() is just putting the hash value as a string to params[0]!?
Aliakbar Ahmadi
CC BY-SA 3.0
2015-05-19T17:16:22.300Z
@AliakbarAhmadi Why do you think you *need* to do that? In this case, the parameter could be passed by value or by reference, but passing by reference is cheaper. Competent C++ coders reflexively pass "complex" classes by reference when that is possible because it avoids copying the value.
David Schwartz
CC BY-SA 3.0
2015-05-19T18:26:03.030Z
David Schwartz, thanks! Finally you gave the answer and I can sleep well :D +1
Aliakbar Ahmadi
CC BY-SA 3.0
2015-05-18T23:09:12.063Z
2015-05-18T23:09:12.063Z
David Schwartz
<p>I'm trying to understand how "invalidateblock"-function works, literally line by line.</p>

<p>Since I'm at basic level in C++, I couldn't explain to myself what's the "&amp;" after "Array" there to achieve though I know of references and pointers and though I've found out that it's a so called "type modifier". Still I'm wondering "Array" is a type just like "int", "char" etc.</p>

<p>Where can I find more information on where Array is defined/explained?What are member functions?</p>

<p>Thanks in advance! </p>

CC BY-SA 3.0
2015-05-18T19:11:17.077Z
I'm voting to close this question as off-topic because this question is not related to Bitcoin specifically and would be better suited for http://stackoverflow.com
cdecker
CC BY-SA 3.0
2015-05-18T20:41:14.717Z
Ok, but I asked it here in order to hear developer's answers or comments who have written the code and are represented in Bitcoi.SE.
Aliakbar Ahmadi
CC BY-SA 3.0
2015-05-18T23:05:02.460Z
Can you provide a link to the particular software your question is about?
David Schwartz
CC BY-SA 3.0
2015-05-19T10:43:39.457Z
@DavidSchwartz: I've been looking at `rpcblockchain.cpp` of bitcoin-0.10.0
Aliakbar Ahmadi
<blockchain><c++>
"Array& params": How to understand "&" after "Array" - type modifer?
Aliakbar Ahmadi
# "Array& params": How to understand "&" after "Array" - type modifer?

(Asked by: username_0 on 2015-05-18)

I'm trying to understand how "invalidateblock"-function works, literally line by line.

Since I'm at basic level in C++, I couldn't explain to myself what's the "&" after "Array" there to achieve though I know of references and pointers and though I've found out that it's a so called "type modifier". Still I'm wondering "Array" is a type just like "int", "char" etc.

Where can I find more information on where Array is defined/explained?What are member functions?

Thanks in advance!

**Tags:** blockchain, c++

> **Comments:**
> **username_1**: I'm voting to close this question as off-topic because this question is not related to Bitcoin specifically and would be better suited for http://stackoverflow.com  
> **username_0**: Ok, but I asked it here in order to hear developer's answers or comments who have written the code and are represented in Bitcoi.SE.  
> **username_2**: Can you provide a link to the particular software your question is about?  
> **username_0**: @DavidSchwartz: I've been looking at `rpcblockchain.cpp` of bitcoin-0.10.0  

---

## 1 answers

### Answer by username_2 on 2015-05-18. Score: 1 | Accepted answer

It's part of the JSON code. An Array is a JSON entity that contains an ordered list of zero or more JSON entities. As its name, "params", suggests, this one contains the parameters to the command. So when you see:
std::string strHash = params[0].get_str();

That gets the first parameter into a string called strHash. This makes sense since the first (and only) parameter to invalidateblock is a hash, as this help text indicates:
        "invalidateblock \"hash\"\n"
        "\nPermanently marks a block as invalid, as if it violated a consensus rule.\n"
        "\nArguments:\n"
        "1. hash   (string, required) the hash of the block to mark as invalid\n"
        "\nResult:\n"
        "\nExamples:\n"

> **Comments:**
> **username_0**: Thanks! But what's the purpose of "&" after "Array"? I think type modifiers, such as "&", are used in programming to convert a data type into another and obviously Array is being converted into a reference type while it's defined in the "invalidateblock"-function so can I assume that this conversion makes references out of Array's params? And if yes, *what variables* are they references to? What do they have to do with `get_str()`?  
> **username_2**: @AliakbarAhmadi It sounds like you need to learn C++ and then come back and look at this code.  
> **username_0**: I know I'm not using the best technical terms but would you give me a hint to understand: why I need to put a "&" after "Array" though - to my limited knowledge - you could leave it away and simply write ‍‍‍`Value invalidateblock(const Array params, bool fHelp) {...‎‎‏}`? - I found [this](http://www.codeproject.com/Articles/20027/JSON-Spirit-A-C-JSON-Parser-Generator-Implemented) but it's not really helping to understand this problem. But I think get_str() is just putting the hash value as a string to params[0]!?  
> **username_2**: @AliakbarAhmadi Why do you think you *need* to do that? In this case, the parameter could be passed by value or by reference, but passing by reference is cheaper. Competent C++ coders reflexively pass "complex" classes by reference when that is possible because it avoids copying the value.  
> **username_0**: username_2, thanks! Finally you gave the answer and I can sleep well :D +1  

---

