Commit 22487532 authored by David Vorick's avatar David Vorick

more conservative locking in contractor

parent 37b104b9
......@@ -173,8 +173,8 @@ func (he *hostEditor) Modify(oldRoot, newRoot crypto.Hash, offset uint64, newDat
// Editor returns a Editor object that can be used to upload, modify, and
// delete sectors on a host.
func (c *Contractor) Editor(id types.FileContractID, cancel <-chan struct{}) (_ Editor, err error) {
c.mu.RLock()
id = c.ResolveID(id)
c.mu.RLock()
cachedEditor, haveEditor := c.editors[id]
height := c.blockHeight
contract, haveContract := c.contracts[id]
......
......@@ -141,14 +141,16 @@ func (w *worker) upload(uw uploadWork) {
w.consecutiveUploadFailures = 0
// Update the renter metadata.
addr := e.Address()
endHeight := e.EndHeight()
id := w.renter.mu.Lock()
uw.file.mu.Lock()
contract, exists := uw.file.contracts[w.contractID]
if !exists {
contract = fileContract{
ID: w.contractID,
IP: e.Address(),
WindowStart: e.EndHeight(),
IP: addr,
WindowStart: endHeight,
}
}
contract.Pieces = append(contract.Pieces, pieceData{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment