Skip to content

Commit abb4932

Browse files
committed
Minor Updates..
1 parent 073e4e7 commit abb4932

File tree

6 files changed

+67
-58
lines changed

6 files changed

+67
-58
lines changed

Example/Images.xcassets/AppIcon.appiconset/Contents.json

+15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
{
22
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"size" : "20x20",
6+
"scale" : "2x"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"size" : "20x20",
11+
"scale" : "3x"
12+
},
313
{
414
"idiom" : "iphone",
515
"size" : "29x29",
@@ -29,6 +39,11 @@
2939
"idiom" : "iphone",
3040
"size" : "60x60",
3141
"scale" : "3x"
42+
},
43+
{
44+
"idiom" : "ios-marketing",
45+
"size" : "1024x1024",
46+
"scale" : "1x"
3247
}
3348
],
3449
"info" : {

Source/Factories/Blockchain.swift

+10-37
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ public class Blockchain: Graph {
2121
threshold = ithreshold
2222
super.init(directed: false)
2323

24-
25-
//initialize network
24+
2625
chain.append(genesisBlock())
2726
}
2827

@@ -31,7 +30,6 @@ public class Blockchain: Graph {
3130
//MARK: helper functions
3231

3332

34-
3533
//starting block
3634
private func genesisBlock()-> Block {
3735

@@ -40,11 +38,15 @@ public class Blockchain: Graph {
4038
firstBlock.id = blockIdentifier()
4139
firstBlock.description = "Genesis Block"
4240

43-
self.broadcast(block: firstBlock)
44-
4541
return firstBlock
4642
}
43+
4744

45+
//broadcast latest block to peers
46+
func broadcast(to peer: inout Peer) {
47+
peer.chain = self.chain
48+
}
49+
4850

4951

5052
//obtain latest block
@@ -59,27 +61,10 @@ public class Blockchain: Graph {
5961
}
6062

6163

62-
//update network
63-
private func broadcast(block: Block) {
64-
65-
/*
66-
note: all participating network peers receive their
67-
own copy of the newly created block.
68-
*/
69-
70-
for vPeer in self.canvas {
71-
if let bPeer = vPeer as? Peer {
72-
bPeer.chain.append(block)
73-
}
74-
}
75-
76-
}
77-
78-
7964

8065

8166
class Miner {
82-
67+
8368

8469
//poll the network for pending exchanges..
8570
func poll(startingv: Vertex, network: Blockchain) {
@@ -128,22 +113,10 @@ public class Blockchain: Graph {
128113
*/
129114

130115
let newBlock = self.createBlock(for: network)
131-
132-
133-
network.broadcast(block: newBlock)
134116

135-
/*
136-
note: all participating network peers receive their
137-
own copy of the newly created block.
138-
*/
139-
/*
140-
for vPeer in network.canvas {
141-
if var bPeer = vPeer as? Peer {
142-
network.add(block: newBlock, peer: &bPeer)
143-
}
144-
}
145-
*/
146117

118+
//update main network chain
119+
network.chain.append(newBlock)
147120

148121
}
149122

Source/Factories/Graph.swift

-3
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,6 @@ public class Graph {
359359

360360
while !graphQueue.isEmpty() {
361361

362-
//traverse the next queued vertex - Swift 4.0
363-
//let vitem = graphQueue.deQueue() as Vertex!
364-
365362

366363
//traverse the next queued vertex
367364
guard let vitem = graphQueue.deQueue() else {

SwiftStructures.xcodeproj/xcuserdata/waynebishop.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

+32-16
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
ignoreCount = "0"
1111
continueAfterRunningActions = "No"
1212
filePath = "Source/Factories/Graph.swift"
13-
timestampString = "562204869.682559"
13+
timestampString = "562269789.402064"
1414
startingColumnNumber = "9223372036854775807"
1515
endingColumnNumber = "9223372036854775807"
1616
startingLineNumber = "296"
@@ -26,7 +26,7 @@
2626
ignoreCount = "0"
2727
continueAfterRunningActions = "No"
2828
filePath = "SwiftTests/LearningTest.swift"
29-
timestampString = "562203213.45533"
29+
timestampString = "562265835.782315"
3030
startingColumnNumber = "9223372036854775807"
3131
endingColumnNumber = "9223372036854775807"
3232
startingLineNumber = "67"
@@ -38,50 +38,66 @@
3838
<BreakpointProxy
3939
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
4040
<BreakpointContent
41-
shouldBeEnabled = "Yes"
41+
shouldBeEnabled = "No"
4242
ignoreCount = "0"
4343
continueAfterRunningActions = "No"
44-
filePath = "SwiftTests/BlockTest.swift"
45-
timestampString = "562204869.682894"
44+
filePath = "Source/Factories/Blockchain.swift"
45+
timestampString = "562269789.402235"
4646
startingColumnNumber = "9223372036854775807"
4747
endingColumnNumber = "9223372036854775807"
48-
startingLineNumber = "53"
49-
endingLineNumber = "53"
50-
landmarkName = "testMiningBlock()"
48+
startingLineNumber = "119"
49+
endingLineNumber = "119"
50+
landmarkName = "poll(startingv:network:)"
5151
landmarkType = "7">
5252
</BreakpointContent>
5353
</BreakpointProxy>
5454
<BreakpointProxy
5555
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
5656
<BreakpointContent
57-
shouldBeEnabled = "Yes"
57+
shouldBeEnabled = "No"
5858
ignoreCount = "0"
5959
continueAfterRunningActions = "No"
6060
filePath = "Source/Factories/Blockchain.swift"
61-
timestampString = "562205095.236864"
61+
timestampString = "562269789.402325"
6262
startingColumnNumber = "9223372036854775807"
6363
endingColumnNumber = "9223372036854775807"
64-
startingLineNumber = "76"
65-
endingLineNumber = "76"
64+
startingLineNumber = "84"
65+
endingLineNumber = "84"
6666
landmarkName = "poll(startingv:network:)"
6767
landmarkType = "7">
6868
</BreakpointContent>
6969
</BreakpointProxy>
7070
<BreakpointProxy
7171
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
7272
<BreakpointContent
73-
shouldBeEnabled = "Yes"
73+
shouldBeEnabled = "No"
7474
ignoreCount = "0"
7575
continueAfterRunningActions = "No"
7676
filePath = "Source/Factories/Blockchain.swift"
77-
timestampString = "562206718.554189"
77+
timestampString = "562269789.402403"
7878
startingColumnNumber = "9223372036854775807"
7979
endingColumnNumber = "9223372036854775807"
80-
startingLineNumber = "115"
81-
endingLineNumber = "115"
80+
startingLineNumber = "126"
81+
endingLineNumber = "126"
8282
landmarkName = "poll(startingv:network:)"
8383
landmarkType = "7">
8484
</BreakpointContent>
8585
</BreakpointProxy>
86+
<BreakpointProxy
87+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
88+
<BreakpointContent
89+
shouldBeEnabled = "Yes"
90+
ignoreCount = "0"
91+
continueAfterRunningActions = "No"
92+
filePath = "SwiftTests/BlockTest.swift"
93+
timestampString = "562269789.402478"
94+
startingColumnNumber = "9223372036854775807"
95+
endingColumnNumber = "9223372036854775807"
96+
startingLineNumber = "57"
97+
endingLineNumber = "57"
98+
landmarkName = "testPollForExchanges()"
99+
landmarkType = "7">
100+
</BreakpointContent>
101+
</BreakpointProxy>
86102
</Breakpoints>
87103
</Bucket>

SwiftTests/BlockTest.swift

+10-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class BlockTest: XCTestCase {
3434

3535
//add the edges
3636
bitcoin.addEdge(source: PeerA, neighbor: PeerB, weight: 1)
37-
bitcoin.addEdge(source: PeerB, neighbor: PeerC, weight: 1)
37+
bitcoin.addEdge(source: PeerA, neighbor: PeerC, weight: 1)
3838
bitcoin.addEdge(source: PeerB, neighbor: PeerD, weight: 1)
3939

4040

@@ -48,9 +48,17 @@ class BlockTest: XCTestCase {
4848

4949

5050
//miners monitor the peer network for intended transactions
51-
func testMiningBlock() {
51+
func testPollForExchanges() {
52+
5253
let miner = Blockchain.Miner()
5354
miner.poll(startingv: PeerA, network: bitcoin)
55+
56+
57+
bitcoin.broadcast(to: &PeerA)
58+
bitcoin.broadcast(to: &PeerB)
59+
bitcoin.broadcast(to: &PeerC)
60+
bitcoin.broadcast(to: &PeerD)
61+
5462
}
5563

5664

0 commit comments

Comments
 (0)