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
t.outlist[0].value = 4
t.outlist[0].addr = createnode.student5publickey
t.outlist[1].value = 6
t.outlist[1].addr = createnode.student3publickey

result = t.validatetrans(createnode.i_am)
Esempio n. 2
0
t1.outlist = [transaction.outputtrans() for i in range (t1.outcount)]
t1.outlist[0].value = transaction.transaction(0,0).STAR
t1.outlist[0].addr = teacher2publickey
i_am.blockhead.propblock.add_trans_to_block(t1)

t1 = transaction.transaction(0,1)
t1.sign = "signadmin"
t1.hash = "102"
t1.outlist = [transaction.outputtrans() for i in range (t1.outcount)]
t1.outlist[0].value = transaction.transaction(0,0).STAR
t1.outlist[0].addr = teacher3publickey
i_am.blockhead.propblock.add_trans_to_block(t1)

t1 = transaction.transaction(0,1)
t1.sign = "signadmin"
t1.hash = "103"
t1.outlist = [transaction.outputtrans() for i in range (t1.outcount)]
t1.outlist[0].value = transaction.transaction(0,0).STAR
t1.outlist[0].addr = teacher4publickey
i_am.blockhead.propblock.add_trans_to_block(t1)

t1 = transaction.transaction(0,1)
t1.sign = "signadmin"
t1.hash = "104"
t1.outlist = [transaction.outputtrans() for i in range (t1.outcount)]
t1.outlist[0].value = transaction.transaction(0,0).STAR
t1.outlist[0].addr = teacher5publickey
i_am.blockhead.propblock.add_trans_to_block(t1)

treestruct.addblock(i_am.blockhead.propblock, i_am)