From db4fcfb8d08c3f4a7f21b12c46f3938ddad6dd86 Mon Sep 17 00:00:00 2001 From: Bruno Garcia Date: Sat, 30 Jun 2018 17:50:22 -0300 Subject: [PATCH] Renamed Raiblocks to Nano --- RaiBlocks.php => Nano.php | 6 +++--- RaiBlocksBlock.php => NanoBlock.php | 18 +++++++++--------- RaiBlocksExceptions.php => NanoExceptions.php | 4 ++-- Tests/blocks.php | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) rename RaiBlocks.php => Nano.php (95%) rename RaiBlocksBlock.php => NanoBlock.php (92%) rename RaiBlocksExceptions.php => NanoExceptions.php (73%) diff --git a/RaiBlocks.php b/Nano.php similarity index 95% rename from RaiBlocks.php rename to Nano.php index 3191046..58e0418 100644 --- a/RaiBlocks.php +++ b/Nano.php @@ -2,9 +2,9 @@ require 'Salt/autoload.php'; require_once 'util.php'; -require 'RaiBlocksExceptions.php'; +require 'NanoExceptions.php'; -class RaiBlocks +class Nano { const MAGIC_NUMBER = "5243"; // 0x52 0x43 const VERSION_MAX = "01"; // 0x01 @@ -86,7 +86,7 @@ public static function keyFromAccount($acc) public static function accountFromKey($pk) { if(!preg_match('/[0-9A-F]{64}/i', $pk)) - throw new InvalidRaiBlocksKeyException("Key should be a 32 byte hex string"); + throw new InvalidNanoKeyException("Key should be a 32 byte hex string"); $key = Uint::fromHex($pk); $checksum; diff --git a/RaiBlocksBlock.php b/NanoBlock.php similarity index 92% rename from RaiBlocksBlock.php rename to NanoBlock.php index 89d0e35..dbf6373 100644 --- a/RaiBlocksBlock.php +++ b/NanoBlock.php @@ -1,7 +1,7 @@ source = Uint::fromHex($source); @@ -141,7 +141,7 @@ public function change($previous, $representative) $pk = self::keyFromAccount($representative); if($pk === false) - throw new InvalidRaiBlocksAccountException('Representative account is not valid'); + throw new InvalidNanoAccountException('Representative account is not valid'); $this->previous = Uint::fromHex($previous); $this->representative = Uint::fromHex($pk); $this->type = "change"; @@ -180,8 +180,8 @@ public static function checkWork($hash, $work) public function setAccount($xrb_account) { - if(!RaiBlocks::keyFromAccount($xrb_account)) - throw new InvalidRaiBlocksAccountException(); + if(!Nano::keyFromAccount($xrb_account)) + throw new InvalidNanoAccountException(); $this->owner_account = $xrb_account; } @@ -203,7 +203,7 @@ public function setSignature($sig) if(!$this->hash) throw new IncompleteBlockException("Block hash is missing."); - if(!RaiBlocks::checkSig($this->hash->toHexString(), $sig, $this->owner_account)) + if(!Nano::checkSig($this->hash->toHexString(), $sig, $this->owner_account)) throw new InvalidSignatureException(); $this->signature = Uint::fromHex($sig); } diff --git a/RaiBlocksExceptions.php b/NanoExceptions.php similarity index 73% rename from RaiBlocksExceptions.php rename to NanoExceptions.php index 4591d5a..b61090d 100644 --- a/RaiBlocksExceptions.php +++ b/NanoExceptions.php @@ -3,8 +3,8 @@ class InvalidBlockTypeException extends Exception{} class IncompleteBlockException extends Exception{} class InsufficientWorkException extends Exception{} -class InvalidRaiBlocksAccountException extends Exception{} -class InvalidRaiBlocksKeyException extends Exception{} +class InvalidNanoAccountException extends Exception{} +class InvalidNanoKeyException extends Exception{} class InvalidSignatureException extends Exception{} class InvalidBlockHashException extends Exception{} class InvalidBalanceException extends Exception{} \ No newline at end of file diff --git a/Tests/blocks.php b/Tests/blocks.php index 7e5795e..3cdeb7b 100644 --- a/Tests/blocks.php +++ b/Tests/blocks.php @@ -1,9 +1,9 @@ send( $previous='1967EA3553D6CEA90987D6C2CD5F101278823F497DA5527A6E1C0F2F3E5BF801',