code: func newHeaderStore(db walletdb.DB, filePath string,
  	hType HeaderType) (*headerStore, error) {
  
  	var flatFileName string
  	switch hType {
  	case Block:
  		flatFileName = "block_headers.bin"
  	case RegularFilter:
  		flatFileName = "reg_filter_headers.bin"
  	default:
  		return nil, fmt.Errorf("unrecognized filter type: %v", hType)
  	}
  
  	flatFileName = filepath.Join(filePath, flatFileName)
  
  	// We'll open the file, creating it if necessary and ensuring that all
  	// writes are actually appends to the end of the file.
  	fileFlags := os.O_RDWR | os.O_APPEND | os.O_CREATE
  	headerFile, err := os.OpenFile(flatFileName, fileFlags, 0644)
  	if err != nil {
  		return nil, err
  	}
  
  	// With the file open, we'll then create the header index so we can
  	// have random access into the flat files.
  	index, err := newHeaderIndex(db, hType)
  	if err != nil {
  		return nil, err
  	}
  
  	return &headerStore{
  		filePath:    filePath,
  		file:        headerFile,
  		headerIndex: index,
  	}, nil
  }
docs: // newHeaderStore creates a new headerStore given an already open database, a
  // target file path for the flat-file and a particular header type. The target
  // file will be created as necessary.