Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
eed80f8
Abdullah/stubnetwork extended test (#20)
akucukoduk16 Apr 12, 2022
ca8e558
Merge branch 'master' into abdullah/mapdb-transactions-and-blocks
Apr 13, 2022
b3f6f3e
TansactionsMapDb and tests are implemented.
Apr 14, 2022
f4b67c5
Merge branch 'master' into abdullah/mapdb-transactions-and-blocks
Apr 14, 2022
edc8bf7
BlocksMapDb is implemented
Apr 14, 2022
b289d60
BlocksMapDb is implemented but adding problem exist
Apr 15, 2022
7b0b8a3
Proof of id remains same for transaction
Apr 15, 2022
aa21128
Change structure
Apr 15, 2022
3c8c098
Change structure
Apr 15, 2022
9fa93cb
Merge branch 'master' into abdullah/mapdb-transactions-and-blocks
Apr 21, 2022
97a11d5
Transactions and Blocks mapdb done.
Apr 21, 2022
433128c
Style modifications
Apr 21, 2022
c385d55
Style modifications
Apr 21, 2022
edd814f
Style modifications
Apr 21, 2022
0054cc1
Style modifications
Apr 21, 2022
800e427
Style modifications
Apr 21, 2022
18f49a6
Style modifications
Apr 21, 2022
24d3727
Style modifications
Apr 21, 2022
6c1d8cd
Style modifications
Apr 21, 2022
46dc48e
Merge branch 'master' into abdullah/mapdb-transactions-and-blocks
thep2p Apr 24, 2022
e0af055
Merge branch 'master' into abdullah/mapdb-transactions-and-blocks
Apr 28, 2022
e233b17
Merge remote-tracking branch 'origin/abdullah/mapdb-transactions-and-…
Apr 28, 2022
5ec7b52
Merge branch 'master' into abdullah/mapdb-transactions-and-blocks
thep2p May 12, 2022
4e0df2c
applies revisions
thep2p May 15, 2022
20c1d9f
Merge remote-tracking branch 'origin/abdullah/mapdb-transactions-and-…
thep2p May 15, 2022
9afe715
applies revisions
thep2p May 15, 2022
ee76d84
applies revisions
May 16, 2022
c7e0c72
applies revisions
May 16, 2022
31bbcac
Merge remote-tracking branch 'origin/abdullah/mapdb-transactions-and-…
May 16, 2022
b409a26
applies revisions
thep2p May 23, 2022
8129144
lint fix
thep2p May 23, 2022
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
5 changes: 3 additions & 2 deletions src/main/java/model/crypto/Signature.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package model.crypto;

import java.io.Serializable;

import model.Entity;
import model.lightchain.Identifier;

/**
* Represents abstract data type for the cryptographic digital signature used in LightChain.
*/
public abstract class Signature extends Entity {
public abstract class Signature extends Entity implements Serializable {
/**
* The signature value in bytes.
*/
private final byte[] bytes;

/**
* Identifier of node that signed transaction.
*/
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/model/crypto/ecdsa/EcdsaSignature.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package model.crypto.ecdsa;

import java.io.Serializable;

import model.codec.EntityType;
import model.crypto.Signature;
import model.lightchain.Identifier;

/**
* ECDSA signature implementation with signer ID.
*/
public class EcdsaSignature extends Signature {
public class EcdsaSignature extends Signature implements Serializable {
public static final String ELLIPTIC_CURVE = "EC";
public static final String SIGN_ALG_SHA_3_256_WITH_ECDSA = "SHA3-256withECDSA";

Expand Down
22 changes: 21 additions & 1 deletion src/main/java/model/lightchain/Block.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package model.lightchain;

import java.io.Serializable;

import model.codec.EntityType;
import model.crypto.Signature;

/**
* Represents a LightChain Block that encapsulates set of ValidatedTransaction(s).
*/
public class Block extends model.Entity {
public class Block extends model.Entity implements Serializable {
/**
* Reference to the hash value of another block as its parent.
*/
Expand Down Expand Up @@ -72,6 +74,24 @@ public Block(Identifier previousBlockId,
this.height = height;
}

@Override
public int hashCode() {
return this.id().hashCode();
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Block)) {
return false;
}
Block that = (Block) o;

return this.id().equals(that.id());
}

/**
* Type of this entity.
*
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/model/lightchain/Identifiers.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package model.lightchain;

import java.io.Serializable;
import java.util.ArrayList;

/**
* Represents an aggregated type for identifiers.
*/
public class Identifiers {
public class Identifiers implements Serializable {
private final ArrayList<Identifier> identifiers;

public Identifiers() {
Expand Down
33 changes: 32 additions & 1 deletion src/main/java/model/lightchain/Transaction.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package model.lightchain;

import java.io.Serializable;

import model.codec.EntityType;
import model.crypto.Signature;

/**
* Represents a LightChain transaction in form of a token transfer between a sender and receiver.
*/
public class Transaction extends model.Entity {
public class Transaction extends model.Entity implements Serializable {
/**
* The identifier of a finalized block that this transaction refers to its snapshot.
*/
Expand Down Expand Up @@ -51,6 +53,35 @@ public Transaction(Identifier referenceBlockId, Identifier sender, Identifier re
this.amount = amount;
}

/**
* Return the HashCode.
*
* @return the hashcode.
*/
@Override
public int hashCode() {
return this.id().hashCode();
}

/**
* Returns true if objects are equal.
*
* @param o an transaction object.
* @return true if objects equal.
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Transaction)) {
return false;
}
Transaction that = (Transaction) o;

return this.id().equals(that.id());
}

/**
* Type of this entity.
*
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/model/lightchain/ValidatedBlock.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package model.lightchain;

import java.util.Arrays;

import model.codec.EntityType;
import model.crypto.Signature;

Expand Down Expand Up @@ -36,6 +38,28 @@ public Signature[] getCertificates() {
return certificates.clone();
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof ValidatedBlock)) {
return false;
}
if (!super.equals(o)) {
return false;
}
ValidatedBlock that = (ValidatedBlock) o;
return Arrays.equals(getCertificates(), that.getCertificates());
}

@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + Arrays.hashCode(getCertificates());
return result;
}

@Override
public String type() {
return EntityType.TYPE_VALIDATED_TRANSACTION;
Expand Down
27 changes: 26 additions & 1 deletion src/main/java/model/lightchain/ValidatedTransaction.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package model.lightchain;

import java.io.Serializable;
import java.util.Arrays;

import model.codec.EntityType;
import model.crypto.Signature;

/**
* A ValidatedTransaction is a wrapper around a Transaction that carries a proof of assigned validators that attests
* the transaction passed local validation of validators.
*/
public class ValidatedTransaction extends Transaction {
public class ValidatedTransaction extends Transaction implements Serializable {
/**
* Represents the signatures of assigned validators to this transaction.
*/
Expand Down Expand Up @@ -36,6 +39,28 @@ public Signature[] getCertificates() {
return certificates.clone();
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof ValidatedTransaction)) {
return false;
}
if (!super.equals(o)) {
return false;
}
ValidatedTransaction that = (ValidatedTransaction) o;
return Arrays.equals(getCertificates(), that.getCertificates());
}

@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + Arrays.hashCode(getCertificates());
return result;
}

@Override
public String type() {
return EntityType.TYPE_VALIDATED_TRANSACTION;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/storage/Blocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* Persistent module for storing blocks on the disk.
*/
public interface Blocks {
// TODO: refactor blocks to keep validated blocks.

/**
* Checks existence of block on the database.
*
Expand Down
Loading