Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xlc committed Jul 17, 2024
1 parent 6035c83 commit 51f5908
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Blockchain/Sources/Blockchain/Blockchain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class Blockchain {
}

private func addState(_ state: StateRef) {
stateByBlockHash[state.value.lastBlock.header.hash] = state
stateByBlockHash[state.value.lastBlock.header.hash()] = state
stateByTimeslot[state.value.lastBlock.header.timeslotIndex, default: []].append(state)
}
}
Expand Down
8 changes: 6 additions & 2 deletions Blockchain/Sources/Blockchain/Types/Header.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ extension Header: ScaleCodec.Encodable {
}

extension Header {
public func hash() throws -> Data32 {
try blake2b256(ScaleCodec.encode(self))
public func hash() -> Data32 {
do {
return try blake2b256(ScaleCodec.encode(self))
} catch let e {
fatalError("Failed to hash header: \(e)")
}
}
}

0 comments on commit 51f5908

Please sign in to comment.