From 47ac21377957d2ad6b46411ee133ff2426a612c9 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Sun, 12 May 2013 16:55:18 +0200 Subject: [PATCH] adding search method for unconfirmed blocks, add updateConfirmations method for blocks --- public/include/classes/block.class.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/public/include/classes/block.class.php b/public/include/classes/block.class.php index 9ee60596..a540bdb6 100644 --- a/public/include/classes/block.class.php +++ b/public/include/classes/block.class.php @@ -46,6 +46,29 @@ class Block { return false; } + public function getAllUnconfirmed($confirmations='120') { + $stmt = $this->mysqli->prepare("SELECT id, blockhash, confirmations FROM $this->table WHERE confirmations < ?"); + if ($this->checkStmt($stmt)) { + $stmt->bind_param("i", $confirmations); + $stmt->execute(); + $result = $stmt->get_result(); + $stmt->close(); + return $result->fetch_all(MYSQLI_ASSOC); + } + return false; + } + + public function setConfirmations($block_id, $confirmations) { + $stmt = $this->mysqli->prepare("UPDATE $this->table SET confirmations = ? WHERE id = ?"); + if ($this->checkStmt($stmt)) { + $stmt->bind_param("ii", $confirmations, $block_id) or die($stmt->error); + $stmt->execute() or die("Failed"); + $stmt->close(); + return true; + } + return false; + } + public function getAll($order='DESC') { $stmt = $this->mysqli->prepare("SELECT * FROM $this->table ORDER BY height $order"); if ($this->checkStmt($stmt)) {