From d05b2b0b39ade75195f1653568d5accef5a7df69 Mon Sep 17 00:00:00 2001 From: decanus Date: Sun, 17 Mar 2019 13:19:07 +0100 Subject: [PATCH 1/4] Started working on node --- Package.swift | 13 +++++++++++-- Sources/Node/main.swift | 2 ++ Tests/NodeTests/XCTestManifests.swift | 8 ++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 Sources/Node/main.swift create mode 100644 Tests/NodeTests/XCTestManifests.swift diff --git a/Package.swift b/Package.swift index cf042c1..4bb46da 100644 --- a/Package.swift +++ b/Package.swift @@ -9,7 +9,10 @@ let package = Package( // Products define the executables and libraries produced by a package, and make them visible to other packages. .library( name: "BeaconChain", - targets: ["BeaconChain"]) + targets: ["BeaconChain"]), + .executable( + name: "Node", + targets: ["Node"]) ], dependencies: [ // Dependencies declare other packages that this package depends on. @@ -21,8 +24,14 @@ let package = Package( .target( name: "BeaconChain", dependencies: []), + .target( + name: "Node", + dependencies: ["BeaconChain"]), .testTarget( name: "BeaconChainTests", - dependencies: ["BeaconChain"]) + dependencies: ["BeaconChain"]), + .testTarget( + name: "NodeTests", + dependencies: ["Node"]) ] ) diff --git a/Sources/Node/main.swift b/Sources/Node/main.swift new file mode 100644 index 0000000..fbf2875 --- /dev/null +++ b/Sources/Node/main.swift @@ -0,0 +1,2 @@ +import Foundation + diff --git a/Tests/NodeTests/XCTestManifests.swift b/Tests/NodeTests/XCTestManifests.swift new file mode 100644 index 0000000..f9ce505 --- /dev/null +++ b/Tests/NodeTests/XCTestManifests.swift @@ -0,0 +1,8 @@ +import XCTest + +#if !os(macOS) +public func allTests() -> [XCTestCaseEntry] { + return [ + ] +} +#endif From 4342ec3db6efad5da2df1f39bc07d801ee6ed7ac Mon Sep 17 00:00:00 2001 From: decanus Date: Sun, 17 Mar 2019 13:33:23 +0100 Subject: [PATCH 2/4] Store stub --- .../DataStructures/Blocks/BeaconBlock.swift | 2 +- .../Attestations/Attestation.swift | 2 +- Sources/BeaconChain/Types.swift | 2 +- Sources/Node/Store/TestStore.swift | 19 +++++++++++++++++++ 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 Sources/Node/Store/TestStore.swift diff --git a/Sources/BeaconChain/DataStructures/Blocks/BeaconBlock.swift b/Sources/BeaconChain/DataStructures/Blocks/BeaconBlock.swift index 0a06d2b..3d81314 100644 --- a/Sources/BeaconChain/DataStructures/Blocks/BeaconBlock.swift +++ b/Sources/BeaconChain/DataStructures/Blocks/BeaconBlock.swift @@ -1,6 +1,6 @@ import Foundation -struct BeaconBlock { +public struct BeaconBlock { let slot: UInt64 let parentRoot: Data let stateRoot: Data diff --git a/Sources/BeaconChain/DataStructures/Transactions/Attestations/Attestation.swift b/Sources/BeaconChain/DataStructures/Transactions/Attestations/Attestation.swift index 906b060..6fef20e 100644 --- a/Sources/BeaconChain/DataStructures/Transactions/Attestations/Attestation.swift +++ b/Sources/BeaconChain/DataStructures/Transactions/Attestations/Attestation.swift @@ -1,6 +1,6 @@ import Foundation -struct Attestation { +public struct Attestation { let aggregationBitfield: Data let data: AttestationData let custodyBitfield: Data diff --git a/Sources/BeaconChain/Types.swift b/Sources/BeaconChain/Types.swift index 7e02de6..e57221f 100644 --- a/Sources/BeaconChain/Types.swift +++ b/Sources/BeaconChain/Types.swift @@ -3,7 +3,7 @@ import Foundation typealias Slot = UInt64 typealias Epoch = UInt64 typealias Shard = UInt64 -typealias ValidatorIndex = UInt64 +public typealias ValidatorIndex = UInt64 typealias Gwei = UInt64 typealias Bytes32 = Data // @todo needs to be 32 fixed length data typealias BLSPubkey = Data // @todo needs to be 48 fixed length data diff --git a/Sources/Node/Store/TestStore.swift b/Sources/Node/Store/TestStore.swift new file mode 100644 index 0000000..e239b89 --- /dev/null +++ b/Sources/Node/Store/TestStore.swift @@ -0,0 +1,19 @@ +import BeaconChain + +class TestStore { + func parent(_ block: BeaconBlock) -> BeaconBlock { + + } + + func children(_ block: BeaconBlock) -> [BeaconBlock] { + + } + + func latestAttestation(validator: ValidatorIndex) -> Attestation { + + } + + func latestAttestationTarget(validator: ValidatorIndex) -> BeaconBlock { + + } +} From 7249e7a12baa616a753d8aa937192ebe9eb68b03 Mon Sep 17 00:00:00 2001 From: decanus Date: Mon, 18 Mar 2019 17:55:13 +0100 Subject: [PATCH 3/4] implemented --- Sources/Node/Store/TestStore.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Node/Store/TestStore.swift b/Sources/Node/Store/TestStore.swift index e239b89..1d0f7e4 100644 --- a/Sources/Node/Store/TestStore.swift +++ b/Sources/Node/Store/TestStore.swift @@ -1,6 +1,6 @@ import BeaconChain -class TestStore { +class TestStore: Store { func parent(_ block: BeaconBlock) -> BeaconBlock { } From 2ec3c10bbdb4c113ee904ee334994348837094e2 Mon Sep 17 00:00:00 2001 From: decanus Date: Mon, 18 Mar 2019 19:48:20 +0100 Subject: [PATCH 4/4] public --- Sources/BeaconChain/Store/Store.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/BeaconChain/Store/Store.swift b/Sources/BeaconChain/Store/Store.swift index 199cfb5..baba99f 100644 --- a/Sources/BeaconChain/Store/Store.swift +++ b/Sources/BeaconChain/Store/Store.swift @@ -1,6 +1,6 @@ import Foundation -protocol Store { +public protocol Store { func parent(_ block: BeaconBlock) -> BeaconBlock func children(_ block: BeaconBlock) -> [BeaconBlock]