@@ -22,9 +22,46 @@ public final class NodeDataSource: Sendable {
2222 }
2323}
2424
25- extension NodeDataSource : SystemDataSource { }
25+ extension NodeDataSource : SystemDataSource {
26+ public func getProperties( ) async throws -> JSON {
27+ // TODO: Get a custom set of properties as a JSON object, defined in the chain spec
28+ JSON . array ( [ ] )
29+ }
30+
31+ public func getChainName( ) async throws -> String {
32+ blockchain. config. value. presetName ( ) ?? " "
33+ }
34+
35+ public func getNodeRoles( ) async throws -> [ String ] {
36+ // TODO: Returns the roles the node is running as.
37+ [ ]
38+ }
39+
40+ public func getVersion( ) async throws -> String {
41+ // TODO: From spec or config
42+ " 0.0.1 "
43+ }
44+
45+ public func getHealth( ) async throws -> Bool {
46+ // TODO: Check health status
47+ true
48+ }
49+
50+ public func getImplementation( ) async throws -> String {
51+ name
52+ }
53+ }
2654
2755extension NodeDataSource : ChainDataSource {
56+ public func getKeys( prefix: Data32 , count: UInt32 , startKey: Data32 ? , blockHash: Data32 ? ) async throws -> [ String ] {
57+ // TODO:
58+ try await chainDataProvider. getKeys ( prefix: prefix, count: count, startKey: startKey, blockHash: blockHash)
59+ }
60+
61+ public func getStorage( key: Data32 , blockHash: Utils . Data32 ? ) async throws -> [ String ] {
62+ try await chainDataProvider. getStorage ( key: key, blockHash: blockHash)
63+ }
64+
2865 public func getBestBlock( ) async throws -> BlockRef {
2966 try await chainDataProvider. getBlock ( hash: chainDataProvider. bestHead. hash)
3067 }
@@ -37,6 +74,18 @@ extension NodeDataSource: ChainDataSource {
3774 let state = try await chainDataProvider. getState ( hash: blockHash)
3875 return try await state. value. read ( key: key)
3976 }
77+
78+ public func getBlockHash( byTimeslot timeslot: TimeslotIndex ) async throws -> Set < Data32 > {
79+ try await chainDataProvider. getBlockHash ( byTimeslot: timeslot)
80+ }
81+
82+ public func getHeader( hash: Data32 ) async throws -> HeaderRef ? {
83+ try await chainDataProvider. getHeader ( hash: hash)
84+ }
85+
86+ public func getFinalizedHead( ) async throws -> Data32 ? {
87+ try await chainDataProvider. getFinalizedHead ( )
88+ }
4089}
4190
4291extension NodeDataSource : TelemetryDataSource {
@@ -47,4 +96,8 @@ extension NodeDataSource: TelemetryDataSource {
4796 public func getPeersCount( ) async throws -> Int {
4897 networkManager. peersCount
4998 }
99+
100+ public func getNetworkKey( ) async throws -> String {
101+ networkManager. network. networkKey
102+ }
50103}
0 commit comments