Esempio n. 1
0
def checkpropose():
	global flag
	for i in range(block.block('None').max_trans_num) :
		if createnode.i_am.currentblock.translist[i] == None:
			print False
			#flag= False
			break
		
		# else we need to propose the current block after solving proof of work
		proof_of_work.proofofwork(createnode.i_am.currentblock)	
		#print "Proof of work has been solved!"
		# convert the current block to file
		block.blocktofile(createnode.i_am.currentblock,blocktopropose)
		#flag= True
		print True
t.outlist[1].addr = createnode.teacher5publickey

createnode.i_am.currentblock.add_trans_to_block(t)

#####################
for i in range(block.MAXTRANS) :
	if createnode.i_am.currentblock.translist[i].hash == None:
		print ""
		print "not yet...."
		break
# else we need to propose the current block after solving proof of work
proof_of_work.proofofwork(createnode.i_am.currentblock)	
print ""
print "Proof of work has been solved!"
# convert the current block to file
block.blocktofile(createnode.i_am.currentblock,"blocktopropose.txt")
print ""
print "Current block is ready to be proposed!"
#####################

# to attach the block to the blockchain
treestruct.addblock(createnode.i_am.currentblock, createnode.i_am)

'''
t = transaction.transaction(1,2)
t.sign = "teacher1sign"
t.hash = 12360
t.inlist[0].hash = "12350"
t.inlist[0].n = 0
t.inlist[0].sign = "signghf"
t.inlist[0].pub = createnode.student5publickey