Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
open-runtime-module-library
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Noxim
open-runtime-module-library
Commits
a8cfd422
Unverified
Commit
a8cfd422
authored
4 years ago
by
Shaopeng Wang
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Oracle feed_values: index in bound proof. (#231)
parent
a67c4719
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
oracle/src/lib.rs
+6
-4
6 additions, 4 deletions
oracle/src/lib.rs
with
6 additions
and
4 deletions
oracle/src/lib.rs
+
6
−
4
View file @
a8cfd422
...
...
@@ -69,7 +69,7 @@ type MomentOf<T> = <<T as Trait>::Time as Time>::Moment;
pub
type
TimestampedValueOf
<
T
>
=
TimestampedValue
<<
T
as
Trait
>
::
OracleValue
,
MomentOf
<
T
>>
;
/// Number of blocks before an unconfirmed unsigned transaction expires.
pub
const
EXTRINSIC_LONGVITY
:
u32
=
100
;
pub
const
EXTRINSIC_LONG
E
VITY
:
u32
=
100
;
#[derive(Encode,
Decode,
RuntimeDebug,
Eq,
PartialEq,
Clone,
Copy)]
#[cfg_attr(feature
=
"std"
,
derive(Serialize,
Deserialize))]
...
...
@@ -160,7 +160,9 @@ decl_module! {
)
{
ensure_none
(
origin
.clone
())
.or_else
(|
_
|
ensure_root
(
origin
))
?
;
// validate_unsigned already unsure index is valid
let
who
=
Self
::
members
()
.0
[
index
as
usize
]
.clone
();
let
who
=
Self
::
members
()
.0
.get
(
index
as
usize
)
.expect
(
"`validate_unsigned` ensures index is in bound; qed`"
)
.clone
();
Self
::
do_feed_values
(
who
,
values
);
}
...
...
@@ -307,7 +309,7 @@ impl<T: Trait> frame_support::unsigned::ValidateUnsigned for Module<T> {
if
let
Call
::
feed_values
(
value
,
index
,
block
,
signature
)
=
call
{
let
now
=
<
frame_system
::
Module
<
T
>>
::
block_number
();
if
now
>
*
block
+
EXTRINSIC_LONGVITY
.into
()
{
if
now
>
*
block
+
EXTRINSIC_LONG
E
VITY
.into
()
{
return
Err
(
InvalidTransaction
::
Stale
.into
());
}
if
now
<
*
block
{
...
...
@@ -345,7 +347,7 @@ impl<T: Trait> frame_support::unsigned::ValidateUnsigned for Module<T> {
ValidTransaction
::
with_tag_prefix
(
"orml-oracle"
)
.priority
(
T
::
UnsignedPriority
::
get
()
.saturating_add
(
add_priority
))
.and_provides
((
who
,
nonce
))
.longevity
(
EXTRINSIC_LONGVITY
.into
())
.longevity
(
EXTRINSIC_LONG
E
VITY
.into
())
.propagate
(
true
)
.build
()
}
else
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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