github.com/NebulousLabs/Sia@v1.3.7/siatest/renter/dependencies.go (about) 1 package renter 2 3 import ( 4 "github.com/NebulousLabs/Sia/modules" 5 "github.com/NebulousLabs/Sia/siatest" 6 ) 7 8 // dependencyBlockScan blocks the scan progress of the hostdb until Scan is 9 // called on the dependency. 10 type dependencyBlockScan struct { 11 modules.ProductionDependencies 12 closed bool 13 c chan struct{} 14 } 15 16 // Disrupt will block the scan progress of the hostdb. The scan can be started 17 // by calling Scan on the dependency. 18 func (d *dependencyBlockScan) Disrupt(s string) bool { 19 if d.c == nil { 20 d.c = make(chan struct{}) 21 } 22 if s == "BlockScan" { 23 <-d.c 24 } 25 return false 26 } 27 28 // Scan resumes the blocked scan. 29 func (d *dependencyBlockScan) Scan() { 30 if d.closed { 31 return 32 } 33 close(d.c) 34 d.closed = true 35 } 36 37 // newDependencyInterruptDownloadBeforeSendingRevision creates a new dependency 38 // that interrupts the download on the renter side before sending the signed 39 // revision to the host. 40 func newDependencyInterruptDownloadBeforeSendingRevision() *siatest.DependencyInterruptOnceOnKeyword { 41 return siatest.NewDependencyInterruptOnceOnKeyword("InterruptDownloadBeforeSendingRevision") 42 } 43 44 // newDependencyInterruptDownloadAfterSendingRevision creates a new dependency 45 // that interrupts the download on the renter side right after receiving the 46 // signed revision from the host. 47 func newDependencyInterruptDownloadAfterSendingRevision() *siatest.DependencyInterruptOnceOnKeyword { 48 return siatest.NewDependencyInterruptOnceOnKeyword("InterruptDownloadAfterSendingRevision") 49 } 50 51 // newDependencyInterruptUploadBeforeSendingRevision creates a new dependency 52 // that interrupts the upload on the renter side before sending the signed 53 // revision to the host. 54 func newDependencyInterruptUploadBeforeSendingRevision() *siatest.DependencyInterruptOnceOnKeyword { 55 return siatest.NewDependencyInterruptOnceOnKeyword("InterruptUploadBeforeSendingRevision") 56 } 57 58 // newDependencyInterruptUploadAfterSendingRevision creates a new dependency 59 // that interrupts the upload on the renter side right after receiving the 60 // signed revision from the host. 61 func newDependencyInterruptUploadAfterSendingRevision() *siatest.DependencyInterruptOnceOnKeyword { 62 return siatest.NewDependencyInterruptOnceOnKeyword("InterruptUploadAfterSendingRevision") 63 }