Esempio n. 1
0
	def insertInput(self, input_):
		"""Inserts an input into the database.

		Does not commit database modification.
		@param input_ Input object.
		"""
		query = '	INSERT INTO inputs (transaction_id, transaction_hash, transaction_index, coinbase, sequence_number, script) \
					VALUES (%s, %s, %s, %s, %s, %s)'
		self.executeQuery(query, (\
					self.lastId, \
					binaryRead.strToHex(input_.transactionHash), \
					binaryRead.uIntToStr(input_.transactionIndex), \
					input_.isCoinbase, \
					binaryRead.uIntToStr(input_.sequenceNumber), \
					binaryRead.strToHex(input_.scriptData)))
Esempio n. 2
0
	def insertBlock(self, block):
		"""Inserts a block into the database.

		Does not commit database modification.
		@param block Block object.
		"""
		query = '	INSERT INTO blocks (id, magic_id, length, version, previous_block_hash, merkle_root, target_difficulty, nonce, block_hash, file_name, real_size, block_timestamp) \
					VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)'
		self.executeQuery(query, (\
					str(block.blockNumber), \
					binaryRead.strToHex(block.blockHeader.magicID), \
					binaryRead.uIntToStr(block.blockHeader.length), \
					binaryRead.uIntToStr(block.blockHeader.version), \
					binaryRead.strToHex(block.blockHeader.previousBlockHash), \
					binaryRead.strToHex(block.blockHeader.merkleRoot), \
					binaryRead.uIntToStr(block.blockHeader.targetDifficulty), \
					binaryRead.uIntToStr(block.blockHeader.nonce), \
					block.blockHeader.blockHash, \
					block.fileName, \
					block.realSize, \
					binaryRead.binaryToTime(block.blockHeader.timestamp)))
Esempio n. 3
0
	def insertOutput(self, output):
		"""Inserts a output into the database.

		Does not commit database modification.
		@param output Output object.
		"""
		query = '	INSERT INTO outputs (transaction_id, value, address, script, index) \
					VALUES (%s, %s, %s, %s, %s)'
		self.executeQuery(query, (\
					self.lastId, \
					binaryRead.uLongLongToStr(output.value), \
					output.outputAddress, \
					binaryRead.strToHex(output.outputScript), \
					output.outputIndex))