• Daniel Martí's avatar
    v2/blockstore: add ReadWrite.Discard · 039ddc7c
    Daniel Martí authored
    This allows closing a read-write blockstore without doing the extra work
    to finalize its header and index. Can be useful if an entire piece of
    work is cancelled, and also simplifies the tests.
    
    Also make ReadOnly error in a straightforward way if it is used after
    being closed. Before, this could lead to panics, as we'd attempt to read
    the CARv1 file when it's closed.
    
    Both mechanisms now use a "closed" boolean, which is consistent and
    simpler than checking a header field.
    
    Finally, add tests that ensure both ReadOnly and ReadWrite behave as
    intended once they have been closed.
    
    The tests also uncovered that AllKeysChan would not release the mutex if
    it encountered an error early on. Fix that, too.
    
    While at it, fix some now-obsolete references to panics on unsupported
    or after-close method calls.
    
    Fixes #205.
    039ddc7c
readonly_test.go 7.66 KB