Skip to content

Commit

Permalink
update chainhandler
Browse files Browse the repository at this point in the history
  • Loading branch information
MacOMNI committed Feb 7, 2025
1 parent 9a4c110 commit 80043ad
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions RPC/Sources/RPC/Handlers/ChainHandlers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,6 @@ import Codec
import Foundation
import Utils

extension Set<Data32> {
func encode() throws -> Data {
var data = Data(capacity: count * 32)
for element in self {
data.append(element.data)
}
return data
}
}

public enum ChainHandlers {
public static let handlers: [any RPCHandler.Type] = [
GetBlock.self,
Expand Down Expand Up @@ -71,7 +61,7 @@ public enum ChainHandlers {
public func handle(request: Request) async throws -> Response? {
if let timeslot = request.value {
let block = try await source.getBlockHash(byTimeslot: timeslot)
return try block.encode()
return block.reduce(into: Data(capacity: block.count * 32)) { $0.append($1.data) }
}
return nil

Check warning on line 66 in RPC/Sources/RPC/Handlers/ChainHandlers.swift

View check run for this annotation

Codecov / codecov/patch

RPC/Sources/RPC/Handlers/ChainHandlers.swift#L66

Added line #L66 was not covered by tests
}
Expand Down

0 comments on commit 80043ad

Please sign in to comment.