Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Ercoin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
3
Issues
3
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ercoin
Ercoin
Commits
9f8ba2bc
Verified
Commit
9f8ba2bc
authored
Nov 14, 2018
by
Krzysztof Jurewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Truncate fresh transactions in BeginBlock
parent
ef882ee0
Pipeline
#36630092
failed with stages
in 5 minutes and 13 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
16 deletions
+16
-16
ercoin_abci.erl
src/ercoin_abci.erl
+1
-3
ercoin_data.erl
src/ercoin_data.erl
+3
-2
ercoin_abci_tests.erl
test/ercoin_abci_tests.erl
+0
-11
ercoin_data_tests.erl
test/ercoin_data_tests.erl
+12
-0
No files found.
src/ercoin_abci.erl
View file @
9f8ba2bc
...
...
@@ -84,7 +84,6 @@ handle_event(
fresh_txs
=
FreshTxs
,
validators
=
Validators
,
future_validators
=
FutureValidators
})
->
NewHeight
=
Height
+
1
,
Diffs
=
case
EpochStage
of
drawing_to_be_announced
->
...
...
@@ -92,8 +91,7 @@ handle_event(
_
->
[]
end
,
NewFreshTxs
=
lists
:
dropwhile
(
fun
({
TxTimestamp
,
_})
->
TxTimestamp
<
Timestamp
-
EpochLength
end
,
FreshTxs
),
Data1
=
Data
#data
{
height
=
NewHeight
,
fresh_txs
=
NewFreshTxs
},
Data1
=
Data
#data
{
height
=
Height
+
1
},
{
keep_state
,
Data1
,
{
reply
,
From
,
#'abci.ResponseEndBlock'
{
validator_updates
=
Diffs
}}};
handle_event
({
call
,
From
},
#'abci.RequestDeliverTx'
{
tx
=
MaybeTxBin
},
committing
,
Data
)
->
{
ErrorCode
,
NewData
}
=
ercoin_tx
:
handle_bin
(
MaybeTxBin
,
Data
),
...
...
src/ercoin_data.erl
View file @
9f8ba2bc
...
...
@@ -106,8 +106,9 @@ grant_fee_deposits(
Data1
#data
{
fee_deposit_short
=
0
,
fee_deposit_long
=
DepositLong
-
DisposedDepositLong
}.
-
spec
shift_to_timestamp
(
ercoin_timestamp
:
timestamp
(),
data
())
->
data
().
shift_to_timestamp
(
Timestamp
,
Data
)
->
remove_old_and_unlock_accounts
(
Data
#data
{
timestamp
=
Timestamp
}).
shift_to_timestamp
(
Timestamp
,
Data
=
#data
{
epoch_length
=
EpochLength
,
fresh_txs
=
FreshTxs
})
->
NewFreshTxs
=
lists
:
dropwhile
(
fun
({
TxTimestamp
,
_})
->
TxTimestamp
<
Timestamp
-
EpochLength
end
,
FreshTxs
),
remove_old_and_unlock_accounts
(
Data
#data
{
timestamp
=
Timestamp
,
fresh_txs
=
NewFreshTxs
}).
-
spec
now
(
data
())
->
ercoin_timestamp
:
timestamp
().
now
(
Data
=
#data
{
now_fun
=
F
})
->
...
...
test/ercoin_abci_tests.erl
View file @
9f8ba2bc
...
...
@@ -106,17 +106,6 @@ prop_end_block_increments_height() ->
data
(),
get_value
(
height
,
end_block
(
Data
))
=:=
get_value
(
height
,
Data
)
+
1
).
prop_end_block_truncates_fresh_txs
()
->
%% TODO: Move this to BeginBlock.
?
FORALL
(
Data
,
data
(),
begin
FreshTxs
=
Data
#data.fresh_txs
,
#data
{
fresh_txs
=
NewFreshTxs
,
timestamp
=
Timestamp
}
=
end_block
(
Data
),
NewFreshTxs
=:=
?
SETS
:
filter
(
fun
({
TxTimestamp
,
_
Tx
})
->
TxTimestamp
>=
Timestamp
-
Data
#data.epoch_length
end
,
FreshTxs
)
end
).
prop_deliver_tx_handles_binary_in_regard_to_data
()
->
?
FORALL
(
{
Data
,
MaybeTxBin
},
...
...
test/ercoin_data_tests.erl
View file @
9f8ba2bc
...
...
@@ -32,6 +32,18 @@ prop_shift_to_timestamp_expires_and_unlocks_some_accounts() ->
Data
#data.accounts
)
end
).
prop_shift_to_timestamp_truncates_fresh_txs
()
->
?
FORALL
(
{
Data
,
TimestampDiff
},
{
ercoin_gen
:
data
(),
non_neg_integer
()},
begin
NewTimestamp
=
Data
#data.timestamp
+
TimestampDiff
,
(
ercoin_data
:
shift_to_timestamp
(
NewTimestamp
,
Data
))
#data.fresh_txs
=:=
?
SETS
:
filter
(
fun
({
TxTimestamp
,
_
Tx
})
->
TxTimestamp
>=
NewTimestamp
-
Data
#data.epoch_length
end
,
Data
#data.fresh_txs
)
end
).
prop_fee_deposit_granting
()
->
?
FORALL
(
Data
=
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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