mirror of
https://github.com/XTXMarkets/ternfs.git
synced 2026-05-07 21:01:48 -05:00
ternblocks: refactor to use blockservice package
This commit is contained in:
@@ -273,7 +273,7 @@ type BlockServiceOpts struct {
|
||||
StorageClasses []msgs.StorageClass
|
||||
FailureDomain string
|
||||
Location msgs.Location
|
||||
FutureCutoff *time.Duration
|
||||
EraseCutoff *time.Duration
|
||||
LogLevel log.LogLevel
|
||||
RegistryAddress string
|
||||
Profile bool
|
||||
@@ -300,8 +300,8 @@ func (procs *ManagedProcesses) StartBlockService(ll *log.Logger, opts *BlockServ
|
||||
if opts.Addr2 != "" {
|
||||
args = append(args, "-addr", opts.Addr2)
|
||||
}
|
||||
if opts.FutureCutoff != nil {
|
||||
args = append(args, "-future-cutoff", opts.FutureCutoff.String())
|
||||
if opts.EraseCutoff != nil {
|
||||
args = append(args, "-erase-cutoff", opts.EraseCutoff.String())
|
||||
}
|
||||
if opts.LogLevel == log.DEBUG {
|
||||
args = append(args, "-verbose")
|
||||
|
||||
@@ -48,6 +48,7 @@ type BlockServiceOptions struct {
|
||||
MaxConcurrentReads int
|
||||
FutureCutoff time.Duration
|
||||
PastCutoff time.Duration
|
||||
EraseCutoff time.Duration
|
||||
ReservedCapacityBytes uint64
|
||||
}
|
||||
|
||||
@@ -454,10 +455,10 @@ func (b *BlockService) EraseBlock(blockId msgs.BlockId, cert [8]byte) ([8]byte,
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
pastCutoff := now.Add(-b.options.PastCutoff)
|
||||
eraseCutoff := now.Add(-b.options.EraseCutoff)
|
||||
blockTime := msgs.TernTime(uint64(blockId)).Time()
|
||||
|
||||
if blockTime.After(pastCutoff) {
|
||||
if blockTime.After(eraseCutoff) {
|
||||
return proof, msgs.BLOCK_TOO_RECENT_FOR_DELETION
|
||||
}
|
||||
|
||||
@@ -468,7 +469,7 @@ func (b *BlockService) EraseBlock(blockId msgs.BlockId, cert [8]byte) ([8]byte,
|
||||
blockPath := path.Join(b.localPath, blockId.Path())
|
||||
b.logger.Debug("deleting block %v at path %v", blockId, blockPath)
|
||||
err := eraseFileIfExistsAndSyncDir(blockPath)
|
||||
if err != nil {
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
atomic.AddUint64(&b.IoErrors, 1)
|
||||
return proof, err
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ func createTestService(t *testing.T) *BlockService {
|
||||
BufferSize: 1024 * 1024,
|
||||
FutureCutoff: time.Minute,
|
||||
PastCutoff: time.Minute,
|
||||
EraseCutoff: time.Minute,
|
||||
}, pool, bsInfo, "dev1")
|
||||
|
||||
deadline := time.Now().Add(5 * time.Second)
|
||||
|
||||
+326
-1157
File diff suppressed because it is too large
Load Diff
@@ -884,7 +884,7 @@ func (bsv *blockServiceVictim) start(
|
||||
FailureDomain: bsv.failureDomain,
|
||||
LogLevel: log.Level(),
|
||||
RegistryAddress: fmt.Sprintf("127.0.0.1:%d", registryPort),
|
||||
FutureCutoff: &testBlockFutureCutoff,
|
||||
EraseCutoff: &testBlockEraseCutoff,
|
||||
Addr1: fmt.Sprintf("127.0.0.1:%d", port1),
|
||||
Addr2: fmt.Sprintf("127.0.0.1:%d", port2),
|
||||
Profile: profile,
|
||||
@@ -1042,7 +1042,7 @@ func newTestClient(log *log.Logger, registryAddress string, counters *client.Cli
|
||||
// 0 interval won't do, because otherwise transient files will immediately be
|
||||
// expired and not picked.
|
||||
var testTransientDeadlineInterval = 30 * time.Second
|
||||
var testBlockFutureCutoff = testTransientDeadlineInterval / 2
|
||||
var testBlockEraseCutoff = testTransientDeadlineInterval / 2
|
||||
|
||||
func main() {
|
||||
overrides := make(cfgOverrides)
|
||||
|
||||
Reference in New Issue
Block a user