Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
parity-bitcoin
Commits
7c75c535
Unverified
Commit
7c75c535
authored
Dec 28, 2019
by
Svyatoslav Nikolsky
Committed by
GitHub
Dec 28, 2019
Browse files
Merge pull request #575 from JosephGoulden/fix-todo-redundant-copy
fix: remove redundant copy of signature in interpreter.rs
parents
b283eca9
ab277d12
Pipeline
#72879
failed with stages
in 3 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
script/src/interpreter.rs
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
;
}
...
...
Write
Preview
Supports
Markdown
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!
Cancel
Please
register
or
sign in
to comment