isValidChain 함수 만들기

969·2022년 1월 3일
0

checkVaildBlock.js 에 이어서

function isValidChain(newBlocks){
	if(JSON.stringify(newBlocks[0]) !== JSON.stringify(Blocks[0])){
		return false;
	}
	var tempBlocks = [newBlocks[0]];
	
	for(var i = 1; i< newBlocks.length; i++){
		if(isValidNewBlock(newBlock[i], tempBlocks[i-1])){
			tempBlocks.push(newBlocks[i]);

		}
		else {
			return false;
		}
	}
	return true;
	
}

0개의 댓글

관련 채용 정보