Browse Source

api clean up, added lombok getter and setter, get transactions by public key

Eric Foster 6 years ago
parent
commit
eb28fbd3a3

+ 155
- 129
ZipCoinRedJavaServer/.idea/workspace.xml View File

@@ -12,10 +12,22 @@
12 12
   </component>
13 13
   <component name="FileEditorManager">
14 14
     <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
15
+      <file leaf-file-name="BlockController.java" pinned="false" current-in-tab="false">
16
+        <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/controller/BlockController.java">
17
+          <provider selected="true" editor-type-id="text-editor">
18
+            <state relative-caret-position="33">
19
+              <caret line="23" column="19" selection-start-line="23" selection-start-column="19" selection-end-line="23" selection-end-column="19" />
20
+              <folding>
21
+                <element signature="imports" expanded="true" />
22
+              </folding>
23
+            </state>
24
+          </provider>
25
+        </entry>
26
+      </file>
15 27
       <file leaf-file-name="TransactionController.java" pinned="false" current-in-tab="false">
16 28
         <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/controller/TransactionController.java">
17 29
           <provider selected="true" editor-type-id="text-editor">
18
-            <state relative-caret-position="420">
30
+            <state relative-caret-position="211">
19 31
               <caret line="36" column="5" selection-start-line="36" selection-start-column="5" selection-end-line="36" selection-end-column="5" />
20 32
             </state>
21 33
           </provider>
@@ -25,37 +37,37 @@
25 37
         <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/config/TransactionApis.java">
26 38
           <provider selected="true" editor-type-id="text-editor">
27 39
             <state relative-caret-position="60">
28
-              <caret line="4" column="98" lean-forward="true" selection-start-line="4" selection-start-column="98" selection-end-line="4" selection-end-column="98" />
40
+              <caret line="4" column="102" lean-forward="true" selection-start-line="4" selection-start-column="102" selection-end-line="4" selection-end-column="102" />
29 41
             </state>
30 42
           </provider>
31 43
         </entry>
32 44
       </file>
33
-      <file leaf-file-name="WalletRepository.java" pinned="false" current-in-tab="false">
34
-        <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/repository/WalletRepository.java">
45
+      <file leaf-file-name="TransactionService.java" pinned="false" current-in-tab="false">
46
+        <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/service/TransactionService.java">
35 47
           <provider selected="true" editor-type-id="text-editor">
36
-            <state relative-caret-position="60">
37
-              <caret line="10" column="71" selection-start-line="10" selection-start-column="71" selection-end-line="10" selection-end-column="71" />
48
+            <state relative-caret-position="-39">
49
+              <caret line="11" selection-start-line="11" selection-end-line="11" />
50
+              <folding>
51
+                <element signature="imports" expanded="true" />
52
+              </folding>
38 53
             </state>
39 54
           </provider>
40 55
         </entry>
41 56
       </file>
42
-      <file leaf-file-name="BlockController.java" pinned="false" current-in-tab="true">
43
-        <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/controller/BlockController.java">
57
+      <file leaf-file-name="WalletRepository.java" pinned="false" current-in-tab="false">
58
+        <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/repository/WalletRepository.java">
44 59
           <provider selected="true" editor-type-id="text-editor">
45
-            <state relative-caret-position="246">
46
-              <caret line="29" column="22" lean-forward="true" selection-start-line="29" selection-start-column="22" selection-end-line="29" selection-end-column="22" />
47
-              <folding>
48
-                <element signature="imports" expanded="true" />
49
-              </folding>
60
+            <state relative-caret-position="105">
61
+              <caret line="13" selection-start-line="13" selection-start-column="2" selection-end-line="14" selection-end-column="46" />
50 62
             </state>
51 63
           </provider>
52 64
         </entry>
53 65
       </file>
54
-      <file leaf-file-name="WalletService.java" pinned="false" current-in-tab="false">
55
-        <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/service/WalletService.java">
66
+      <file leaf-file-name="WalletController.java" pinned="false" current-in-tab="false">
67
+        <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/controller/WalletController.java">
56 68
           <provider selected="true" editor-type-id="text-editor">
57
-            <state relative-caret-position="-12">
58
-              <caret line="7" column="28" selection-start-line="7" selection-start-column="28" selection-end-line="7" selection-end-column="28" />
69
+            <state relative-caret-position="130">
70
+              <caret line="39" selection-start-line="39" selection-start-column="2" selection-end-line="42" selection-end-column="7" />
59 71
               <folding>
60 72
                 <element signature="imports" expanded="true" />
61 73
               </folding>
@@ -63,41 +75,38 @@
63 75
           </provider>
64 76
         </entry>
65 77
       </file>
66
-      <file leaf-file-name="BlockRepository.java" pinned="false" current-in-tab="false">
67
-        <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/repository/BlockRepository.java">
78
+      <file leaf-file-name="BlockApis.java" pinned="false" current-in-tab="false">
79
+        <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/config/BlockApis.java">
68 80
           <provider selected="true" editor-type-id="text-editor">
69 81
             <state relative-caret-position="60">
70
-              <caret line="5" column="17" selection-start-line="5" selection-start-column="17" selection-end-line="5" selection-end-column="17" />
82
+              <caret line="4" column="83" selection-start-line="4" selection-start-column="83" selection-end-line="4" selection-end-column="83" />
71 83
             </state>
72 84
           </provider>
73 85
         </entry>
74 86
       </file>
75
-      <file leaf-file-name="TransactionService.java" pinned="false" current-in-tab="false">
76
-        <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/service/TransactionService.java">
87
+      <file leaf-file-name="WalletApis.java" pinned="false" current-in-tab="false">
88
+        <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/config/WalletApis.java">
77 89
           <provider selected="true" editor-type-id="text-editor">
78
-            <state relative-caret-position="270">
79
-              <caret line="18" column="5" lean-forward="true" selection-start-line="18" selection-start-column="5" selection-end-line="18" selection-end-column="5" />
80
-              <folding>
81
-                <element signature="imports" expanded="true" />
82
-              </folding>
90
+            <state relative-caret-position="45">
91
+              <caret line="3" column="65" selection-start-line="3" selection-start-column="49" selection-end-line="3" selection-end-column="65" />
83 92
             </state>
84 93
           </provider>
85 94
         </entry>
86 95
       </file>
87
-      <file leaf-file-name="WalletLoader.java" pinned="false" current-in-tab="false">
88
-        <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/config/WalletLoader.java">
96
+      <file leaf-file-name="TransactionRepository.java" pinned="false" current-in-tab="false">
97
+        <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/repository/TransactionRepository.java">
89 98
           <provider selected="true" editor-type-id="text-editor">
90
-            <state relative-caret-position="195">
91
-              <caret line="18" selection-start-line="18" selection-end-line="18" />
99
+            <state relative-caret-position="120">
100
+              <caret line="18" column="96" selection-start-line="18" selection-start-column="96" selection-end-line="18" selection-end-column="96" />
92 101
             </state>
93 102
           </provider>
94 103
         </entry>
95 104
       </file>
96
-      <file leaf-file-name="WalletController.java" pinned="false" current-in-tab="false">
97
-        <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/controller/WalletController.java">
105
+      <file leaf-file-name="WalletService.java" pinned="false" current-in-tab="true">
106
+        <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/service/WalletService.java">
98 107
           <provider selected="true" editor-type-id="text-editor">
99
-            <state relative-caret-position="-116">
100
-              <caret line="7" column="28" selection-start-line="7" selection-start-column="28" selection-end-line="7" selection-end-column="28" />
108
+            <state relative-caret-position="465">
109
+              <caret line="31" selection-start-line="31" selection-start-column="2" selection-end-line="33" selection-end-column="7" />
101 110
               <folding>
102 111
                 <element signature="imports" expanded="true" />
103 112
               </folding>
@@ -105,15 +114,6 @@
105 114
           </provider>
106 115
         </entry>
107 116
       </file>
108
-      <file leaf-file-name="TransactionRepository.java" pinned="false" current-in-tab="false">
109
-        <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/repository/TransactionRepository.java">
110
-          <provider selected="true" editor-type-id="text-editor">
111
-            <state relative-caret-position="120">
112
-              <caret line="18" column="96" selection-start-line="18" selection-start-column="96" selection-end-line="18" selection-end-column="96" />
113
-            </state>
114
-          </provider>
115
-        </entry>
116
-      </file>
117 117
     </leaf>
118 118
   </component>
119 119
   <component name="FileTemplateManagerImpl">
@@ -127,18 +127,25 @@
127 127
     <option name="CHANGED_PATHS">
128 128
       <list>
129 129
         <option value="$PROJECT_DIR$/src/main/java/com/zipcoin/config/TransactionLoader.java" />
130
-        <option value="$PROJECT_DIR$/src/main/java/com/zipcoin/config/WalletLoader.java" />
131 130
         <option value="$PROJECT_DIR$/src/main/java/com/zipcoin/config/BlockLoader.java" />
132 131
         <option value="$PROJECT_DIR$/src/main/java/com/zipcoin/ZipCoinApp.java" />
133
-        <option value="$PROJECT_DIR$/pom.xml" />
134
-        <option value="$PROJECT_DIR$/src/main/java/com/zipcoin/config/TransactionApis.java" />
135
-        <option value="$PROJECT_DIR$/src/main/java/com/zipcoin/model/Transaction.java" />
136 132
         <option value="$PROJECT_DIR$/src/main/java/com/zipcoin/controller/TransactionController.java" />
133
+        <option value="$PROJECT_DIR$/src/main/java/com/zipcoin/repository/TransactionRepository.java" />
137 134
         <option value="$PROJECT_DIR$/src/main/java/com/zipcoin/service/TransactionService.java" />
138
-        <option value="$PROJECT_DIR$/src/main/java/com/zipcoin/service/WalletService.java" />
139
-        <option value="$PROJECT_DIR$/src/main/java/com/zipcoin/controller/WalletController.java" />
135
+        <option value="$PROJECT_DIR$/src/main/java/com/zipcoin/config/WalletApis.java" />
136
+        <option value="$PROJECT_DIR$/src/main/java/com/zipcoin/config/TransactionApis.java" />
137
+        <option value="$PROJECT_DIR$/src/main/java/com/zipcoin/config/BlockApis.java" />
138
+        <option value="$PROJECT_DIR$/pom.xml" />
139
+        <option value="$PROJECT_DIR$/src/main/java/com/zipcoin/model/Transaction.java" />
140
+        <option value="$PROJECT_DIR$/src/main/java/com/zipcoin/model/Wallet.java" />
141
+        <option value="$PROJECT_DIR$/src/main/java/com/zipcoin/model/Chain.java" />
142
+        <option value="$PROJECT_DIR$/src/main/java/com/zipcoin/config/WalletLoader.java" />
143
+        <option value="$PROJECT_DIR$/src/main/java/com/zipcoin/service/BlockService.java" />
144
+        <option value="$PROJECT_DIR$/src/main/java/com/zipcoin/model/Block.java" />
145
+        <option value="$PROJECT_DIR$/src/main/java/com/zipcoin/controller/BlockController.java" />
140 146
         <option value="$PROJECT_DIR$/src/main/java/com/zipcoin/repository/WalletRepository.java" />
141
-        <option value="$PROJECT_DIR$/src/main/java/com/zipcoin/repository/TransactionRepository.java" />
147
+        <option value="$PROJECT_DIR$/src/main/java/com/zipcoin/controller/WalletController.java" />
148
+        <option value="$PROJECT_DIR$/src/main/java/com/zipcoin/service/WalletService.java" />
142 149
       </list>
143 150
     </option>
144 151
   </component>
@@ -372,12 +379,12 @@
372 379
       <option name="presentableId" value="Default" />
373 380
       <updated>1533221514750</updated>
374 381
       <workItem from="1533221516219" duration="17000" />
375
-      <workItem from="1533244438155" duration="6556000" />
382
+      <workItem from="1533244438155" duration="11004000" />
376 383
     </task>
377 384
     <servers />
378 385
   </component>
379 386
   <component name="TimeTrackingManager">
380
-    <option name="totallyTimeSpent" value="9670000" />
387
+    <option name="totallyTimeSpent" value="14118000" />
381 388
   </component>
382 389
   <component name="TodoView">
383 390
     <todo-panel id="selected-file">
@@ -390,6 +397,7 @@
390 397
   </component>
391 398
   <component name="ToolWindowManager">
392 399
     <frame x="0" y="0" width="1280" height="800" extended-state="0" />
400
+    <editor active="true" />
393 401
     <layout>
394 402
       <window_info anchor="right" id="Palette" order="5" />
395 403
       <window_info anchor="bottom" id="Event Log" order="10" side_tool="true" />
@@ -403,16 +411,16 @@
403 411
       <window_info id="UI Designer" order="5" />
404 412
       <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
405 413
       <window_info anchor="bottom" id="TODO" order="6" weight="0.32954547" />
406
-      <window_info anchor="bottom" id="Messages" order="9" visible="true" weight="0.32827586" />
414
+      <window_info anchor="bottom" id="Messages" order="9" weight="0.32827586" />
407 415
       <window_info anchor="right" id="Palette&#9;" order="5" />
408 416
       <window_info id="Image Layers" order="5" />
409 417
       <window_info anchor="bottom" id="Java Enterprise" order="7" weight="0.32954547" />
410 418
       <window_info anchor="right" id="Capture Analysis" order="5" />
411 419
       <window_info anchor="bottom" id="Version Control" order="10" show_stripe_button="false" />
412
-      <window_info anchor="bottom" id="Run" order="2" weight="0.28" />
420
+      <window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.5834483" />
413 421
       <window_info anchor="bottom" id="Spring" order="7" weight="0.32954547" />
414 422
       <window_info anchor="bottom" id="Terminal" order="10" weight="0.0" />
415
-      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.2536349" />
423
+      <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.2536349" />
416 424
       <window_info anchor="right" id="Bean Validation" order="3" />
417 425
       <window_info id="Web" order="5" side_tool="true" />
418 426
       <window_info anchor="bottom" id="Find" order="1" />
@@ -433,15 +441,6 @@
433 441
     <option name="myLimit" value="2678400000" />
434 442
   </component>
435 443
   <component name="editorHistoryManager">
436
-    <entry file="file://$PROJECT_DIR$/src/test/java/com/zipcoin/redCoin/testMain.java" />
437
-    <entry file="file://$PROJECT_DIR$/pom.xml">
438
-      <provider selected="true" editor-type-id="text-editor">
439
-        <state relative-caret-position="90">
440
-          <caret line="6" column="20" selection-start-line="6" selection-start-column="13" selection-end-line="6" selection-end-column="20" />
441
-        </state>
442
-      </provider>
443
-    </entry>
444
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/redCoin/Main.java" />
445 444
     <entry file="file://$PROJECT_DIR$/ZipCoin-RED.iml" />
446 445
     <entry file="file://$PROJECT_DIR$/src/test/java/com/zipcoin/redCoin/block/test/BlockControllerTest.java">
447 446
       <provider selected="true" editor-type-id="text-editor">
@@ -512,161 +511,188 @@
512 511
         </state>
513 512
       </provider>
514 513
     </entry>
515
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/model/Block.java">
514
+    <entry file="file://$PROJECT_DIR$/.idea/workspace.xml">
515
+      <provider selected="true" editor-type-id="text-editor">
516
+        <state relative-caret-position="358">
517
+          <caret line="57" column="20" selection-start-line="57" selection-start-column="20" selection-end-line="57" selection-end-column="20" />
518
+        </state>
519
+      </provider>
520
+    </entry>
521
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/ZipCoinApp.java">
516 522
       <provider selected="true" editor-type-id="text-editor">
517
-        <state relative-caret-position="1230">
518
-          <caret line="82" column="4" selection-start-line="82" selection-start-column="4" selection-end-line="82" selection-end-column="4" />
523
+        <state relative-caret-position="255">
524
+          <caret line="17" column="1" selection-start-line="17" selection-start-column="1" selection-end-line="17" selection-end-column="1" />
519 525
           <folding>
520 526
             <element signature="imports" expanded="true" />
521 527
           </folding>
522 528
         </state>
523 529
       </provider>
524 530
     </entry>
525
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/model/Chain.java">
531
+    <entry file="file://$PROJECT_DIR$/pom.xml">
526 532
       <provider selected="true" editor-type-id="text-editor">
527
-        <state relative-caret-position="150">
528
-          <caret line="10" selection-start-line="10" selection-end-line="10" />
533
+        <state relative-caret-position="245">
534
+          <caret line="52" column="21" selection-start-line="52" selection-start-column="21" selection-end-line="52" selection-end-column="21" />
529 535
         </state>
530 536
       </provider>
531 537
     </entry>
532
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/controller/HomeController.java">
538
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/model/Wallet.java">
533 539
       <provider selected="true" editor-type-id="text-editor">
534
-        <state relative-caret-position="120">
535
-          <caret line="9" column="5" selection-start-line="9" selection-start-column="5" selection-end-line="9" selection-end-column="5" />
540
+        <state relative-caret-position="345">
541
+          <caret line="32" column="5" selection-start-line="32" selection-start-column="5" selection-end-line="32" selection-end-column="5" />
536 542
         </state>
537 543
       </provider>
538 544
     </entry>
539
-    <entry file="file://$PROJECT_DIR$/.idea/workspace.xml">
545
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/model/Transaction.java">
540 546
       <provider selected="true" editor-type-id="text-editor">
541
-        <state relative-caret-position="358">
542
-          <caret line="57" column="20" selection-start-line="57" selection-start-column="20" selection-end-line="57" selection-end-column="20" />
547
+        <state relative-caret-position="405">
548
+          <caret line="31" column="5" lean-forward="true" selection-start-line="31" selection-start-column="5" selection-end-line="31" selection-end-column="5" />
543 549
         </state>
544 550
       </provider>
545 551
     </entry>
546
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/config/BlockLoader.java">
552
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/model/Chain.java">
547 553
       <provider selected="true" editor-type-id="text-editor">
548
-        <state relative-caret-position="180">
549
-          <caret line="12" column="4" selection-start-line="12" selection-start-column="4" selection-end-line="12" selection-end-column="4" />
554
+        <state relative-caret-position="240">
555
+          <caret line="19" column="5" lean-forward="true" selection-start-line="19" selection-start-column="5" selection-end-line="19" selection-end-column="5" />
550 556
           <folding>
551 557
             <element signature="imports" expanded="true" />
552 558
           </folding>
553 559
         </state>
554 560
       </provider>
555 561
     </entry>
556
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/ZipCoinApp.java">
562
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/config/WalletLoader.java">
557 563
       <provider selected="true" editor-type-id="text-editor">
558
-        <state relative-caret-position="255">
559
-          <caret line="17" column="1" selection-start-line="17" selection-start-column="1" selection-end-line="17" selection-end-column="1" />
560
-          <folding>
561
-            <element signature="imports" expanded="true" />
562
-          </folding>
564
+        <state relative-caret-position="300">
565
+          <caret line="25" column="36" selection-start-line="25" selection-start-column="36" selection-end-line="25" selection-end-column="36" />
563 566
         </state>
564 567
       </provider>
565 568
     </entry>
566
-    <entry file="file://$PROJECT_DIR$/pom.xml">
569
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/config/TransactionLoader.java">
567 570
       <provider selected="true" editor-type-id="text-editor">
568 571
         <state relative-caret-position="195">
569
-          <caret line="13" column="40" selection-start-line="13" selection-start-column="40" selection-end-line="13" selection-end-column="40" />
572
+          <caret line="18" selection-start-line="18" selection-end-line="18" />
570 573
         </state>
571 574
       </provider>
572 575
     </entry>
573
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/model/Transaction.java">
576
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/config/BlockLoader.java">
574 577
       <provider selected="true" editor-type-id="text-editor">
575
-        <state relative-caret-position="165">
576
-          <caret line="13" column="26" lean-forward="true" selection-start-line="13" selection-start-column="26" selection-end-line="13" selection-end-column="26" />
578
+        <state relative-caret-position="180">
579
+          <caret line="12" column="4" selection-start-line="12" selection-start-column="4" selection-end-line="12" selection-end-column="4" />
580
+          <folding>
581
+            <element signature="imports" expanded="true" />
582
+          </folding>
577 583
         </state>
578 584
       </provider>
579 585
     </entry>
580
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/config/TransactionLoader.java">
586
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/controller/HomeController.java">
581 587
       <provider selected="true" editor-type-id="text-editor">
582
-        <state relative-caret-position="195">
583
-          <caret line="18" selection-start-line="18" selection-end-line="18" />
588
+        <state relative-caret-position="120">
589
+          <caret line="9" column="5" selection-start-line="9" selection-start-column="5" selection-end-line="9" selection-end-column="5" />
584 590
         </state>
585 591
       </provider>
586 592
     </entry>
587
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/config/WalletApis.java">
593
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/model/Block.java">
588 594
       <provider selected="true" editor-type-id="text-editor">
589
-        <state relative-caret-position="30">
590
-          <caret line="2" column="23" selection-start-line="2" selection-start-column="23" selection-end-line="2" selection-end-column="23" />
595
+        <state relative-caret-position="885">
596
+          <caret line="59" column="5" selection-start-line="59" selection-start-column="5" selection-end-line="59" selection-end-column="5" />
597
+          <folding>
598
+            <element signature="imports" expanded="true" />
599
+          </folding>
591 600
         </state>
592 601
       </provider>
593 602
     </entry>
594
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/config/TransactionApis.java">
603
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/service/BlockService.java">
595 604
       <provider selected="true" editor-type-id="text-editor">
596
-        <state relative-caret-position="60">
597
-          <caret line="4" column="98" lean-forward="true" selection-start-line="4" selection-start-column="98" selection-end-line="4" selection-end-column="98" />
605
+        <state relative-caret-position="356">
606
+          <caret line="35" column="16" lean-forward="true" selection-start-line="35" selection-start-column="16" selection-end-line="35" selection-end-column="16" />
607
+          <folding>
608
+            <element signature="imports" expanded="true" />
609
+          </folding>
598 610
         </state>
599 611
       </provider>
600 612
     </entry>
601
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/config/WalletLoader.java">
613
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/repository/BlockRepository.java">
602 614
       <provider selected="true" editor-type-id="text-editor">
603
-        <state relative-caret-position="195">
604
-          <caret line="18" selection-start-line="18" selection-end-line="18" />
615
+        <state relative-caret-position="60">
616
+          <caret line="5" column="17" selection-start-line="5" selection-start-column="17" selection-end-line="5" selection-end-column="17" />
605 617
         </state>
606 618
       </provider>
607 619
     </entry>
608
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/controller/TransactionController.java">
620
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/config/BlockApis.java">
609 621
       <provider selected="true" editor-type-id="text-editor">
610
-        <state relative-caret-position="420">
611
-          <caret line="36" column="5" selection-start-line="36" selection-start-column="5" selection-end-line="36" selection-end-column="5" />
622
+        <state relative-caret-position="60">
623
+          <caret line="4" column="83" selection-start-line="4" selection-start-column="83" selection-end-line="4" selection-end-column="83" />
612 624
         </state>
613 625
       </provider>
614 626
     </entry>
615
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/service/WalletService.java">
627
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/controller/BlockController.java">
616 628
       <provider selected="true" editor-type-id="text-editor">
617
-        <state relative-caret-position="-12">
618
-          <caret line="7" column="28" selection-start-line="7" selection-start-column="28" selection-end-line="7" selection-end-column="28" />
629
+        <state relative-caret-position="33">
630
+          <caret line="23" column="19" selection-start-line="23" selection-start-column="19" selection-end-line="23" selection-end-column="19" />
619 631
           <folding>
620 632
             <element signature="imports" expanded="true" />
621 633
           </folding>
622 634
         </state>
623 635
       </provider>
624 636
     </entry>
625
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/service/TransactionService.java">
637
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/repository/TransactionRepository.java">
626 638
       <provider selected="true" editor-type-id="text-editor">
627
-        <state relative-caret-position="270">
628
-          <caret line="18" column="5" lean-forward="true" selection-start-line="18" selection-start-column="5" selection-end-line="18" selection-end-column="5" />
629
-          <folding>
630
-            <element signature="imports" expanded="true" />
631
-          </folding>
639
+        <state relative-caret-position="120">
640
+          <caret line="18" column="96" selection-start-line="18" selection-start-column="96" selection-end-line="18" selection-end-column="96" />
632 641
         </state>
633 642
       </provider>
634 643
     </entry>
635
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/controller/WalletController.java">
644
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/service/TransactionService.java">
636 645
       <provider selected="true" editor-type-id="text-editor">
637
-        <state relative-caret-position="-116">
638
-          <caret line="7" column="28" selection-start-line="7" selection-start-column="28" selection-end-line="7" selection-end-column="28" />
646
+        <state relative-caret-position="-39">
647
+          <caret line="11" selection-start-line="11" selection-end-line="11" />
639 648
           <folding>
640 649
             <element signature="imports" expanded="true" />
641 650
           </folding>
642 651
         </state>
643 652
       </provider>
644 653
     </entry>
645
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/repository/TransactionRepository.java">
654
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/controller/TransactionController.java">
646 655
       <provider selected="true" editor-type-id="text-editor">
647
-        <state relative-caret-position="120">
648
-          <caret line="18" column="96" selection-start-line="18" selection-start-column="96" selection-end-line="18" selection-end-column="96" />
656
+        <state relative-caret-position="211">
657
+          <caret line="36" column="5" selection-start-line="36" selection-start-column="5" selection-end-line="36" selection-end-column="5" />
649 658
         </state>
650 659
       </provider>
651 660
     </entry>
652
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/repository/WalletRepository.java">
661
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/config/TransactionApis.java">
653 662
       <provider selected="true" editor-type-id="text-editor">
654 663
         <state relative-caret-position="60">
655
-          <caret line="10" column="71" selection-start-line="10" selection-start-column="71" selection-end-line="10" selection-end-column="71" />
664
+          <caret line="4" column="102" lean-forward="true" selection-start-line="4" selection-start-column="102" selection-end-line="4" selection-end-column="102" />
656 665
         </state>
657 666
       </provider>
658 667
     </entry>
659
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/repository/BlockRepository.java">
668
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/config/WalletApis.java">
660 669
       <provider selected="true" editor-type-id="text-editor">
661
-        <state relative-caret-position="60">
662
-          <caret line="5" column="17" selection-start-line="5" selection-start-column="17" selection-end-line="5" selection-end-column="17" />
670
+        <state relative-caret-position="45">
671
+          <caret line="3" column="65" selection-start-line="3" selection-start-column="49" selection-end-line="3" selection-end-column="65" />
663 672
         </state>
664 673
       </provider>
665 674
     </entry>
666
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/controller/BlockController.java">
675
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/controller/WalletController.java">
676
+      <provider selected="true" editor-type-id="text-editor">
677
+        <state relative-caret-position="130">
678
+          <caret line="39" selection-start-line="39" selection-start-column="2" selection-end-line="42" selection-end-column="7" />
679
+          <folding>
680
+            <element signature="imports" expanded="true" />
681
+          </folding>
682
+        </state>
683
+      </provider>
684
+    </entry>
685
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/repository/WalletRepository.java">
686
+      <provider selected="true" editor-type-id="text-editor">
687
+        <state relative-caret-position="105">
688
+          <caret line="13" selection-start-line="13" selection-start-column="2" selection-end-line="14" selection-end-column="46" />
689
+        </state>
690
+      </provider>
691
+    </entry>
692
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcoin/service/WalletService.java">
667 693
       <provider selected="true" editor-type-id="text-editor">
668
-        <state relative-caret-position="246">
669
-          <caret line="29" column="22" lean-forward="true" selection-start-line="29" selection-start-column="22" selection-end-line="29" selection-end-column="22" />
694
+        <state relative-caret-position="465">
695
+          <caret line="31" selection-start-line="31" selection-start-column="2" selection-end-line="33" selection-end-column="7" />
670 696
           <folding>
671 697
             <element signature="imports" expanded="true" />
672 698
           </folding>

+ 5
- 1
ZipCoinRedJavaServer/pom.xml View File

@@ -46,7 +46,11 @@
46 46
             <version>4.12</version>
47 47
             <scope>test</scope>
48 48
         </dependency>
49
-
49
+        <dependency>
50
+            <groupId>org.projectlombok</groupId>
51
+            <artifactId>lombok</artifactId>
52
+            <optional>true</optional>
53
+        </dependency>
50 54
         <dependency>
51 55
             <groupId>mysql</groupId>
52 56
             <artifactId>mysql-connector-java</artifactId>

+ 6
- 0
ZipCoinRedJavaServer/src/main/java/com/zipcoin/config/BlockApis.java View File

@@ -0,0 +1,6 @@
1
+package com.zipcoin.config;
2
+
3
+public class BlockApis {
4
+    public static final String BASE_BLOCK_URL = "api/v1/blocks";
5
+    public static final String GET_MINED_BLOCK_BY_ID = BASE_BLOCK_URL + "/{id}/mine";
6
+}

+ 1
- 1
ZipCoinRedJavaServer/src/main/java/com/zipcoin/config/TransactionApis.java View File

@@ -2,5 +2,5 @@ package com.zipcoin.config;
2 2
 
3 3
 public class TransactionApis {
4 4
     public static final String BASE_TRANSACTION_URL = "api/v1/transactions";
5
-    public static final String GET_TRANSACTIONS_BY_PUBLIC_KEY = "api/v1/transactions/{publicKey}";
5
+    public static final String GET_TRANSACTIONS_BY_PUBLIC_KEY = BASE_TRANSACTION_URL + "/{publicKey}";
6 6
 }

+ 3
- 0
ZipCoinRedJavaServer/src/main/java/com/zipcoin/config/WalletApis.java View File

@@ -1,4 +1,7 @@
1 1
 package com.zipcoin.config;
2 2
 
3 3
 public class WalletApis {
4
+    public static final String BASE_WALLET_URL = "api/v1/wallets";
5
+    public static final String GET_WALLET_BY_PUBLIC_KEY = BASE_WALLET_URL + "/{publicKey}";
6
+    public static final String GET_ALL_WALLET_PUBLIC_KEYS = BASE_WALLET_URL + "/publicKeys";
4 7
 }

+ 5
- 9
ZipCoinRedJavaServer/src/main/java/com/zipcoin/config/WalletLoader.java View File

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

+ 18
- 30
ZipCoinRedJavaServer/src/main/java/com/zipcoin/controller/BlockController.java View File

@@ -1,50 +1,38 @@
1 1
 package com.zipcoin.controller;
2 2
 
3 3
 import com.zipcoin.model.Block;
4
-import com.zipcoin.utilities.Miner;
5
-import org.springframework.beans.BeanUtils;
4
+import com.zipcoin.service.BlockService;
6 5
 import org.springframework.beans.factory.annotation.Autowired;
7 6
 import org.springframework.web.bind.annotation.*;
8
-import com.zipcoin.repository.BlockRepository;
9 7
 
10
-import java.util.List;
11
-import java.util.Optional;
8
+import java.util.Collection;
9
+
10
+import static com.zipcoin.config.BlockApis.BASE_BLOCK_URL;
11
+import static com.zipcoin.config.BlockApis.GET_MINED_BLOCK_BY_ID;
12 12
 
13 13
 @RestController
14
-@RequestMapping("api/v1/")
15 14
 @CrossOrigin(origins = {"http://localhost:8100"})
16 15
 public class BlockController {
17 16
 
18
-    @Autowired
19
-    private BlockRepository blockRepository;
17
+    private BlockService blockService;
20 18
 
21
-    @RequestMapping(value = "blocks", method = RequestMethod.POST)
22
-    public Block create(@RequestBody Block block){
23
-        return blockRepository.saveAndFlush(block);
24
-    }
25
-
26
-    @RequestMapping(value = "blocks/{id}", method = RequestMethod.GET)
27
-    public Optional<Block> get(@PathVariable Long id){
28
-        return blockRepository.findById(id);
19
+    @Autowired
20
+    public BlockController(BlockService blockService){
21
+        this.blockService = blockService;
29 22
     }
30 23
 
31
-    @RequestMapping(value = "blocks", method = RequestMethod.GET)
32
-    public List<Block> get(){
33
-        return blockRepository.findAll();
24
+    @PostMapping(path = BASE_BLOCK_URL)
25
+    public Block createBlock(@RequestBody Block block){
26
+        return blockService.createBlock(block);
34 27
     }
35 28
 
36
-    @RequestMapping(value = "blocks/{id}", method = RequestMethod.DELETE)
37
-    public Block delete(@PathVariable Long id){
38
-        Block blockToDelete = blockRepository.findOne(id);
39
-        blockRepository.delete(blockToDelete);
40
-        return blockToDelete;
29
+    @GetMapping(path = BASE_BLOCK_URL)
30
+    public Collection<Block> getAllBlocks(){
31
+        return blockService.getAllBlocks();
41 32
     }
42 33
 
43
-    @RequestMapping(value = "blocks/{id}/mine", method = RequestMethod.GET)
44
-    public Block mine(@PathVariable Long id){
45
-        Block blockToMine = blockRepository.findOne(id);
46
-        Miner miner = new Miner();
47
-        Block minedBlock = miner.mine(blockToMine);
48
-        return blockRepository.saveAndFlush(minedBlock);
34
+    @GetMapping(path = GET_MINED_BLOCK_BY_ID)
35
+    public Block getMinedBlockById(@PathVariable Long id){
36
+        return blockService.getMinedBlockById(id);
49 37
     }
50 38
 }

+ 11
- 8
ZipCoinRedJavaServer/src/main/java/com/zipcoin/controller/WalletController.java View File

@@ -7,8 +7,11 @@ import org.springframework.web.bind.annotation.*;
7 7
 
8 8
 import java.util.Collection;
9 9
 
10
+import static com.zipcoin.config.WalletApis.BASE_WALLET_URL;
11
+import static com.zipcoin.config.WalletApis.GET_ALL_WALLET_PUBLIC_KEYS;
12
+import static com.zipcoin.config.WalletApis.GET_WALLET_BY_PUBLIC_KEY;
13
+
10 14
 @RestController
11
-@RequestMapping("api/v1/")
12 15
 @CrossOrigin(origins = {"http://localhost:8100"})
13 16
 public class WalletController {
14 17
 
@@ -19,24 +22,24 @@ public class WalletController {
19 22
         this.walletService = walletService;
20 23
     }
21 24
 
22
-    @PostMapping(path = "wallets")
25
+    @PostMapping(path = BASE_WALLET_URL)
23 26
     public Wallet createWallet(@RequestBody Wallet wallet){
24 27
         return walletService.createWallet(wallet);
25 28
     }
26 29
 
27
-    @GetMapping(path = "wallets")
30
+    @GetMapping(path = BASE_WALLET_URL)
28 31
     public Collection<Wallet> getAllWallets() {
29 32
         return walletService.getAllWallets();
30 33
     }
31 34
 
32
-    @GetMapping(path = "wallets/{publicKey}")
35
+    @GetMapping(path = GET_WALLET_BY_PUBLIC_KEY)
33 36
     public Wallet getWalletByPublicKey(@PathVariable String publicKey){
34 37
         return walletService.getWalletByPublicKey(publicKey);
35 38
     }
36 39
 
37
-    @GetMapping(value = "wallets/publicKeys")
38
-    public Collection<String> getAllPublicKeys(){
39
-        return walletService.getAllPublicKeys();
40
-    }
40
+//    @GetMapping(path = GET_ALL_WALLET_PUBLIC_KEYS)
41
+//    public Collection<Object[]> getAllPublicKeys(){
42
+//        return walletService.getAllPublicKeys();
43
+//    }
41 44
 
42 45
 }

+ 3
- 44
ZipCoinRedJavaServer/src/main/java/com/zipcoin/model/Block.java View File

@@ -1,10 +1,13 @@
1 1
 package com.zipcoin.model;
2 2
 
3
+import lombok.Getter;
4
+import lombok.Setter;
3 5
 import org.apache.commons.codec.digest.DigestUtils;
4 6
 
5 7
 import javax.persistence.*;
6 8
 
7 9
 @Entity
10
+@Getter @Setter
8 11
 public class Block {
9 12
 
10 13
     @Id
@@ -40,46 +43,10 @@ public class Block {
40 43
         nonce=0;
41 44
     }
42 45
 
43
-    public void setId(Long id) {
44
-        this.id = id;
45
-    }
46
-
47
-    public Long getId() {
48
-        return id;
49
-    }
50
-
51
-    public void setBlockNumber(Integer blockNumber) {
52
-        this.blockNumber = blockNumber;
53
-    }
54
-
55
-    public Integer getBlockNumber() {
56
-        return blockNumber;
57
-    }
58
-
59
-    public void setPreviousHash(String previousHash) {
60
-        this.previousHash = previousHash;
61
-    }
62
-
63
-    public String getPreviousHash() {
64
-        return previousHash;
65
-    }
66
-
67
-    public void setNonce(Integer nonce) {
68
-        this.nonce = nonce;
69
-    }
70
-
71 46
     public void iterateNonce() {
72 47
         this.nonce ++;
73 48
     }
74 49
 
75
-    public Integer getNonce() {
76
-        return nonce;
77
-    }
78
-
79
-    public void setCurrentHash(String currentHash) {
80
-        this.currentHash = currentHash;
81
-    }
82
-
83 50
     public String getCurrentHash() {
84 51
         updateCurrentHash();
85 52
         return currentHash;
@@ -92,14 +59,6 @@ public class Block {
92 59
         currentHash = DigestUtils.sha256Hex(text).toUpperCase();
93 60
     }
94 61
 
95
-    public String getTransactionList() {
96
-        return transactionList;
97
-    }
98
-
99
-    public void setTransactionList(String transactionList) {
100
-        this.transactionList = transactionList;
101
-    }
102
-
103 62
     public void addTransaction(String transaction){
104 63
         transactionList += transaction;
105 64
     }

+ 4
- 0
ZipCoinRedJavaServer/src/main/java/com/zipcoin/model/Chain.java View File

@@ -1,7 +1,11 @@
1 1
 package com.zipcoin.model;
2 2
 
3
+import lombok.Getter;
4
+import lombok.Setter;
5
+
3 6
 import java.util.ArrayList;
4 7
 
8
+@Getter @Setter
5 9
 public class Chain {
6 10
 
7 11
     Block block = new Block(0);

+ 10
- 50
ZipCoinRedJavaServer/src/main/java/com/zipcoin/model/Transaction.java View File

@@ -1,80 +1,40 @@
1 1
 package com.zipcoin.model;
2 2
 
3
+import lombok.Getter;
4
+import lombok.Setter;
3 5
 import org.apache.commons.codec.digest.DigestUtils;
4 6
 
5 7
 import javax.persistence.*;
6 8
 
7
-
8 9
 @Entity
10
+@Getter @Setter
9 11
 public class Transaction {
12
+
10 13
     @Id
11 14
     @GeneratedValue(strategy = GenerationType.AUTO)
12 15
     private Long transactionId;
13
-
14 16
     private String sender;
15 17
     private String recipient;
16 18
     private float amount;
17
-
18 19
     //@OneToMany
19
-  /*  private List<Integer> coins;*/
20
-
21
-
22
-
20
+    //private List<Integer> coins;
23 21
     //public Signature signature;
24
-    public Transaction()
25
-    {
22
+
23
+    public Transaction() {
26 24
 
27 25
     }
28 26
 
29
-    public Transaction(String from, String to, float amount/*List<Integer> coins*/) {
27
+    public Transaction(String from, String to, float amount/*,List<Integer> coins*/) {
30 28
         this.sender = from;
31 29
         this.recipient = to;
32 30
         this.amount = amount;
33 31
         //this.coins=coins;
34
-
35
-    }
36
-
37
-    public Long getTransactionId() {
38
-        return transactionId;
39
-    }
40
-
41
-    public void setTransactionId(Long transactionId) {
42
-        this.transactionId = transactionId;
43
-    }
44
-
45
-    public String getSender() {
46
-        return sender;
47
-    }
48
-
49
-    public void setSender(String sender) {
50
-        this.sender = sender;
51
-    }
52
-
53
-    public String getRecipient() {
54
-        return recipient;
55
-    }
56
-
57
-    public void setRecipient(String recipient) {
58
-        this.recipient = recipient;
59 32
     }
60 33
 
61
-    public float getAmount() { return amount; }
62
-
63
-    public void setAmount(float amount) { this.amount = amount; }
64
-
65
-    /*public List<Integer> getCoins() { return coins; }
66
-
67
-    public void setCoins(List<Integer> coins) { this.coins = coins; }*/
68
-
69 34
     private String calculateHash() {
70
-
71
-        return DigestUtils.sha256Hex(
72
-                sender +
73
-                        recipient +
74
-
75
-                        Float.toString(amount)
76
-        );
35
+        return DigestUtils.sha256Hex(sender + recipient + Float.toString(amount));
77 36
     }
37
+
78 38
 //    public void generateSignature(PrivateKey privateKey) throws NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException {
79 39
 //        String data = StringUtil.getStringFromKey(sender) + StringUtil.getStringFromKey(reciepient) + Float.toString(value)    ;
80 40
 //        signature = StringUtil.applyECDSASig(privateKey,data);

+ 11
- 44
ZipCoinRedJavaServer/src/main/java/com/zipcoin/model/Wallet.java View File

@@ -1,6 +1,8 @@
1 1
 package com.zipcoin.model;
2 2
 
3 3
 import com.zipcoin.utilities.StringUtil;
4
+import lombok.Getter;
5
+import lombok.Setter;
4 6
 
5 7
 import javax.persistence.Entity;
6 8
 import javax.persistence.GeneratedValue;
@@ -10,62 +12,30 @@ import java.security.*;
10 12
 import java.util.Random;
11 13
 
12 14
 @Entity
15
+@Getter @Setter
13 16
 public class Wallet {
14 17
 
15 18
     @Id
16 19
     @GeneratedValue(strategy = GenerationType.AUTO)
17 20
     private int id;
18
-
19
-    public String getName() {
20
-        return name;
21
-    }
22
-
23
-    public void setName(String name) {
24
-        this.name = name;
25
-    }
26
-
27
-    public String getPublickey() {
28
-        return publickey;
29
-    }
30
-
31
-    public void setPublickey(String publickey) {
32
-        this.publickey = publickey;
33
-    }
34
-
35 21
     private String name;
36
-    private String publickey;
22
+    private String publicKey;
37 23
     private Double amount;
38 24
 
39
-    public Wallet()
40
-    {
25
+    public Wallet() {
41 26
         generateKeyPair();
42
-
43 27
     }
44
-    public Wallet(String name,String publickey,double amount)
45
-    {
28
+
29
+    public Wallet(String name, String publicKey, double amount) {
46 30
         this.name=name;
47
-        this.publickey=publickey;
31
+        this.publicKey=publicKey;
48 32
         this.amount=amount;
49 33
     }
50 34
 
51
-    public Double getAmount()
52
-    {
53
-        return amount;
54
-    }
55
-
56
-    public void setAmount(Double amount)
57
-    {
58
-        this.amount = amount;
59
-    }
60
-
61
-
62
-    public String getPublicKey()
63
-    {
64
-        return publickey;
65
-    }
66
-
67
-
68 35
     public void generateKeyPair() {
36
+        Random random =new SecureRandom();
37
+        Integer random10digit= random.nextInt(10);
38
+        publicKey=random10digit.toString();
69 39
 //        try {
70 40
 //
71 41
 //            KeyPairGenerator keyGen = KeyPairGenerator.getInstance( "DSA","SUN");
@@ -84,9 +54,6 @@ public class Wallet {
84 54
 //        } catch (Exception e) {
85 55
 //            throw new RuntimeException(e);
86 56
 //        }
87
-        Random random =new SecureRandom();
88
-        Integer random10digit= random.nextInt(10);
89
-        publickey=random10digit.toString();
90 57
     }
91 58
 
92 59
 }

+ 3
- 1
ZipCoinRedJavaServer/src/main/java/com/zipcoin/repository/WalletRepository.java View File

@@ -10,5 +10,7 @@ import java.util.List;
10 10
 
11 11
 public interface WalletRepository extends JpaRepository<Wallet, Long> {
12 12
     Wallet findWalletByPublicKey(String publicKey);
13
-    Collection<String> findAllPublicKeys();
13
+
14
+//    @Query(value = "SELECT publicKey FROM Wallet", nativeQuery = true)
15
+//    Collection<Object[]> findAllPublicKey();
14 16
 }

+ 41
- 0
ZipCoinRedJavaServer/src/main/java/com/zipcoin/service/BlockService.java View File

@@ -0,0 +1,41 @@
1
+package com.zipcoin.service;
2
+
3
+import com.zipcoin.model.Block;
4
+import com.zipcoin.repository.BlockRepository;
5
+import com.zipcoin.utilities.Miner;
6
+import org.springframework.beans.factory.annotation.Autowired;
7
+import org.springframework.stereotype.Service;
8
+
9
+import java.util.Collection;
10
+import java.util.Optional;
11
+
12
+@Service
13
+public class BlockService {
14
+
15
+    private BlockRepository blockRepository;
16
+
17
+    @Autowired
18
+    public BlockService(BlockRepository blockRepository){
19
+        this.blockRepository = blockRepository;
20
+    }
21
+
22
+    public Block createBlock(Block block) {
23
+        return blockRepository.saveAndFlush(block);
24
+    }
25
+
26
+    public Collection<Block> getAllBlocks() {
27
+        return blockRepository.findAll();
28
+    }
29
+
30
+    public Block getMinedBlockById(Long id) {
31
+        Optional<Block> blockToMine = blockRepository.findById(id);
32
+        if (blockToMine.isPresent()) {
33
+            Miner miner = new Miner();
34
+            Block minedBlock = miner.mine(blockToMine.get());
35
+            return blockRepository.saveAndFlush(minedBlock);
36
+        } else {
37
+            return null;
38
+        }
39
+    }
40
+
41
+}

+ 0
- 1
ZipCoinRedJavaServer/src/main/java/com/zipcoin/service/TransactionService.java View File

@@ -1,7 +1,6 @@
1 1
 package com.zipcoin.service;
2 2
 
3 3
 import com.zipcoin.model.Transaction;
4
-import com.zipcoin.model.Wallet;
5 4
 import com.zipcoin.repository.TransactionRepository;
6 5
 import org.springframework.beans.factory.annotation.Autowired;
7 6
 import org.springframework.stereotype.Service;

+ 3
- 3
ZipCoinRedJavaServer/src/main/java/com/zipcoin/service/WalletService.java View File

@@ -29,8 +29,8 @@ public class WalletService {
29 29
         return walletRepository.findWalletByPublicKey(publicKey);
30 30
     }
31 31
 
32
-    public Collection<String> getAllPublicKeys() {
33
-        return walletRepository.findAllPublicKeys();
34
-    }
32
+//    public Collection<Object[]> getAllPublicKeys() {
33
+//        return walletRepository.findAllPublicKey();
34
+//    }
35 35
 
36 36
 }