Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
duniter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
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
nodes
typescript
duniter
Merge requests
!1280
#1358
: Remove Loki related code
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
#1358
: Remove Loki related code
rm_loki
into
dev
Overview
0
Commits
1
Pipelines
0
Changes
17
Merged
Moul
requested to merge
rm_loki
into
dev
6 years ago
Overview
0
Commits
1
Pipelines
0
Changes
17
Expand
0
0
Merge request reports
Compare
dev
version 2
ec90437b
6 years ago
version 1
6c860815
6 years ago
dev (base)
and
latest version
latest version
ec90437b
1 commit,
6 years ago
version 2
ec90437b
1 commit,
6 years ago
version 1
6c860815
1 commit,
6 years ago
17 files
+
0
−
1369
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
17
Search (e.g. *.vue) (Ctrl+P)
app/lib/dal/indexDAL/loki/LokiBIndex.ts deleted
100644 → 0
+
0
−
99
Options
import
{
DBHead
}
from
"
../../../db/DBHead
"
import
{
BIndexDAO
}
from
"
../abstract/BIndexDAO
"
import
{
NewLogger
}
from
"
../../../logger
"
import
{
MonitorLokiExecutionTime
}
from
"
../../../debug/MonitorLokiExecutionTime
"
import
{
LokiProtocolIndex
}
from
"
./LokiProtocolIndex
"
import
{
MonitorExecutionTime
}
from
"
../../../debug/MonitorExecutionTime
"
const
logger
=
NewLogger
()
export
class
LokiBIndex
extends
LokiProtocolIndex
<
DBHead
>
implements
BIndexDAO
{
private
HEAD
:
DBHead
|
null
=
null
constructor
(
loki
:
any
)
{
super
(
loki
,
'
bindex
'
,
[
'
number
'
,
'
hash
'
])
}
@
MonitorExecutionTime
()
async
insert
(
record
:
DBHead
):
Promise
<
void
>
{
this
.
HEAD
=
record
return
super
.
insert
(
record
);
}
@
MonitorExecutionTime
()
async
removeBlock
(
blockstamp
:
string
):
Promise
<
void
>
{
this
.
HEAD
=
await
this
.
head
(
2
)
return
super
.
removeBlock
(
blockstamp
);
}
@
MonitorExecutionTime
()
async
head
(
n
:
number
):
Promise
<
DBHead
>
{
if
(
!
n
)
{
throw
"
Cannot read HEAD~0, which is the incoming block
"
}
if
(
n
===
1
&&
this
.
HEAD
)
{
// Cached
return
this
.
HEAD
}
else
if
(
this
.
HEAD
)
{
// Another than HEAD
return
this
.
collection
.
find
({
number
:
this
.
HEAD
.
number
-
n
+
1
})[
0
]
}
else
{
// Costly method, as a fallback
return
this
.
collection
.
chain
()
.
find
({})
.
simplesort
(
'
number
'
,
true
)
.
data
()[
n
-
1
]
}
}
@
MonitorExecutionTime
()
async
range
(
n
:
number
,
m
:
number
):
Promise
<
DBHead
[]
>
{
if
(
!
n
)
{
throw
"
Cannot read HEAD~0, which is the incoming block
"
}
const
HEAD
=
await
this
.
head
(
1
)
if
(
!
HEAD
)
{
return
[]
}
return
this
.
collection
.
chain
()
.
find
({
$and
:
[
{
number
:
{
$lte
:
HEAD
.
number
-
n
+
1
}
},
{
number
:
{
$gte
:
HEAD
.
number
-
m
+
1
}
},
]
})
.
simplesort
(
'
number
'
,
true
)
.
data
().
slice
(
n
-
1
,
m
)
}
@
MonitorExecutionTime
()
async
tail
():
Promise
<
DBHead
>
{
const
HEAD
=
await
this
.
head
(
1
)
if
(
!
HEAD
)
{
return
HEAD
}
const
nbHEADs
=
this
.
collection
.
length
()
return
this
.
collection
.
find
({
number
:
HEAD
.
number
-
nbHEADs
+
1
})[
0
]
}
@
MonitorExecutionTime
()
@
MonitorLokiExecutionTime
(
true
)
async
trimBlocks
(
maxnumber
:
number
):
Promise
<
void
>
{
this
.
collection
.
chain
()
.
find
({
number
:
{
$lt
:
maxnumber
}})
.
remove
()
}
@
MonitorExecutionTime
()
@
MonitorLokiExecutionTime
(
true
)
async
getWrittenOn
(
blockstamp
:
string
):
Promise
<
DBHead
[]
>
{
const
criterion
:
any
=
{
number
:
parseInt
(
blockstamp
)
}
return
this
.
collection
.
find
(
criterion
)
}
}
Loading