Skip to content
GitLab
Explore
Sign in
parity
Mirrored projects
ink-workshop
Compare revisions
033e1a86cac0ed82293b87e1ca34893370889a09 to 8e279513f390447db1384586ddcfe5bc8ed1bece
Commits on Source (2)
Reduce gas budget to a quarter
· 688615a9
Alexander Theißen
authored
Feb 07, 2023
688615a9
Allow game creator to start early
· 8e279513
Alexander Theißen
authored
Feb 07, 2023
8e279513
Hide whitespace changes
Inline
Side-by-side
game/lib.rs
View file @
8e279513
...
...
@@ -63,6 +63,8 @@ mod contract {
rounds
:
u32
,
/// The block number the last turn was made.
last_turn
:
Lazy
<
u32
>
,
/// The opener is allowed to start the game early.
opener
:
AccountId
,
}
#[derive(scale::Decode,
scale::Encode)]
...
...
@@ -273,6 +275,7 @@ mod contract {
buy_in
,
rounds
,
last_turn
:
Default
::
default
(),
opener
:
Self
::
env
()
.caller
(),
};
ret
.players
.set
(
&
Vec
::
new
());
ret
...
...
@@ -306,7 +309,8 @@ mod contract {
pub
fn
start_game
(
&
mut
self
)
{
if
let
State
::
Forming
{
earliest_start
}
=
self
.state
{
assert!
(
Self
::
env
()
.block_number
()
>=
earliest_start
,
Self
::
env
()
.caller
()
==
self
.opener
||
Self
::
env
()
.block_number
()
>=
earliest_start
,
"Game can't be started, yet."
);
}
else
{
...
...
@@ -626,7 +630,7 @@ mod contract {
}
fn
calc_gas_budget
(
gas_limit
:
u64
,
num_rounds
:
u32
)
->
u64
{
gas_limit
*
u64
::
from
(
num_rounds
)
/
3
gas_limit
*
u64
::
from
(
num_rounds
)
/
4
}
fn
players
(
&
self
)
->
Vec
<
Player
>
{
...
...