import fs from "fs" ; import path from "path" ; import { VOTING_KEYSTORE_FILE } from "../validatorDir/paths" ; param dirPath param filenameMatcher export function recursivelyFind ( dirPath , filenameMatcher ) { let filepaths = [ ] ; for ( const filename of fs . readdirSync ( dirPath ) ) { const filepath = path . join ( dirPath , filename ) ; if ( fs . statSync ( filepath ) . isDirectory ( ) ) { filepaths = filepaths . concat ( recursivelyFind ( filepath , filenameMatcher ) ) ; } else if ( filenameMatcher ( filename ) ) { filepaths . push ( filepath ) ; } } return filepaths ; } /**
 * Find voting keystores recursively in `dirPath`
 */ export function recursivelyFindVotingKeystores ( dirPath ) { return recursivelyFind ( dirPath , isVotingKeystore ) ; } /**
 * Returns `true` if we should consider the `filename` to represent a voting keystore.
 */ export function isVotingKeystore ( filename ) { return ( filename . endsWith ( ".json" ) && ( filename === VOTING_KEYSTORE_FILE || /keystore-m_12381_3600_[0-9]+_0_0-[0-9]+.json/ . test ( filename ) ) ) ; } /**
 * Returns true if filename is a BLS Keystore passphrase file
 */ export function isPassphraseFile ( filename ) { return /[0-9A-Fa-f]{96}/ . test ( filename ) ; }