Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dunixir
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
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
teaching
dunixir
Merge requests
!16
Indexes
Code
Review changes
Check out branch
Download
Patches
Plain diff
Closed
Indexes
indexes
into
dev
Overview
0
Commits
13
Pipelines
0
Changes
4
Closed
BENARD Julien
requested to merge
indexes
into
dev
4 years ago
Overview
0
Commits
13
Pipelines
0
Changes
4
Expand
0
0
Merge request reports
Viewing commit
d1b3baf8
Prev
Next
Show latest version
4 files
+
396
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
d1b3baf8
local index now in ets tables 2,d try
· d1b3baf8
Etienne Ferrieux
authored
4 years ago
dunixir_2/lib/document_processor_ets.ex
0 → 100644
+
199
−
0
Options
defmodule
Document
.
Processor
.
ETS
do
def
add_identity
(
blockstamp
,
local_iindex
,
local_mindex
,%{
"pub"
=>
pub
,
"block_uid"
=>
block_uid
,
"user_id"
=>
user_id
})
do
:ok
=
Local
.
ETS
.
I
.
Index
.
insert
(
local_iindex
,%{
op:
"CREATE"
,
uid:
user_id
,
pub:
pub
,
created_on:
block_uid
,
written_on:
blockstamp
,
member:
true
,
wasMember:
true
,
kick:
false
})
:ok
=
Local
.
ETS
.
M
.
Index
.
insert
(
local_mindex
,%{
op:
"CREATE"
,
pub:
pub
,
created_on:
block_uid
,
written_on:
blockstamp
,
expired_on:
0
,
expires_on:
Constants
.
medianTime
+
Constants
.
msValidity
,
revokes_on:
Constants
.
medianTime
+
Constants
.
msValidity
*
2
,
chainable_on:
Constants
.
medianTime
+
Constants
.
msPeriod
,
type:
"JOIN"
,
revocation:
nil
,
revoked_on:
nil
,
leaving:
false
})
:ok
end
def
add_joiner
(
blockstamp
,
local_iindex
,
local_mindex
,
%{
"pub"
=>
pub
,
"m_block_uid"
=>
m_block_uid
,
"i_block_uid"
=>
_i_block_uid
,
"user_id"
=>
_user_id
})
do
match_create
=
!
(
:ets
.
match
(
local_iindex
,{
:"$1"
,%{
op:
"CREATE"
,
pub:
pub
}})
==
[])
case
match_create
do
false
->
:ok
=
Local
.
ETS
.
I
.
Index
.
insert
(
local_iindex
,
%{
op:
"UPDATE"
,
pub:
pub
,
uid:
nil
,
created_on:
nil
,
written_on:
blockstamp
,
member:
true
,
wasMember:
nil
,
kick:
nil
})
:ok
=
Local
.
ETS
.
M
.
Index
.
insert
(
local_mindex
,%{
op:
"UPDATE"
,
pub:
pub
,
created_on:
m_block_uid
,
#ambiguité de la spec (m ou i ?)
written_on:
blockstamp
,
expired_on:
0
,
expires_on:
Constants
.
medianTime
+
Constants
.
msValidity
,
revokes_on:
Constants
.
medianTime
+
Constants
.
msValidity
*
2
,
chainable_on:
Constants
.
medianTime
+
Constants
.
msPeriod
,
type:
"JOIN"
,
revocation:
nil
,
revoked_on:
nil
,
leaving:
nil
})
:ok
_
->
:ok
end
end
def
add_active
(
blockstamp
,
local_mindex
,%{
"pub"
=>
pub
,
"m_block_uid"
=>
m_block_uid
,
"i_block_uid"
=>
_i_block_uid
,
"user_id"
=>
_user_id
})
do
:ok
=
Local
.
ETS
.
M
.
Index
.
insert
(
local_mindex
,%{
op:
"UPDATE"
,
pub:
pub
,
created_on:
m_block_uid
,
#ambiguité de la spec (m ou i ?)
written_on:
blockstamp
,
expired_on:
0
,
expires_on:
Constants
.
medianTime
+
Constants
.
msValidity
,
revokes_on:
Constants
.
medianTime
+
Constants
.
msValidity
*
2
,
chainable_on:
Constants
.
medianTime
+
Constants
.
msPeriod
,
type:
"RENEW"
,
revoked_on:
nil
,
revocation:
nil
,
leaving:
nil
})
:ok
end
def
add_leaver
(
blockstamp
,
local_mindex
,%{
"pub"
=>
pub
,
"m_block_uid"
=>
m_block_uid
,
"i_block_uid"
=>
_i_block_uid
,
"user_id"
=>
_user_id
})
do
:ok
=
Local
.
ETS
.
M
.
Index
.
insert
(
local_mindex
,%{
op:
"UPDATE"
,
pub:
pub
,
created_on:
m_block_uid
,
#ambiguité de la spec (m ou i ?)
written_on:
blockstamp
,
expired_on:
0
,
expires_on:
nil
,
revokes_on:
nil
,
chainable_on:
nil
,
type:
"LEAVE"
,
revoked_on:
Constants
.
medianTime
,
revocation:
nil
,
leaving:
true
})
:ok
end
def
add_revoked
(
blockstamp
,
local_mindex
,%{
"pub"
=>
pub
,
"sig"
=>
sig
})
do
:ok=
Local
.
ETS
.
M
.
Index
.
insert
(
local_mindex
,%{
op:
"UPDATE"
,
pub:
pub
,
created_on:
nil
,
#ambiguité de la spec (BLOCK_UID???)
written_on:
blockstamp
,
expired_on:
0
,
expires_on:
nil
,
revokes_on:
nil
,
chainable_on:
nil
,
type:
"REV"
,
revoked_on:
Constants
.
medianTime
,
revocation:
sig
,
leaving:
false
}
)
:ok
end
def
add_excluded
(
blockstamp
,
local_iindex
,%{
"pub"
=>
pub
})
do
:ok
=
Local
.
ETS
.
I
.
Index
.
insert
(
local_iindex
,
%{
op:
"UPDATE"
,
uid:
nil
,
pub:
pub
,
created_on:
nil
,
written_on:
blockstamp
,
member:
false
,
wasMember:
nil
,
kick:
false
})
:ok
end
def
add_certification
(
blockstamp
,
local_cindex
,%{
"from"
=>
from
,
"to"
=>
to
,
"block_id"
=>
block_id
,
"sig"
=>
sig
})
do
:ok
=
Local
.
ETS
.
C
.
Index
.
insert
(
local_cindex
,%{
op:
"CREATE"
,
issuer:
from
,
receiver:
to
,
created_on:
block_id
,
written_on:
blockstamp
,
sig:
sig
,
expires_on:
Constants
.
medianTime
+
Constants
.
sigValidity
,
expired_on:
0
,
chainable_on:
Constants
.
medianTime
+
Constants
.
sigPeriod
,
replayable_on:
Constants
.
medianTime
+
Constants
.
sigReplay
})
:ok
end
def
add_tx_input
(
blockstamp
,
local_sindex
,%{
"tx_hash"
=>
tx_hash
,
"input_identifier"
=>
input_identifier
,
"input_index"
=>
input_index
,
"tx_blockstamp"
=>
tx_blockstamp
,
"input_amount"
=>
input_amount
,
"input_base"
=>
input_base
})
do
:ok
=
Local
.
ETS
.
S
.
Index
.
insert
(
local_sindex
,
%{
op:
"UPDATE"
,
tx:
tx_hash
,
identifier:
input_identifier
,
pos:
input_index
,
written_on:
blockstamp
,
created_on:
tx_blockstamp
,
written_time:
nil
,
amount:
input_amount
,
base:
input_base
,
locktime:
nil
,
conditions:
nil
,
consumed:
true
})
:ok
end
def
add_tx_output
(
blockstamp
,
local_sindex
,
%{
"tx_hash"
=>
tx_hash
,
"output_index"
=>
output_index
,
"output_amount"
=>
output_amount
,
"output_base"
=>
output_base
,
"locktime"
=>
locktime
,
"conditions"
=>
conditions
})
do
:ok
=
Local
.
ETS
.
S
.
Index
.
insert
(
local_sindex
,
%{
op:
"CREATE"
,
tx:
tx_hash
,
identifier:
tx_hash
,
pos:
output_index
,
written_on:
blockstamp
,
created_on:
nil
,
written_time:
Constants
.
medianTime
,
amount:
output_amount
,
base:
output_base
,
locktime:
locktime
,
conditions:
conditions
,
consumed:
false
})
:ok
end
end
Loading