validation.js
function validateSkiplist(conn, arrSkiplistUnits, callback){
	var prev = "";
	async.eachSeries(
		arrSkiplistUnits,
		function(skiplist_unit, cb){
			//if (skiplist_unit.charAt(0) !== "0")
			//    return cb("skiplist unit doesn't start with 0");
			if (skiplist_unit <= prev)
				return cb(createJointError("skiplist units not ordered"));
			conn.query("SELECT unit, is_stable, is_on_main_chain, main_chain_index FROM units WHERE unit=?", [skiplist_unit], function(rows){
				if (rows.length === 0)
					return cb("skiplist unit "+skiplist_unit+" not found");
				var objSkiplistUnitProps = rows[0];
				// if not stable, can't check that it is on MC as MC is not stable in its area yet
				if (objSkiplistUnitProps.is_stable === 1){
					if (objSkiplistUnitProps.is_on_main_chain !== 1)
						return cb("skiplist unit "+skiplist_unit+" is not on MC");
					if (objSkiplistUnitProps.main_chain_index % 10 !== 0)
						return cb("skiplist unit "+skiplist_unit+" MCI is not divisible by 10");
				}
				// we can't verify the choice of skiplist unit.
				// If we try to find a skiplist unit now, we might find something matching on unstable part of MC.
				// Again, we have another check when we reach stability
				cb();
			});
		},
		callback
	);
}
function validateSkiplist(conn, arrSkiplistUnits, callback){
	var prev = "";
	async.eachSeries(
		arrSkiplistUnits,
		function(skiplist_unit, cb){
			//if (skiplist_unit.charAt(0) !== "0")
			//    return cb("skiplist unit doesn't start with 0");
			if (skiplist_unit <= prev)
				return cb(createJointError("skiplist units not ordered"));
			conn.query("SELECT unit, is_stable, is_on_main_chain, main_chain_index FROM units WHERE unit=?", [skiplist_unit], function(rows){
				if (rows.length === 0)
					return cb("skiplist unit "+skiplist_unit+" not found");
				var objSkiplistUnitProps = rows[0];
				// if not stable, can't check that it is on MC as MC is not stable in its area yet
				if (objSkiplistUnitProps.is_stable === 1){
					if (objSkiplistUnitProps.is_on_main_chain !== 1)
						return cb("skiplist unit "+skiplist_unit+" is not on MC");
					if (objSkiplistUnitProps.main_chain_index % 10 !== 0)
						return cb("skiplist unit "+skiplist_unit+" MCI is not divisible by 10");
				}
				// we can't verify the choice of skiplist unit.
				// If we try to find a skiplist unit now, we might find something matching on unstable part of MC.
				// Again, we have another check when we reach stability
				cb();
			});
		},
		callback
	);
}
function validateSkiplist ( conn , arrSkiplistUnits , callback ) { var prev = "" ; async . eachSeries ( arrSkiplistUnits , function ( skiplist_unit , cb ) { //if (skiplist_unit.charAt(0) !== "0") //    return cb("skiplist unit doesn't start with 0"); if ( skiplist_unit <= prev ) return cb ( createJointError ( "skiplist units not ordered" ) ) ; conn . query ( "SELECT unit, is_stable, is_on_main_chain, main_chain_index FROM units WHERE unit=?" , [ skiplist_unit ] , function ( rows ) { if ( rows . length === 0 ) return cb ( "skiplist unit " + skiplist_unit + " not found" ) ; var objSkiplistUnitProps = rows [ 0 ] ; // if not stable, can't check that it is on MC as MC is not stable in its area yet if ( objSkiplistUnitProps . is_stable === 1 ) { if ( objSkiplistUnitProps . is_on_main_chain !== 1 ) return cb ( "skiplist unit " + skiplist_unit + " is not on MC" ) ; if ( objSkiplistUnitProps . main_chain_index % 10 !== 0 ) return cb ( "skiplist unit " + skiplist_unit + " MCI is not divisible by 10" ) ; } // we can't verify the choice of skiplist unit. // If we try to find a skiplist unit now, we might find something matching on unstable part of MC. // Again, we have another check when we reach stability cb ( ) ; } ) ; } , callback ) ; }
we cannot verify that skiplist units lie on MC if they are unstable yet, but if they don't, we'll get unmatching ball hash when the current unit reaches stability
we cannot verify that skiplist units lie on MC if they are unstable yet but if they don t we ll get unmatching ball hash when the current unit reaches stability