Skip to content

Commit

Permalink
Dev mackun (#64)
Browse files Browse the repository at this point in the history
* #update  ignore

* try to fix ExtrinsicPreimages issue

* fix fixedSizeData issue

* try to fix ExtrinsicPreimages issue

* #update Preimages serviceIndices
  • Loading branch information
MacOMNI authored Aug 19, 2024
1 parent 5a69280 commit a99a6ae
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
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 })
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

0 comments on commit a99a6ae

Please sign in to comment.