github.com/fozzysec/SiaPrime@v0.0.0-20190612043147-66c8e8d11fe3/siatest/renter/dependencies.go (about)

     1  package renter
     2  
     3  import (
     4  	"SiaPrime/modules"
     5  	"SiaPrime/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  // newDependencyInterruptContractSaveToDiskAfterDeletion creates a new
    38  // dependency that interrupts the contract being saved to disk after being
    39  // removed from static contracts
    40  func newDependencyInterruptContractSaveToDiskAfterDeletion() *siatest.DependencyInterruptOnceOnKeyword {
    41  	return siatest.NewDependencyInterruptOnceOnKeyword("InterruptContractSaveToDiskAfterDeletion")
    42  }
    43  
    44  // newDependencyInterruptDownloadBeforeSendingRevision creates a new dependency
    45  // that interrupts the download on the renter side before sending the signed
    46  // revision to the host.
    47  func newDependencyInterruptDownloadBeforeSendingRevision() *siatest.DependencyInterruptOnceOnKeyword {
    48  	return siatest.NewDependencyInterruptOnceOnKeyword("InterruptDownloadBeforeSendingRevision")
    49  }
    50  
    51  // newDependencyInterruptDownloadAfterSendingRevision creates a new dependency
    52  // that interrupts the download on the renter side right after receiving the
    53  // signed revision from the host.
    54  func newDependencyInterruptDownloadAfterSendingRevision() *siatest.DependencyInterruptOnceOnKeyword {
    55  	return siatest.NewDependencyInterruptOnceOnKeyword("InterruptDownloadAfterSendingRevision")
    56  }
    57  
    58  // newDependencyInterruptUploadBeforeSendingRevision creates a new dependency
    59  // that interrupts the upload on the renter side before sending the signed
    60  // revision to the host.
    61  func newDependencyInterruptUploadBeforeSendingRevision() *siatest.DependencyInterruptOnceOnKeyword {
    62  	return siatest.NewDependencyInterruptOnceOnKeyword("InterruptUploadBeforeSendingRevision")
    63  }
    64  
    65  // newDependencyInterruptUploadAfterSendingRevision creates a new dependency
    66  // that interrupts the upload on the renter side right after receiving the
    67  // signed revision from the host.
    68  func newDependencyInterruptUploadAfterSendingRevision() *siatest.DependencyInterruptOnceOnKeyword {
    69  	return siatest.NewDependencyInterruptOnceOnKeyword("InterruptUploadAfterSendingRevision")
    70  }