Each block commits to the previous block in the block header by including the previous block's hash. A block's hash is defined as the output of hashing the block header, and for a block to be valid, this hash must fulfill the current difficulty requirement. While blocks can have more than one child block, the Bitcoin network finally agrees on just one best chain. In the best chain there is only one block at each height, so while blocks can have multiple child blocks, only one of them will be relevant in the longterm.
Therefore normally previous hash of B is correct, but previous hash of A should be changed to the hash of B.
Firstly, changing even a single bit in the block header will cause the hash of the block header to come out differently (see e.g. Mastering Bitcoin (Ch8, section "Mining the Block")). It's astronomically unlikely that the new hash also fulfills the difficulty statement. Therefore, the modified block header would no longer represent a valid block.
Secondly, given that A and B were drawing on the same set of unconfirmed transactions when they were found, it's extremely likely that the transactions included in the blocks for confirmation have some overlap. However, each transaction can only be included in one block, because each transaction output can only be spent once, and therefore the inputs of a transaction that was already confirmed are no longer available in a later block. It follows that A would likely include invalid transactions if it were following B.
So, once both A and B were found, and both have each independently committed to block L as their predecessor as well as including some of the same transactions, the blocks A and B are competing to be part of the best chain and exclusive to each other.
I am working on arduino device for health care, that it cannot synch it self every time with main ledger. Because of that, Arduino just sing the data and send it without previous hash to the server. And my server as a miner verify the signature and add the hash of last block as previous hash.
My solution is not proper for shared ledger, but because I am using individual ledger for each member there shouldn't be any conflict between transaction and member data
– masoud2011 Dec 18 '19 at 12:58