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

perf: do not use byte32 serializer #283

Merged
merged 1 commit into from
Jan 25, 2021
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
10 changes: 7 additions & 3 deletions lib/ckb/serializers/code_hash_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@ class CodeHashSerializer

# @param code_hash [String]
def initialize(code_hash)
@byte32_serializer = Byte32Serializer.new(code_hash)
@item = if code_hash
code_hash.start_with?("0x") ? code_hash[2..-1] : code_hash
else
""
end
end

private

attr_reader :byte32_serializer
attr_reader :item

def layout
body
end

def body
byte32_serializer.serialize[2..-1]
item
end
end
end
Expand Down
10 changes: 7 additions & 3 deletions lib/ckb/serializers/header_dep_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@ class HeaderDepSerializer

# @param header_dep [String]
def initialize(header_dep)
@byte32_serializer = Byte32Serializer.new(header_dep)
@item = if header_dep
header_dep.start_with?("0x") ? header_dep[2..-1] : header_dep
else
""
end
end

private

attr_reader :byte32_serializer
attr_reader :item

def layout
body
end

def body
byte32_serializer.serialize[2..-1]
item
end
end
end
Expand Down
10 changes: 7 additions & 3 deletions lib/ckb/serializers/out_point_tx_hash_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@ class OutPointTxHashSerializer

# @param tx_hash [String]
def initialize(tx_hash)
@byte32_serializer = Byte32Serializer.new(tx_hash)
@item = if tx_hash
tx_hash.start_with?("0x") ? tx_hash[2..-1] : tx_hash
else
""
end
end

private

attr_reader :byte32_serializer
attr_reader :item

def layout
body
end

def body
byte32_serializer.serialize[2..-1]
item
end
end
end
Expand Down