Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev mackun #64

Merged
merged 5 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ target

# static lib files
.lib/
tasks.json
4 changes: 2 additions & 2 deletions Blockchain/Sources/Blockchain/Runtime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ public final class Runtime {
item.blocks += 1
item.tickets += UInt32(block.extrinsic.tickets.tickets.count)
item.preimages += UInt32(block.extrinsic.preimages.preimages.count)
item.preimagesBytes += UInt32(block.extrinsic.preimages.preimages.reduce(into: 0) { $0 += $1.size })

// try to change preimage size to serviceIndices
item.preimagesBytes += UInt32(block.extrinsic.preimages.preimages.reduce(into: 0) { $0 += $1.serviceIndices })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is wrong. it doesn't make sense to add service indices

acc[block.header.authorIndex] = item

for report in block.extrinsic.reports.guarantees {
Expand Down
10 changes: 5 additions & 5 deletions Blockchain/Sources/Blockchain/Types/ExtrinsicPreimages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import Utils

public struct ExtrinsicPreimages: Sendable, Equatable {
public struct SizeAndData: Sendable, Equatable {
public var size: DataLength
public var serviceIndices: ServiceIndices
public var data: Data

public init(size: DataLength, data: Data) {
self.size = size
public init(serviceIndices: ServiceIndices, data: Data) {
self.serviceIndices = serviceIndices
self.data = data
}
}
Expand Down Expand Up @@ -44,13 +44,13 @@ extension ExtrinsicPreimages: ScaleCodec.Codable {
extension ExtrinsicPreimages.SizeAndData: ScaleCodec.Codable {
public init(from decoder: inout some ScaleCodec.Decoder) throws {
try self.init(
size: decoder.decode(),
serviceIndices: decoder.decode(),
data: decoder.decode()
)
}

public func encode(in encoder: inout some ScaleCodec.Encoder) throws {
try encoder.encode(size)
try encoder.encode(serviceIndices)
try encoder.encode(data)
}
}
2 changes: 2 additions & 0 deletions Blockchain/Sources/Blockchain/Types/primitives.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ public typealias Balances = UInt64
public typealias ServiceIdentifier = Data32
public typealias TimeslotIndex = UInt32
public typealias Gas = UInt64
public typealias ServiceIndices = UInt32
public typealias DataLength = UInt32

public typealias ValidatorIndex = UInt32 // TODO: confirm this
public typealias CoreIndex = UInt32 // TODO: confirm this
public typealias TicketIndex = UInt8
Expand Down
Loading