Closed tianyueli8227 closed 3 months ago
Thank you for your PR. It is intentional that this function can only be called from the root, and also the change you propose will force more allocations. The point is that we do want to pool all the computation together. Allowing this to be called at lower levels would defeat that purpose. So we won't be merging this.
In the original implementation of
collectNonHashedNodes
, the function only works when the internal node is root. Since onlyBatchSerialize
calls this function bynodes, paths = n.collectNonHashedNodes(nodes, paths, nil)
, andBatchSerialize
seems to assume only root will call this function. However, if we want to have any internal node to callBatchSerialize
without losing generality, we should modify thecollectNonHashedNodes
and make it returns correct leave path correspondingly.