code: func scanBlockFiles(dbPath string) (int, uint32) {
  	lastFile := -1
  	fileLen := uint32(0)
  	for i := 0; ; i++ {
  		filePath := blockFilePath(dbPath, uint32(i))
  		st, err := os.Stat(filePath)
  		if err != nil {
  			break
  		}
  		lastFile = i
  
  		fileLen = uint32(st.Size())
  	}
  
  	log.Tracef("Scan found latest block file #%d with length %d", lastFile,
  		fileLen)
  	return lastFile, fileLen
  }
docs: // scanBlockFiles searches the database directory for all flat block files to
  // find the end of the most recent file.  This position is considered the
  // current write cursor which is also stored in the metadata.  Thus, it is used
  // to detect unexpected shutdowns in the middle of writes so the block files
  // can be reconciled.