Arin Turpin пре 6 година
родитељ
комит
298aa7276b

+ 5
- 5
ZipCoinRedJavaServer/src/main/java/com/zipcoin/config/TransactionLoader.java Прегледај датотеку

@@ -20,11 +20,11 @@ public class TransactionLoader implements ApplicationRunner {
20 20
   @Override
21 21
   public void run(ApplicationArguments applicationArguments){
22 22
       Transaction[] transactions = new Transaction[]{
23
-              new Transaction("shivam", "khalil", 10),
24
-              new Transaction("eric", "shivam", 100),
25
-              new Transaction("khalil", "eric", (float)30.22),
26
-              new Transaction("aleena", "navya", (float)43.32),
27
-              new Transaction("shivam", "ken", 1)
23
+              new Transaction("shivam", "khalil", (double) 10f),
24
+              new Transaction("eric", "shivam", (double) 100.34f),
25
+              new Transaction("khalil", "eric", (double) 30.000),
26
+              new Transaction("aleena", "navya", (double) 43.32),
27
+              new Transaction("shivam", "ken", (double) 1f)
28 28
       };
29 29
 
30 30
       for(Transaction t : transactions){

+ 2
- 2
ZipCoinRedJavaServer/src/main/java/com/zipcoin/config/WalletLoader.java Прегледај датотеку

@@ -20,8 +20,8 @@ public class WalletLoader implements ApplicationRunner {
20 20
     @Override
21 21
     public void run(ApplicationArguments applicationArguments) throws Exception {
22 22
         Wallet[] wallets = new Wallet[]{
23
-                new Wallet("ann","34",80),
24
-                new Wallet("sen","3564",8)
23
+                new Wallet("ann","34",80.45),
24
+                new Wallet("sen","3564",8.8)
25 25
         };
26 26
         for(Wallet wallet :wallets) {
27 27
             this.walletRepository.save(wallet);

+ 12
- 17
ZipCoinRedJavaServer/src/main/java/com/zipcoin/model/Transaction.java Прегледај датотеку

@@ -12,16 +12,23 @@ public class Transaction {
12 12
 
13 13
     @Id
14 14
     @GeneratedValue(strategy = GenerationType.AUTO)
15
-    // private String transactionId;
15
+    private Long transactionId;
16 16
     private String senderPublicKey;
17 17
     private String recipientPublicKey;
18 18
     private String transactionHash;
19
-    private Float amount;
19
+    private Double amount;
20 20
     //@OneToMany
21 21
     //private List<Integer> coins;
22 22
     //public Signature signature;
23 23
 
24
-    public Transaction(String senderPublicKey, String recipientPublicKey, Float amount){
24
+    public Transaction(){
25
+
26
+    }
27
+
28
+    public Transaction(String senderPublicKey, String recipientPublicKey, Double amount){
29
+        this.senderPublicKey = senderPublicKey;
30
+        this.recipientPublicKey = recipientPublicKey;
31
+        this.amount = amount;
25 32
 
26 33
     }
27 34
 
@@ -33,14 +40,12 @@ public class Transaction {
33 40
         return recipientPublicKey;
34 41
     }
35 42
 
36
-    public Float getAmount() {
43
+    public Double getAmount() {
37 44
         return amount;
38 45
     }
39 46
 
40
-
41
-
42 47
     public void calculateAndSetHash() {
43
-        String transactionHash = DigestUtils.sha256Hex(senderPublicKey + recipientPublicKey + Float.toString(amount));
48
+        String transactionHash = DigestUtils.sha256Hex(senderPublicKey + recipientPublicKey + Double.toString(amount));
44 49
         setTransactionHash(transactionHash);
45 50
     }
46 51
 
@@ -48,16 +53,6 @@ public class Transaction {
48 53
         this.transactionHash = transactionHash;
49 54
     }
50 55
 
51
-
52
-//    public Transaction(String from, String to, float amount/*,List<Integer> coins*/) {
53
-//        this.sender = from;
54
-//        this.recipient = to;
55
-//        this.amount = amount;
56
-//        //this.coins=coins;
57
-//    }
58
-
59
-
60
-
61 56
 //    public void generateSignature(PrivateKey privateKey) throws NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException {
62 57
 //        String data = StringUtil.getStringFromKey(sender) + StringUtil.getStringFromKey(reciepient) + Float.toString(value)    ;
63 58
 //        signature = StringUtil.applyECDSASig(privateKey,data);

+ 4
- 4
ZipCoinRedJavaServer/src/main/java/com/zipcoin/model/Wallet.java Прегледај датотеку

@@ -20,13 +20,13 @@ public class Wallet {
20 20
     private int id;
21 21
     private String name;
22 22
     private String publicKey;
23
-    private Float amount;
23
+    private Double amount;
24 24
 
25 25
     public Wallet() {
26 26
         generateKeyPair();
27 27
     }
28 28
 
29
-    public Wallet(String name, String publicKey, Float amount) {
29
+    public Wallet(String name, String publicKey, Double amount) {
30 30
         this.name=name;
31 31
         this.publicKey=publicKey;
32 32
         this.amount=amount;
@@ -36,11 +36,11 @@ public class Wallet {
36 36
         return publicKey;
37 37
     }
38 38
 
39
-    public Float getAmount(){
39
+    public Double getAmount(){
40 40
         return amount;
41 41
     }
42 42
 
43
-    public void setAmount(Float amount){
43
+    public void setAmount(Double amount){
44 44
         this.amount = amount;
45 45
     }
46 46
 

+ 1
- 1
ZipCoinRedJavaServer/src/main/java/com/zipcoin/repository/TransactionRepository.java Прегледај датотеку

@@ -16,5 +16,5 @@ import java.util.List;
16 16
 
17 17
 @Repository
18 18
 public interface TransactionRepository extends JpaRepository<Transaction, Long> {
19
-    Collection<Transaction> findTransactionBySenderOrRecipient(String sender, String recipient);
19
+    Collection<Transaction> findTransactionBySenderPublicKeyOrRecipientPublicKey(String senderPublicKey, String recipientPublicKey);
20 20
 }

+ 1
- 2
ZipCoinRedJavaServer/src/main/java/com/zipcoin/service/TransactionService.java Прегледај датотеку

@@ -33,7 +33,6 @@ public class TransactionService {
33 33
 
34 34
         transaction.calculateAndSetHash();
35 35
         return transactionRepository.save(transaction);
36
-
37 36
     }
38 37
 
39 38
     public Collection<Transaction> getAllTransactions(){
@@ -41,7 +40,7 @@ public class TransactionService {
41 40
     }
42 41
 
43 42
     public Collection<Transaction> getTransactionsByPublicKey(String publicKey) {
44
-        return transactionRepository.findTransactionBySenderOrRecipient(publicKey, publicKey);
43
+        return transactionRepository.findTransactionBySenderPublicKeyOrRecipientPublicKey(publicKey, publicKey);
45 44
     }
46 45
 
47 46