github.com/btcsuite/btcd@v0.24.0/database/ffldb/export.go (about)

     1  // Copyright (c) 2015-2016 The btcsuite developers
     2  // Use of this source code is governed by an ISC
     3  // license that can be found in the LICENSE file.
     4  
     5  package ffldb
     6  
     7  import (
     8  	"github.com/btcsuite/btcd/database"
     9  )
    10  
    11  // TstRunWithMaxBlockFileSize runs the passed function with the maximum allowed
    12  // file size for the database set to the provided value.  The value will be set
    13  // back to the original value upon completion.
    14  //
    15  // Callers should only use this for testing.
    16  func TstRunWithMaxBlockFileSize(idb database.DB, size uint32, fn func()) {
    17  	ffldb := idb.(*db)
    18  	origSize := ffldb.store.maxBlockFileSize
    19  
    20  	ffldb.store.maxBlockFileSize = size
    21  	fn()
    22  	ffldb.store.maxBlockFileSize = origSize
    23  }