From 34c9e63a5da1204b6c4e84bfc6a1372f4a5f74ca Mon Sep 17 00:00:00 2001 From: artemuhi Date: Thu, 7 Mar 2024 20:36:43 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9C=D0=B8=D0=BD=D1=83=D1=81=201=20=D1=84?= =?UTF-8?q?=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8F=20=D0=B8=20=D0=BF=D0=BB?= =?UTF-8?q?=D1=8E=D1=81=202=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- artemsbc.php | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/artemsbc.php b/artemsbc.php index 7880044..a303e69 100644 --- a/artemsbc.php +++ b/artemsbc.php @@ -1,17 +1,5 @@ max_size=$max_size; - $bc->file=fopen($filename, "w+"); - if ($lock) { - if (!flock($bc->file, LOCK_EX)) { - return false; - } - } - return $bc; -} -function artembc_createbc($bc, $data=[]) { +function artembc_createbc($filename, $data=[]) { $temp=[[ "id"=>0, "time"=>time(), @@ -19,7 +7,7 @@ function artembc_createbc($bc, $data=[]) { "transaction"=>[] ]]; $temp["hash"]=hash("sha256", json_encode($temp)); - return fwrite($bc->file, json_encode($temp), $bc->max_size); + return artembc_save($filename, $temp); } function artembc_addtransaction() {} function artembc_initblock() {} @@ -27,4 +15,10 @@ function artembc_checkbc() {} function artembc_getblock() {} function artembc_getbc() {} function artembc_getnamebc() {} +function artembc_save($filename, $data) { + return file_put_contents($filename, json_encode($data)); +} +function artembc_load($filename) { + return json_decode(file_get_contents($filename)); +} ?> \ No newline at end of file