Skip to content

Commit

Permalink
first realaase of version 3
Browse files Browse the repository at this point in the history
  • Loading branch information
mlibre committed May 31, 2024
1 parent eebbc26 commit 06c1d6b
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 63 deletions.
4 changes: 2 additions & 2 deletions assets/keys/miner.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"publicKey": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEARZFWSXfMHfZ5WWZeqhznPwKV09wq8Cmg9wkLO+dHDoc=\n-----END PUBLIC KEY-----\n",
"privateKey": "-----BEGIN PRIVATE KEY-----\nMC4CAQAwBQYDK2VwBCIEIA7c9FpfySYc+gvaORHZ43oFuacwzayoK5qCRvBAl7kB\n-----END PRIVATE KEY-----\n"
"publicKey": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAQuJ8hp9ntC2z/q+i9TA60NzxLf5JGbSax76JWr+vp8A=\n-----END PUBLIC KEY-----\n",
"privateKey": "-----BEGIN PRIVATE KEY-----\nMC4CAQAwBQYDK2VwBCIEIG1YwIi76G+K6C0HKg+lH+Q69k03Kp/D8bKXcX6OYuq1\n-----END PRIVATE KEY-----\n"
}
4 changes: 2 additions & 2 deletions assets/keys/user.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"publicKey": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEABMxC5bHBMsrZbx2G2mr2Jz+YDJor2JOBIkHoVV/0Wfg=\n-----END PUBLIC KEY-----\n",
"privateKey": "-----BEGIN PRIVATE KEY-----\nMC4CAQAwBQYDK2VwBCIEIERQntg1KdePgNTwvk6smrg2WJtcRCpNvCPsuxqCPFkn\n-----END PRIVATE KEY-----\n"
"publicKey": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEABYuR9ZVr8WRemSZX6RaTlXFmzMZ8Erx3OKsxGi3alXk=\n-----END PUBLIC KEY-----\n",
"privateKey": "-----BEGIN PRIVATE KEY-----\nMC4CAQAwBQYDK2VwBCIEIMYnQt+xnEA8Iy8BYdxkBSahcWZ7mc0bb9HIZkdXCnWQ\n-----END PRIVATE KEY-----\n"
}
10 changes: 5 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# GoodChain

Welcome to **GoodChain**, a blockchain platform designed for both beginners and experienced users, seeking simplicity and flexibility. Built with `TypeScript` and `LevelDB (soon)`, **GoodChain** offers a customizable environment for experimenting with consensus algorithms, including a default Simple **Proof-of-Work (PoW)** option.
Welcome to **GoodChain**, a blockchain platform designed for both beginners and experienced users, seeking simplicity and flexibility. Built with `TypeScript` and `LevelDB`, **GoodChain** offers a customizable environment for experimenting with consensus algorithms, including a default Simple **Proof-of-Work (PoW)** option.

**GoodChain** is a distributed ledger that enables secure and irreversible transactions across a peer-to-peer distributed network of nodes, ensuring the integrity of data.

Expand Down Expand Up @@ -139,13 +139,13 @@ This project is licensed under the GNU General Public License.

The first version of `GoodChain` was a simple blockchain implementation used to learn about blockchain technology. It used `json` files to store the blockchain data. Check out the [releases](https://github.com/mlibre/GoodChain/releases/tag/1.0.5) to see the code.

### Version 2 (latest version)
### Version 2

The second version of `GoodChain` built using `Node.js` and `Express.js`, and uses `git` to store the blockchain data.
The second version of `GoodChain` built using `Node.js` and `Express.js`, and uses `git` to store the blockchain data. Check out the [releases](https://github.com/mlibre/GoodChain/releases/tag/2.0.2) to see the code.

### Version 3 (in progress)
### Version 3 (latest version)

The third version of `GoodChain` is built using `TypeScript`, `Express.js`, and `TypeORM`.
The third version of `GoodChain` is built using `TypeScript`, `Express.js`, and `LevelDB`.

## Donate 💖

Expand Down
8 changes: 3 additions & 5 deletions src/library/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ export default class ChainStore
{
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public db: any;
sublevel: string;
constructor ( leveldb: Level<string, BlockData> )
{
this.sublevel = "chain";
this.db = leveldb.sublevel<string, BlockData>( this.sublevel, { valueEncoding: "json" });
this.db = leveldb.sublevel<string, BlockData>( "chain", { valueEncoding: "json" });
}

async length (): Promise<number>
Expand Down Expand Up @@ -43,7 +41,7 @@ export default class ChainStore
async get ( blockNumber: number | string ): Promise<BlockData>
{
const blockIndex = parseInt( blockNumber.toString() );
if ( blockIndex >= await this.length() || blockIndex < 0 )
if ( blockIndex > await this.length() || blockIndex < 0 )
{
throw new Error( "Invalid block number" );
}
Expand Down Expand Up @@ -82,7 +80,7 @@ export default class ChainStore
{
const action: PutAction = {
type: "put",
sublevel: this.sublevel,
sublevel: this.db,
key: block.index.toString(),
value: block
};
Expand Down
8 changes: 3 additions & 5 deletions src/library/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ class Wallet
{
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public db: any;
sublevel: string;
constructor ( leveldb: Level<string, BlockData> )
{
this.sublevel = "wallet";
this.db = leveldb.sublevel<string, UserWallet>( this.sublevel, { valueEncoding: "json" });
this.db = leveldb.sublevel<string, UserWallet>( "wallet", { valueEncoding: "json" });
}

async allWallets (): Promise<AllWallets>
Expand Down Expand Up @@ -121,7 +119,7 @@ class Wallet
wallet.balance += amount;
const action: PutAction = {
type: "put",
sublevel: this.sublevel,
sublevel: this.db,
key: address,
value: wallet
};
Expand All @@ -140,7 +138,7 @@ class Wallet
wallet.transaction_number++;
const action: PutAction = {
type: "put",
sublevel: this.sublevel,
sublevel: this.db,
key: address,
value: wallet
};
Expand Down
44 changes: 0 additions & 44 deletions src/test/a.ts

This file was deleted.

0 comments on commit 06c1d6b

Please sign in to comment.