node_modules/ocore/light.js
// fixes is_spent in case units were received out of order
fixes is_spent in case units were received out of order
fixes is_spent in case units were received out of order
function fixIsSpentFlag(onDone){
	db.query(
		"SELECT outputs.unit, outputs.message_index, outputs.output_index \n\
		FROM outputs \n\
		CROSS JOIN inputs ON outputs.unit=inputs.src_unit AND outputs.message_index=inputs.src_message_index AND outputs.output_index=inputs.src_output_index \n\
		WHERE is_spent=0 AND type='transfer'",
		function(rows){
			console.log(rows.length+" previous outputs appear to be spent");
			if (rows.length === 0)
				return onDone();
			var arrQueries = [];
			rows.forEach(function(row){
				console.log('fixing is_spent for output', row);
				db.addQuery(arrQueries, 
					"UPDATE outputs SET is_spent=1 WHERE unit=? AND message_index=? AND output_index=?", [row.unit, row.message_index, row.output_index]);
			});
			async.series(arrQueries, onDone);
		}
	);
}
function fixIsSpentFlag ( onDone ) { db . query ( "SELECT outputs.unit, outputs.message_index, outputs.output_index \n\
		FROM outputs \n\
		CROSS JOIN inputs ON outputs.unit=inputs.src_unit AND outputs.message_index=inputs.src_message_index AND outputs.output_index=inputs.src_output_index \n\
		WHERE is_spent=0 AND type='transfer'" , function ( rows ) { console . log ( rows . length + " previous outputs appear to be spent" ) ; if ( rows . length === 0 ) return onDone ( ) ; var arrQueries = [ ] ; rows . forEach ( function ( row ) { console . log ( 'fixing is_spent for output' , row ) ; db . addQuery ( arrQueries , "UPDATE outputs SET is_spent=1 WHERE unit=? AND message_index=? AND output_index=?" , [ row . unit , row . message_index , row . output_index ] ) ; } ) ; async . series ( arrQueries , onDone ) ; } ) ; }
fixes is_spent in case units were received out of order
fixes is_spent in case units were received out of order