Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renamed Raiblocks to Nano on every words #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions RaiBlocks.php → Nano.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
18 changes: 9 additions & 9 deletions RaiBlocksBlock.php → NanoBlock.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
require_once 'RaiBlocks.php';
require_once 'Nano.php';

class RaiBlocksBlock extends RaiBlocks
class NanoBlock extends Nano
{

private $type;
Expand Down Expand Up @@ -91,7 +91,7 @@ public function send($previous, $destination, $balance)
throw new InvalidBlockHashException('Previous block hash is not valid.');
$pk = self::keyFromAccount($destination);
if($pk === false)
throw new InvalidRaiBlocksAccountException('Destination account is not valid');
throw new InvalidNanoAccountException('Destination account is not valid');
if(!is_numeric($balance) || $balance < 0)
throw new InvalidBalanceException('Balance should be an integer greater than 0');

Expand Down Expand Up @@ -121,9 +121,9 @@ public function open($source, $account, $representative)
$a_pk = self::keyFromAccount($account);
$r_pk = self::keyFromAccount($representative);
if($a_pk === false)
throw new InvalidRaiBlocksAccountException('Open account is not valid');
throw new InvalidNanoAccountException('Open account is not valid');
if($r_pk === false)
throw new InvalidRaiBlocksAccountException('Representative account is not valid');
throw new InvalidNanoAccountException('Representative account is not valid');


$this->source = Uint::fromHex($source);
Expand All @@ -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";
Expand Down Expand Up @@ -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;
}

Expand All @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions RaiBlocksExceptions.php → NanoExceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
4 changes: 2 additions & 2 deletions Tests/blocks.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php


require dirname(__DIR__) . '/RaiBlocksBlock.php';
require dirname(__DIR__) . '/NanoBlock.php';

$block = new RaiBlocksBlock();
$block = new NanoBlock();

$block->send(
$previous='1967EA3553D6CEA90987D6C2CD5F101278823F497DA5527A6E1C0F2F3E5BF801',
Expand Down