Skip to content

Commit 2b09229

Browse files
TinyChain instance docs updated.
1 parent 940750f commit 2b09229

File tree

1 file changed

+109
-2
lines changed

1 file changed

+109
-2
lines changed

docs/TinyChain/Instance.md

Lines changed: 109 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,112 @@ Returns the current length of the chain based on the latest block index.
555555
556556
---
557557
558+
### 📦 `existsLatestBlock()`
559+
560+
**Description:**
561+
Checks whether the latest block in the chain exists.
562+
563+
**Returns:**
564+
565+
* `true` if there is at least one block in the chain, otherwise `false`.
566+
567+
---
568+
569+
### 🔍 `chainBlockIndexExists(index)`
570+
571+
**Description:**
572+
Checks if a block with the given internal chain index exists.
573+
574+
**Parameters:**
575+
576+
* `index`: The internal `bigint` index of the block.
577+
578+
**Returns:**
579+
580+
* `true` if a block with that index exists, otherwise `false`.
581+
582+
---
583+
584+
### 📦 `getChainBlockByIndex(index, hash?)`
585+
586+
**Description:**
587+
Retrieves a block by its internal index and optionally its hash.
588+
589+
**Throws:**
590+
591+
* If `index` is not a `bigint`, or `hash` is not a string (when provided).
592+
* If no matching block is found.
593+
594+
---
595+
596+
### 📦 `chainBlockExists(index)`
597+
598+
**Description:**
599+
Checks if a block exists at a specific array position (0-based).
600+
601+
**Returns:**
602+
603+
* `true` if the array index exists, otherwise `false`.
604+
605+
---
606+
607+
### 🚫 `ignoreChainBlock(index, hash)`
608+
609+
**Description:**
610+
Marks a block as ignored so it won't affect calculations or exports.
611+
612+
**Throws:**
613+
614+
* If `index` is not a `bigint`.
615+
* If `hash` is not a `string`.
616+
* If the block doesn't exist.
617+
618+
---
619+
620+
### 🔄 `unignoreChainBlock(index, hash)`
621+
622+
**Description:**
623+
Unmarks a block as ignored.
624+
625+
**Returns:**
626+
627+
* `true` if the block was ignored and is now restored.
628+
629+
---
630+
631+
### ❓ `isChainBlockIgnored(index, hash)`
632+
633+
**Description:**
634+
Checks if a specific block is currently ignored.
635+
636+
**Returns:**
637+
638+
* `true` if the block is ignored.
639+
640+
---
641+
642+
### ❓ `isChainBlockHashIgnored(hash)`
643+
644+
**Description:**
645+
Checks if any block with the specified hash is ignored.
646+
647+
**Returns:**
648+
649+
* `true` if at least one block with this hash is ignored.
650+
651+
---
652+
653+
### 🧾 `getIgnoredBlocks()`
654+
655+
**Description:**
656+
Returns a shallow clone of all currently ignored blocks.
657+
658+
**Returns:**
659+
660+
* A `Set` of strings in the format `"hash:index"`.
661+
662+
---
663+
558664
### 🔍 `getChainBlock(index)`
559665
560666
**Description:**
@@ -622,7 +728,7 @@ This method removes all blocks from the chain, effectively resetting the blockch
622728
623729
**Description:**
624730
Exports a slice of the blockchain for serialization or transfer.
625-
The method safely extracts and serializes blocks between two indices.
731+
The method safely extracts and serializes blocks between two indices, excluding ignored blocks.
626732
627733
**Parameters:**
628734
@@ -642,7 +748,7 @@ The method safely extracts and serializes blocks between two indices.
642748
### 🔄 `importChain(chain)`
643749
644750
**Description:**
645-
Imports and rebuilds a blockchain from serialized block data.
751+
Imports and rebuilds a blockchain from serialized block data and optionally restores the ignore list.
646752
After import, balances are recalculated and the new chain is validated.
647753
648754
**Emits:**
@@ -652,6 +758,7 @@ After import, balances are recalculated and the new chain is validated.
652758
**Parameters:**
653759
654760
* `chain` (`string[]`): The array of serialized blocks to import.
761+
* `ignoredBlocks` (`Set<string>`): A `Set` of ignored block identifiers (`hash:index`).
655762
656763
**Throws:**
657764

0 commit comments

Comments
 (0)