Минус 1 функция и плюс 2 функции
This commit is contained in:
parent
0605d565d2
commit
34c9e63a5d
22
artemsbc.php
22
artemsbc.php
@ -1,17 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
class artembc {}
|
function artembc_createbc($filename, $data=[]) {
|
||||||
function artembc_init($filename, $lock=true, $max_size=400094) {
|
|
||||||
$bc=new artembc;
|
|
||||||
$bc->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=[]) {
|
|
||||||
$temp=[[
|
$temp=[[
|
||||||
"id"=>0,
|
"id"=>0,
|
||||||
"time"=>time(),
|
"time"=>time(),
|
||||||
@ -19,7 +7,7 @@ function artembc_createbc($bc, $data=[]) {
|
|||||||
"transaction"=>[]
|
"transaction"=>[]
|
||||||
]];
|
]];
|
||||||
$temp["hash"]=hash("sha256", json_encode($temp));
|
$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_addtransaction() {}
|
||||||
function artembc_initblock() {}
|
function artembc_initblock() {}
|
||||||
@ -27,4 +15,10 @@ function artembc_checkbc() {}
|
|||||||
function artembc_getblock() {}
|
function artembc_getblock() {}
|
||||||
function artembc_getbc() {}
|
function artembc_getbc() {}
|
||||||
function artembc_getnamebc() {}
|
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));
|
||||||
|
}
|
||||||
?>
|
?>
|
Reference in New Issue
Block a user