light.js
// earlier unit is not included in the chain
earlier unit is not included in the chain
earlier unit is not included in the chain
function createLinkProof(later_unit, earlier_unit, arrChain, cb){
	storage.readJoint(db, later_unit, {
		ifNotFound: function(){
			cb("later unit not found");
		},
		ifFound: function(objLaterJoint){
			var later_mci = objLaterJoint.unit.main_chain_index;
			arrChain.push(objLaterJoint);
			storage.readUnitProps(db, objLaterJoint.unit.last_ball_unit, function(objLaterLastBallUnitProps){
				var later_lb_mci = objLaterLastBallUnitProps.main_chain_index;
				storage.readJoint(db, earlier_unit, {
					ifNotFound: function(){
						cb("earlier unit not found");
					},
					ifFound: function(objEarlierJoint){
						var earlier_mci = objEarlierJoint.unit.main_chain_index;
						var earlier_unit = objEarlierJoint.unit.unit;
						if (later_mci < earlier_mci && later_mci !== null && earlier_mci !== null)
							return cb("not included");
						if (later_lb_mci >= earlier_mci && earlier_mci !== null){ 
							proofChain.buildProofChain(later_lb_mci + 1, earlier_mci, earlier_unit, arrChain, function(){
								cb();
							});
						}
						else{ 
							graph.determineIfIncluded(db, earlier_unit, [later_unit], function(bIncluded){
								if (!bIncluded)
									return cb("not included");
								buildPath(objLaterJoint, objEarlierJoint, arrChain, function(){
									cb();
								});
							});
						}
					}
				});
			});
		}
	});
}
function createLinkProof ( later_unit , earlier_unit , arrChain , cb ) { storage . readJoint ( db , later_unit , { ifNotFound : function ( ) { cb ( "later unit not found" ) ; } , ifFound : function ( objLaterJoint ) { var later_mci = objLaterJoint . unit . main_chain_index ; arrChain . push ( objLaterJoint ) ; storage . readUnitProps ( db , objLaterJoint . unit . last_ball_unit , function ( objLaterLastBallUnitProps ) { var later_lb_mci = objLaterLastBallUnitProps . main_chain_index ; storage . readJoint ( db , earlier_unit , { ifNotFound : function ( ) { cb ( "earlier unit not found" ) ; } , ifFound : function ( objEarlierJoint ) { var earlier_mci = objEarlierJoint . unit . main_chain_index ; var earlier_unit = objEarlierJoint . unit . unit ; if ( later_mci < earlier_mci && later_mci !== null && earlier_mci !== null ) return cb ( "not included" ) ; if ( later_lb_mci >= earlier_mci && earlier_mci !== null ) { proofChain . buildProofChain ( later_lb_mci + 1 , earlier_mci , earlier_unit , arrChain , function ( ) { cb ( ) ; } ) ; } else { graph . determineIfIncluded ( db , earlier_unit , [ later_unit ] , function ( bIncluded ) { if ( ! bIncluded ) return cb ( "not included" ) ; buildPath ( objLaterJoint , objEarlierJoint , arrChain , function ( ) { cb ( ) ; } ) ; } ) ; } } } ) ; } ) ; } } ) ; }
earlier unit is not included in the chain
earlier unit is not included in the chain
// was spent when confirmed // includes the ball of earlier unit // the output was unconfirmed when spent