calculate transaction fee in a block
As the block id is known, the fee can be found from the coinbase itself without an overhead. Maintain a simple map for reward points saying blocks between 0-149 gives 50 BTC, next 149 25 etc.

Now, the first transaction in any block is always a coinbase tran. 
Coinbasetran->vout[0] - reward = Fee (actual fee + unclaimed change)