[#index_util-CopyHeightIndexToHashIndex]
= xref:index_util.adoc[index&lowbar;util]::CopyHeightIndexToHashIndex
:relfileprefix: ../
:mrdocs:

Copy an index entry from the height index to the hash index&period;

== Synopsis

Declared in `&lt;index&sol;db&lowbar;key&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;typename DBVal&gt;
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
static
bool
CopyHeightIndexToHashIndex(
    xref:CDBIterator.adoc[CDBIterator]& db&lowbar;it,
    xref:CDBBatch.adoc[CDBBatch]& batch,
    std::string const& index&lowbar;name,
    int height);
----

== Description

Used during a reorg so entries for blocks no longer on the main chain remain queryable by hash&period;

== Return Value

True on success, false if the expected entry could not be read&period;

[NOTE]
====
The return value https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^].
====
== Template Parameters

[cols="1,4"]
|===
| Name| Description
| *DBVal*
| Type of the value stored for the entry&period;
|===

== Parameters

[cols="1,4"]
|===
| Name| Description
| *db&lowbar;it*
| Iterator positioned to read the height&hyphen;indexed entry&period;
| *batch*
| Write batch that the hash&hyphen;indexed copy is added to&period;
| *index&lowbar;name*
| Name of the index, used for error logging&period;
| *height*
| Block height of the entry to copy&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
