Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
parity-bitcoin
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
parity-bitcoin
Commits
7c75c535
Unverified
Commit
7c75c535
authored
5 years ago
by
Svyatoslav Nikolsky
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #575 from JosephGoulden/fix-todo-redundant-copy
fix: remove redundant copy of signature in interpreter.rs
parents
b283eca9
ab277d12
Branches
Branches containing commit
No related merge requests found
Pipeline
#72879
failed with stages
in 3 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
script/src/interpreter.rs
+12
-16
12 additions, 16 deletions
script/src/interpreter.rs
with
12 additions
and
16 deletions
script/src/interpreter.rs
+
12
−
16
View file @
7c75c535
...
...
@@ -12,8 +12,8 @@ use {
/// Helper function.
fn
check_signature
(
checker
:
&
dyn
SignatureChecker
,
mut
script_sig
:
Vec
<
u8
>
,
public
:
Vec
<
u8
>
,
script_sig
:
&
Vec
<
u8
>
,
public
:
&
Vec
<
u8
>
,
script_code
:
&
Script
,
version
:
SignatureVersion
)
->
bool
{
...
...
@@ -22,14 +22,11 @@ fn check_signature(
_
=>
return
false
,
};
if
script_sig
.is_empty
()
{
return
false
;
if
let
Some
((
hash_type
,
sig
))
=
script_sig
.split_last
()
{
checker
.check_signature
(
&
sig
.into
(),
&
public
,
script_code
,
*
hash_type
as
u32
,
version
)
}
else
{
return
false
}
let
hash_type
=
script_sig
.pop
()
.unwrap
()
as
u32
;
let
signature
=
script_sig
.into
();
checker
.check_signature
(
&
signature
,
&
public
,
script_code
,
hash_type
,
version
)
}
/// Helper function.
...
...
@@ -1038,7 +1035,7 @@ pub fn eval_script(
check_signature_encoding
(
&
signature
,
flags
,
version
)
?
;
check_pubkey_encoding
(
&
pubkey
,
flags
)
?
;
let
success
=
check_signature
(
checker
,
signature
.into
()
,
pubkey
.into
()
,
&
subscript
,
version
);
let
success
=
check_signature
(
checker
,
&
signature
,
&
pubkey
,
&
subscript
,
version
);
match
opcode
{
Opcode
::
OP_CHECKSIG
=>
{
if
success
{
...
...
@@ -1088,14 +1085,13 @@ pub fn eval_script(
let
mut
k
=
0
;
let
mut
s
=
0
;
while
s
<
sigs
.len
()
&&
success
{
// TODO: remove redundant copying
let
key
=
keys
[
k
]
.clone
();
let
sig
=
sigs
[
s
]
.clone
();
let
key
=
&
keys
[
k
];
let
sig
=
&
sigs
[
s
];
check_signature_encoding
(
&
sig
,
flags
,
version
)
?
;
check_pubkey_encoding
(
&
key
,
flags
)
?
;
check_signature_encoding
(
sig
,
flags
,
version
)
?
;
check_pubkey_encoding
(
key
,
flags
)
?
;
let
ok
=
check_signature
(
checker
,
sig
.into
(),
key
.into
()
,
&
subscript
,
version
);
let
ok
=
check_signature
(
checker
,
sig
,
key
,
&
subscript
,
version
);
if
ok
{
s
+=
1
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment