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
3f391a6c
Unverified
Commit
3f391a6c
authored
4 years ago
by
wangjj9219
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
update db read and write (#242)
parent
89141df1
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
auction/src/lib.rs
+34
-10
34 additions, 10 deletions
auction/src/lib.rs
currencies/src/lib.rs
+13
-11
13 additions, 11 deletions
currencies/src/lib.rs
tokens/src/lib.rs
+8
-8
8 additions, 8 deletions
tokens/src/lib.rs
vesting/src/lib.rs
+12
-12
12 additions, 12 deletions
vesting/src/lib.rs
with
67 additions
and
41 deletions
auction/src/lib.rs
+
34
−
10
View file @
3f391a6c
...
...
@@ -14,7 +14,7 @@
use
frame_support
::{
decl_error
,
decl_event
,
decl_module
,
decl_storage
,
ensure
,
traits
::
Get
,
weights
::
constants
::
WEIGHT_PER_MICROS
,
IterableStorageDoubleMap
,
Parameter
,
weights
::
Weight
,
IterableStorageDoubleMap
,
Parameter
,
};
use
frame_system
::
ensure_signed
;
use
orml_traits
::{
Auction
,
AuctionHandler
,
AuctionInfo
,
Change
};
...
...
@@ -76,21 +76,39 @@ decl_module! {
/// - T::Handler is module_auction_manager of Acala
/// - Indirectly needs orml_currencies and module_cdp_treasury of Acala
/// - Complexity: `O(1)`
/// - Db reads: `Auctions`, 2 items of module_auction_manager, 4 items of orml_currencies, 2 items of module_cdp_treasury
/// - Db writes: `Auctions`, 2 items of module_auction_manager, 4 items of orml_currencies, 2 items of module_cdp_treasury
/// - Db reads:
/// - collateral auction:
/// - best cases: 7
/// - worst cases: 14
/// - surplus auction:
/// - best cases: 5
/// - worst cases: 6
/// - debit auction:
/// - best cases: 8
/// - worst cases: 7
/// - Db writes:
/// - collateral auction:
/// - best cases: 7
/// - worst cases: 14
/// - surplus auction:
/// - best cases: 3
/// - worst cases: 5
/// - debit auction:
/// - best cases: 8
/// - worst cases: 8
/// -------------------
/// Base Weight:
/// - collateral auction:
/// - best cases:
49.61
µs
/// - worst cases:
83.65
µs
/// - best cases:
134
µs
/// - worst cases:
300.4
µs
/// - surplus auction:
/// - best cases:
42.67
µs
/// - worst cases:
49.7
6 µs
/// - best cases:
97.9
µs
/// - worst cases:
157.
6 µs
/// - debit auction:
/// - best cases:
45.96
µs
/// - worst cases:
48.55
µs
/// - best cases:
140.7
µs
/// - worst cases:
142.8
µs
/// # </weight>
#[weight
=
84
*
WEIGHT_PER_MICROS
+
T::DbWeight::get()
.
reads_writes(
9
,
9
)]
#[weight
=
300
*
WEIGHT_PER_MICROS
+
T::DbWeight::get()
.
reads_writes(
14
,
14
)]
pub
fn
bid
(
origin
,
id
:
T
::
AuctionId
,
#[compact]
value
:
T
::
Balance
)
{
let
from
=
ensure_signed
(
origin
)
?
;
...
...
@@ -135,6 +153,12 @@ decl_module! {
Self
::
deposit_event
(
RawEvent
::
Bid
(
id
,
from
,
value
));
}
/// dummy `on_initialize` to return the weight used in `on_finalize`.
fn
on_initialize
()
->
Weight
{
// weight of `on_finalize`
0
}
fn
on_finalize
(
now
:
T
::
BlockNumber
)
{
Self
::
_on_finalize
(
now
);
}
...
...
This diff is collapsed.
Click to expand it.
currencies/src/lib.rs
+
13
−
11
View file @
3f391a6c
...
...
@@ -134,14 +134,14 @@ decl_module! {
/// - T::MultiCurrency is orml_tokens
/// - T::NativeCurrency is pallet_balances
/// - Complexity: `O(1)`
/// - Db reads:
2 * `Accounts`
/// - Db writes: 2
* `Accounts`
/// - Db reads:
5
/// - Db writes: 2
/// -------------------
/// Base Weight:
/// - non-native currency:
26.72
µs
/// - native currency in worst case:
29.9
µs
/// - non-native currency:
90.23
µs
/// - native currency in worst case:
70
µs
/// # </weight>
#[weight
=
3
0
*
WEIGHT_PER_MICROS
+
T::DbWeight::get()
.
reads_writes(
2
,
2
)]
#[weight
=
9
0
*
WEIGHT_PER_MICROS
+
T::DbWeight::get()
.
reads_writes(
2
,
2
)]
pub
fn
transfer
(
origin
,
dest
:
<
T
::
Lookup
as
StaticLookup
>
::
Source
,
...
...
@@ -165,9 +165,9 @@ decl_module! {
/// - Db reads: 2 * `Accounts`
/// - Db writes: 2 * `Accounts`
/// -------------------
/// Base Weight:
29.53
µs
/// Base Weight:
70
µs
/// # </weight>
#[weight
=
3
0
*
WEIGHT_PER_MICROS
+
T::DbWeight::get()
.
reads_writes(
2
,
2
)]
#[weight
=
7
0
*
WEIGHT_PER_MICROS
+
T::DbWeight::get()
.
reads_writes(
2
,
2
)]
pub
fn
transfer_native_currency
(
origin
,
dest
:
<
T
::
Lookup
as
StaticLookup
>
::
Source
,
...
...
@@ -189,15 +189,17 @@ decl_module! {
/// - T::MultiCurrency is orml_tokens
/// - T::NativeCurrency is pallet_balances
/// - Complexity: `O(1)`
/// - Db reads: `Accounts`
/// - Db writes: `Accounts`
/// - Db reads:
/// - non-native currency: 5
/// - Db writes:
/// - non-native currency: 2
/// -------------------
/// Base Weight:
/// - non-native currency:
25.36
µs
/// - non-native currency:
66.24
µs
/// - native currency and killing account: 26.33 µs
/// - native currency and create account: 27.39 µs
/// # </weight>
#[weight
=
27
*
WEIGHT_PER_MICROS
+
T::DbWeight::get()
.
reads_writes(
1
,
1
)]
#[weight
=
66
*
WEIGHT_PER_MICROS
+
T::DbWeight::get()
.
reads_writes(
5
,
2
)]
pub
fn
update_balance
(
origin
,
who
:
<
T
::
Lookup
as
StaticLookup
>
::
Source
,
...
...
This diff is collapsed.
Click to expand it.
tokens/src/lib.rs
+
8
−
8
View file @
3f391a6c
...
...
@@ -199,12 +199,12 @@ decl_module! {
///
/// # <weight>
/// - Complexity: `O(1)`
/// - Db reads:
2 * `Accounts`
/// - Db writes: 2
* `Accounts`
/// - Db reads:
4
/// - Db writes: 2
/// -------------------
/// Base Weight:
26.65
µs
/// Base Weight:
84.08
µs
/// # </weight>
#[weight
=
27
*
WEIGHT_PER_MICROS
+
T::DbWeight::get()
.
reads_writes(
2
,
2
)]
#[weight
=
84
*
WEIGHT_PER_MICROS
+
T::DbWeight::get()
.
reads_writes(
4
,
2
)]
pub
fn
transfer
(
origin
,
dest
:
<
T
::
Lookup
as
StaticLookup
>
::
Source
,
...
...
@@ -224,12 +224,12 @@ decl_module! {
///
/// # <weight>
/// - Complexity: `O(1)`
/// - Db reads:
2 * `Accounts`
/// - Db writes: 2
* `Accounts`
/// - Db reads:
4
/// - Db writes: 2
/// -------------------
/// Base Weight:
26.99
µs
/// Base Weight:
87.71
µs
/// # </weight>
#[weight
=
27
*
WEIGHT_PER_MICROS
+
T::DbWeight::get()
.
reads_writes(
2
,
2
)]
#[weight
=
88
*
WEIGHT_PER_MICROS
+
T::DbWeight::get()
.
reads_writes(
4
,
2
)]
pub
fn
transfer_all
(
origin
,
dest
:
<
T
::
Lookup
as
StaticLookup
>
::
Source
,
...
...
This diff is collapsed.
Click to expand it.
vesting/src/lib.rs
+
12
−
12
View file @
3f391a6c
...
...
@@ -179,12 +179,12 @@ decl_module! {
/// - Preconditions:
/// - T::Currency is orml_currencies
/// - Complexity: `O(1)`
/// - Db reads:
`VestingSchedules`, 3 items of orml_currencies
/// - Db writes:
`VestingSchedules`, 3 items of orml_currencies
/// - Db reads:
3
/// - Db writes:
3
/// -------------------
/// Base Weight:
29.86
µs
/// Base Weight:
65.23
µs
/// # </weight>
#[weight
=
30
*
WEIGHT_PER_MICROS
+
T::DbWeight::get()
.
reads_writes(
2
,
2
)]
#[weight
=
30
*
WEIGHT_PER_MICROS
+
T::DbWeight::get()
.
reads_writes(
3
,
3
)]
pub
fn
claim
(
origin
)
{
let
who
=
ensure_signed
(
origin
)
?
;
let
locked_amount
=
Self
::
do_claim
(
&
who
);
...
...
@@ -196,12 +196,12 @@ decl_module! {
/// - Preconditions:
/// - T::Currency is orml_currencies
/// - Complexity: `O(1)`
/// - Db reads:
`VestingSchedules`, 3 items of orml_currencies
/// - Db writes:
`VestingSchedules`, 3 items of orml_currencies
/// - Db reads:
4
/// - Db writes:
4
/// -------------------
/// Base Weight:
47.26
µs
/// Base Weight:
150.4
µs
/// # </weight>
#[weight
=
48
*
WEIGHT_PER_MICROS
+
T::DbWeight::get()
.
reads_writes(
4
,
4
)]
#[weight
=
150
*
WEIGHT_PER_MICROS
+
T::DbWeight::get()
.
reads_writes(
4
,
4
)]
pub
fn
vested_transfer
(
origin
,
dest
:
<
T
::
Lookup
as
StaticLookup
>
::
Source
,
...
...
@@ -218,12 +218,12 @@ decl_module! {
/// - Preconditions:
/// - T::Currency is orml_currencies
/// - Complexity: `O(1)`
/// - Db reads:
`VestingSchedules`, 3 items of orml_currencies
/// - Db writes:
`VestingSchedules`, 3 items of orml_currencies
/// - Db reads:
2
/// - Db writes:
3
/// -------------------
/// Base Weight:
27.96
µs
/// Base Weight:
61.87
µs
/// # </weight>
#[weight
=
2
8
*
WEIGHT_PER_MICROS
+
T::DbWeight::get()
.
reads_writes(
4
,
4
)]
#[weight
=
6
2
*
WEIGHT_PER_MICROS
+
T::DbWeight::get()
.
reads_writes(
2
,
3
)]
pub
fn
update_vesting_schedules
(
origin
,
who
:
<
T
::
Lookup
as
StaticLookup
>
::
Source
,
...
...
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