struct Node and an array of Nodes
allNodes. I was successful in adding
Node to the array but when I tried to use a
removeNode() method (which uses the
delete method in arrays), the value of
allNodes.length remains the same. Is it because blockchains are "immutable". Doesn't immutable mean that when a transaction is made (even
remove Node()), it cannot be undone?
It's possible, but it doesn't do exactly what you (probably) expect.
It signals "no important data here" and helps keep things efficient at the platform level but it doesn't reorganize the array at the application level, by which I mean it doesn't shift all the elements above the deleted row down one row. Length doesn't change.
Immutability has an impact here. No matter what we do, we are only appending to the previous state. Nothing is truly deleted. Even the transactions that created, updated and ultimately deleted the "row" are part of the immutable history. "Delete" can't be about obliterating data, but it might be about reorganizing it.
Have a look over here: Are there well-solved and simple storage patterns for Solidity?
"Mapped Structs with Delete-enabled Index" does a logical delete. It's appropriate for situations where a high percentage of rows will be deleted and you want to avoid looping over garbage.
The much simpler "Mapping with Struct" is more common. It sets a "bit" to indicate a logical delete.
Hope it helps.