async function respond (res: http.ServerResponse, data: Buffer[]): Promise<void> {
let statusCode: number = 500
let headers: http.OutgoingHttpHeaders = { 'Content-Type': 'application/json' }
- let response: string = 'work_validate failed'
+ let response: string = 'request failed'
try {
const datastring = Buffer.concat(data).toString().replace(/\s+/g, '')
if (Buffer.byteLength(datastring) > MAX_BODY_SIZE) {
if (action !== 'work_generate' && action !== 'work_validate') {
throw new Error('Invalid action. Must be work_generate or work_validate.')
}
+ response = `${action} failed`
if (!/^[0-9A-Fa-f]{64}$/.test(hash ?? '')) {
throw new Error('Invalid hash. Must be a 64-character hex string.')
}
if (action === 'work_validate' && !/^[0-9A-Fa-f]{16}$/.test(work ?? '')) {
throw new Error('Invalid work. Must be a 16-character hex string.')
}
- response = `${action} failed`
const options: NanoPowOptions = {
debug: CONFIG.DEBUG,
effort: CONFIG.EFFORT,