contractcourt: deadlock fix via temporary unmerged map
The main idea is that NotifyContractUpdate adds the ContractUpdate to a map called unmerged. It is populated in Start by shallow-copying the activeHTLCs map values (htlcSet). The htlcSets underlying maps are not copied, and so unmerged will just contain pointers to them. This should be fine since unmerged will not modify them. At the call-sites of activeHTLCs, it is updated to include the unmerged sets. This happens with a mutex and should not cause any data race, even though it is copying the underlying map pointers. No persistence should be necessary since on restart, activeHTLCs and unmerged will just be populated again.
This commit is contained in:
3 files changed
+89
-75
No files matched your search
@@ -1010,7 +1010,8 @@ func (c *ChainArbitrator) NotifyContractUpdate(chanPoint wire.OutPoint,
|
||||
return fmt.Errorf("can't find arbitrator for %v", chanPoint)
|
||||
}
|
||||
|
||||
return arbitrator.notifyContractUpdate(update)
|
||||
arbitrator.notifyContractUpdate(update)
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetChannelArbitrator safely returns the channel arbitrator for a given
|
||||
|
||||
Reference in new issue
Block a user