According to my understanding, transient forks (also known as sidechains in geth's source code) are discarded or overwritten when a reorganization happens.
But before that, when the node detects a fork (i.e. two different blocks with the same blockNumber), it stores the chain it received from other nodes as a sidechain and then compares it with the one it currently has to decide which is the canonical chain based on the total difficulty.
My goal is to extract the chain that is not considered as the canonical chain (i.e transient fork) before it gets overwritten or discarded by the node.
I would like to know if this is possible and if there is a way to do it using APIs or I should modify the source code.
Finally, is there any references or guidance that explains the workflow of the geth's source code or geth's components?