code: func loadBlockDB() (database.DB, error) {
  	// The database name is based on the database type.
  	dbName := blockDbNamePrefix + "_" + cfg.DbType
  	dbPath := filepath.Join(cfg.DataDir, dbName)
  
  	log.Infof("Loading block database from '%s'", dbPath)
  	db, err := database.Open(cfg.DbType, dbPath, activeNetParams.Net)
  	if err != nil {
  		// Return the error if it's not because the database doesn't
  		// exist.
  		if dbErr, ok := err.(database.Error); !ok || dbErr.ErrorCode !=
  			database.ErrDbDoesNotExist {
  
  			return nil, err
  		}
  
  		// Create the db if it does not exist.
  		err = os.MkdirAll(cfg.DataDir, 0700)
  		if err != nil {
  			return nil, err
  		}
  		db, err = database.Create(cfg.DbType, dbPath, activeNetParams.Net)
  		if err != nil {
  			return nil, err
  		}
  	}
  
  	log.Info("Block database loaded")
  	return db, nil
  }
docs: // loadBlockDB opens the block database and returns a handle to it.