pow/pow.js
function obtainMiningInput( oConn, uRoundIndex, pfnCallback )
{
	if ( ! oConn )
	{
		throw new Error( `call obtainMiningInput with invalid oConn.` );
	}
	if ( 'number' !== typeof uRoundIndex )
	{
		throw new Error( `call obtainMiningInput with invalid nRoundIndex.` );
	}
	if ( 'function' !== typeof pfnCallback )
	{
		//	arguments.callee.name
		throw new Error( `call obtainMiningInput with invalid pfnCallback.` );
	}

	let sCurrentFirstTrustMEBall	= null;
	let uCurrentBitsValue		= null;
	let sCurrentPublicSeed		= null;
	let sSuperNodeAuthorAddress	= null;
	let sDepositAddress		= null;
	let fDepositBalance		= null;

	_async.series
	([
		function( pfnNext )
		{
			//
			//	author address of this super node
			//
			_super_node.readSingleAddress( oConn, function( sAddress )
			{
				sSuperNodeAuthorAddress = sAddress;
				return pfnNext();
			});
		},
		function( pfnNext )
		{
			//
			//	get deposit address by super-node address
			//
			_deposit.getDepositAddressBySupernodeAddress( oConn, sSuperNodeAuthorAddress, ( err, sAddress ) =>
			{
				if ( err )
				{
					return pfnNext( err );
				}

				sDepositAddress	= sAddress;
				return pfnNext();
			});
		},
		function( pfnNext )
		{
			//
			//	get deposit amount by deposit address
			//
			_deposit.getBalanceOfDepositContract( oConn, sDepositAddress, uRoundIndex, ( err, fBanlance ) =>
			{
				if ( err )
				{
					return pfnNext( err );
				}

				fDepositBalance = fBanlance;
				return pfnNext();
			});
		},
		function( pfnNext )
		{
			//
			//	round (N)
			//	obtain ball address of the first TrustME unit from current round
			//
			_round.queryFirstTrustMEBallOnMainChainByRoundIndex( oConn, uRoundIndex, function( err, sBall )
			{
				if ( err )
				{
					return pfnNext( err );
				}

				sCurrentFirstTrustMEBall = sBall;
				return pfnNext();
			});
		},
		function( pfnNext )
		{
			//
			//	round (N)
			//	calculate public seed
			//
			_round.getRoundInfoByRoundIndex( oConn, uRoundIndex, function( round_index, min_wl, sSeed )
			{
				sCurrentPublicSeed = sSeed;
				return pfnNext();
			});
		},
		// function( pfnNext )
		// {
		// 	//
		// 	//	round (N)
		// 	//	calculate bits value
		// 	//
		// 	_round.getDifficultydByRoundIndex( oConn, uRoundIndex, function( nBits )
		// 	{
		// 		nCurrentBitsValue	= nBits;
		// 		return pfnNext();
		// 	});
		// },
		function( pfnNext )
		{
			//
			//	calculate bits value
			//
			calculateBitsValueByRoundIndexWithDeposit
			(
				oConn,
				uRoundIndex,
				fDepositBalance,
				( err, uSelfBits ) =>
				{
					if ( err )
					{
						return pfnCallback( err );
					}

					//	...
					uCurrentBitsValue = uSelfBits;
					return pfnNext();
				}
			);
		}
	], function( err )
	{
		if ( err )
		{
			return pfnCallback( err );
		}

		let objInput	= {
			roundIndex		: uRoundIndex,
			firstTrustMEBall	: sCurrentFirstTrustMEBall,
			bits			: uCurrentBitsValue,
			deposit			: fDepositBalance,
			publicSeed		: sCurrentPublicSeed,
			superNodeAuthor		: sSuperNodeAuthorAddress,
		};
		pfnCallback( null, objInput );
	});

	return true;
}
function obtainMiningInput( oConn, uRoundIndex, pfnCallback )
{
	if ( ! oConn )
	{
		throw new Error( `call obtainMiningInput with invalid oConn.` );
	}
	if ( 'number' !== typeof uRoundIndex )
	{
		throw new Error( `call obtainMiningInput with invalid nRoundIndex.` );
	}
	if ( 'function' !== typeof pfnCallback )
	{
		//	arguments.callee.name
		throw new Error( `call obtainMiningInput with invalid pfnCallback.` );
	}

	let sCurrentFirstTrustMEBall	= null;
	let uCurrentBitsValue		= null;
	let sCurrentPublicSeed		= null;
	let sSuperNodeAuthorAddress	= null;
	let sDepositAddress		= null;
	let fDepositBalance		= null;

	_async.series
	([
		function( pfnNext )
		{
			//
			//	author address of this super node
			//
			_super_node.readSingleAddress( oConn, function( sAddress )
			{
				sSuperNodeAuthorAddress = sAddress;
				return pfnNext();
			});
		},
		function( pfnNext )
		{
			//
			//	get deposit address by super-node address
			//
			_deposit.getDepositAddressBySupernodeAddress( oConn, sSuperNodeAuthorAddress, ( err, sAddress ) =>
			{
				if ( err )
				{
					return pfnNext( err );
				}

				sDepositAddress	= sAddress;
				return pfnNext();
			});
		},
		function( pfnNext )
		{
			//
			//	get deposit amount by deposit address
			//
			_deposit.getBalanceOfDepositContract( oConn, sDepositAddress, uRoundIndex, ( err, fBanlance ) =>
			{
				if ( err )
				{
					return pfnNext( err );
				}

				fDepositBalance = fBanlance;
				return pfnNext();
			});
		},
		function( pfnNext )
		{
			//
			//	round (N)
			//	obtain ball address of the first TrustME unit from current round
			//
			_round.queryFirstTrustMEBallOnMainChainByRoundIndex( oConn, uRoundIndex, function( err, sBall )
			{
				if ( err )
				{
					return pfnNext( err );
				}

				sCurrentFirstTrustMEBall = sBall;
				return pfnNext();
			});
		},
		function( pfnNext )
		{
			//
			//	round (N)
			//	calculate public seed
			//
			_round.getRoundInfoByRoundIndex( oConn, uRoundIndex, function( round_index, min_wl, sSeed )
			{
				sCurrentPublicSeed = sSeed;
				return pfnNext();
			});
		},
		// function( pfnNext )
		// {
		// 	//
		// 	//	round (N)
		// 	//	calculate bits value
		// 	//
		// 	_round.getDifficultydByRoundIndex( oConn, uRoundIndex, function( nBits )
		// 	{
		// 		nCurrentBitsValue	= nBits;
		// 		return pfnNext();
		// 	});
		// },
		function( pfnNext )
		{
			//
			//	calculate bits value
			//
			calculateBitsValueByRoundIndexWithDeposit
			(
				oConn,
				uRoundIndex,
				fDepositBalance,
				( err, uSelfBits ) =>
				{
					if ( err )
					{
						return pfnCallback( err );
					}

					//	...
					uCurrentBitsValue = uSelfBits;
					return pfnNext();
				}
			);
		}
	], function( err )
	{
		if ( err )
		{
			return pfnCallback( err );
		}

		let objInput	= {
			roundIndex		: uRoundIndex,
			firstTrustMEBall	: sCurrentFirstTrustMEBall,
			bits			: uCurrentBitsValue,
			deposit			: fDepositBalance,
			publicSeed		: sCurrentPublicSeed,
			superNodeAuthor		: sSuperNodeAuthorAddress,
		};
		pfnCallback( null, objInput );
	});

	return true;
}
function obtainMiningInput ( oConn , uRoundIndex , pfnCallback ) { if ( ! oConn ) { throw new Error ( ` ` ) ; } if ( 'number' !== typeof uRoundIndex ) { throw new Error ( ` ` ) ; } if ( 'function' !== typeof pfnCallback ) { //	arguments.callee.name throw new Error ( ` ` ) ; } let sCurrentFirstTrustMEBall = null ; let uCurrentBitsValue = null ; let sCurrentPublicSeed = null ; let sSuperNodeAuthorAddress = null ; let sDepositAddress = null ; let fDepositBalance = null ; _async . series ( [ function ( pfnNext ) { // //	author address of this super node // _super_node . readSingleAddress ( oConn , function ( sAddress ) { sSuperNodeAuthorAddress = sAddress ; return pfnNext ( ) ; } ) ; } , function ( pfnNext ) { // //	get deposit address by super-node address // _deposit . getDepositAddressBySupernodeAddress ( oConn , sSuperNodeAuthorAddress , ( err , sAddress ) => { if ( err ) { return pfnNext ( err ) ; } sDepositAddress = sAddress ; return pfnNext ( ) ; } ) ; } , function ( pfnNext ) { // //	get deposit amount by deposit address // _deposit . getBalanceOfDepositContract ( oConn , sDepositAddress , uRoundIndex , ( err , fBanlance ) => { if ( err ) { return pfnNext ( err ) ; } fDepositBalance = fBanlance ; return pfnNext ( ) ; } ) ; } , function ( pfnNext ) { // //	round (N) //	obtain ball address of the first TrustME unit from current round // _round . queryFirstTrustMEBallOnMainChainByRoundIndex ( oConn , uRoundIndex , function ( err , sBall ) { if ( err ) { return pfnNext ( err ) ; } sCurrentFirstTrustMEBall = sBall ; return pfnNext ( ) ; } ) ; } , function ( pfnNext ) { // //	round (N) //	calculate public seed // _round . getRoundInfoByRoundIndex ( oConn , uRoundIndex , function ( round_index , min_wl , sSeed ) { sCurrentPublicSeed = sSeed ; return pfnNext ( ) ; } ) ; } , // function( pfnNext ) // { // 	// // 	//	round (N) // 	//	calculate bits value // 	// // 	_round.getDifficultydByRoundIndex( oConn, uRoundIndex, function( nBits ) // 	{ // 		nCurrentBitsValue	= nBits; // 		return pfnNext(); // 	}); // }, function ( pfnNext ) { // //	calculate bits value // calculateBitsValueByRoundIndexWithDeposit ( oConn , uRoundIndex , fDepositBalance , ( err , uSelfBits ) => { if ( err ) { return pfnCallback ( err ) ; } //	... uCurrentBitsValue = uSelfBits ; return pfnNext ( ) ; } ) ; } ] , function ( err ) { if ( err ) { return pfnCallback ( err ) ; } let objInput = { roundIndex : uRoundIndex , firstTrustMEBall : sCurrentFirstTrustMEBall , bits : uCurrentBitsValue , deposit : fDepositBalance , publicSeed : sCurrentPublicSeed , superNodeAuthor : sSuperNodeAuthorAddress , } ; pfnCallback ( null , objInput ) ; } ) ; return true ; }
obtain mining input

@param	{handle}	oConn
@param	{function}	oConn.query
@param	{number}	uRoundIndex
@param	{function}	pfnCallback( err )
@return {boolean}

@description
start successfully	pfnCallback( null, objInput );
failed to start		pfnCallback( error );
obtain mining input