Reformat code
This commit is contained in:
@@ -8,7 +8,7 @@ struct EncodedBlock {
|
||||
let bytes: Int
|
||||
let checksum: UInt32
|
||||
|
||||
// Binary format: degree(4) + indices(4*n) + k(4) + bytes(4) + checksum(4) + data
|
||||
/// Binary format: degree(4) + indices(4*n) + k(4) + bytes(4) + checksum(4) + data
|
||||
func toBinary() -> Data {
|
||||
var result = Data()
|
||||
|
||||
|
||||
@@ -12,19 +12,26 @@ final class LubyTransformDecoder {
|
||||
private var disposedEncodedBlocks: [Int: [() -> Void]] = [:]
|
||||
private(set) var meta: EncodedBlock?
|
||||
|
||||
var k: Int { meta?.k ?? 0 }
|
||||
var k: Int {
|
||||
meta?.k ?? 0
|
||||
}
|
||||
|
||||
var progress: Double {
|
||||
guard k > 0 else { return 0 }
|
||||
return Double(decodedCount) / Double(k)
|
||||
}
|
||||
|
||||
var isComplete: Bool { meta != nil && decodedCount == k }
|
||||
var isComplete: Bool {
|
||||
meta != nil && decodedCount == k
|
||||
}
|
||||
|
||||
private class BlockWrapper: Hashable {
|
||||
var block: EncodedBlock
|
||||
let id = UUID()
|
||||
|
||||
init(_ block: EncodedBlock) { self.block = block }
|
||||
init(_ block: EncodedBlock) {
|
||||
self.block = block
|
||||
}
|
||||
|
||||
static func == (lhs: BlockWrapper, rhs: BlockWrapper) -> Bool {
|
||||
lhs.id == rhs.id
|
||||
|
||||
@@ -92,7 +92,7 @@ final class LubyTransformEncoder {
|
||||
)
|
||||
}
|
||||
|
||||
// Ideal Soliton Distribution for degree selection
|
||||
/// Ideal Soliton Distribution for degree selection
|
||||
private func getRandomDegree() -> Int {
|
||||
guard k > 1 else { return k }
|
||||
var probabilities = [Double](repeating: 0, count: k)
|
||||
|
||||
Reference in New Issue
Block a user