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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
typescript
duniter
Commits
080f32dd
Commit
080f32dd
authored
7 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
[fix]
#1248
Could not have chained txs in a block
parent
e843c8e0
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!1233
1.6
,
!1230
Fix/1.6/tx chaining
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/lib/indexer.ts
+22
-22
22 additions, 22 deletions
app/lib/indexer.ts
doc/Protocol.md
+18
-4
18 additions, 4 deletions
doc/Protocol.md
with
40 additions
and
26 deletions
app/lib/indexer.ts
+
22
−
22
View file @
080f32dd
...
@@ -865,42 +865,42 @@ export class Indexer {
...
@@ -865,42 +865,42 @@ export class Indexer {
}
}
}))
}))
// BR_G46
const
getInputLocalFirstOrFallbackGlobally
=
async
(
sindex
:
SindexEntry
[],
ENTRY
:
SindexEntry
)
=>
{
await
Promise
.
all
(
_
.
where
(
sindex
,
{
op
:
constants
.
IDX_UPDATE
}).
map
(
async
(
ENTRY
:
SindexEntry
)
=>
{
let
source
=
_
.
filter
(
sindex
,
(
src
:
SindexEntry
)
=>
src
.
identifier
==
ENTRY
.
identifier
&&
src
.
pos
==
ENTRY
.
pos
&&
src
.
conditions
&&
src
.
op
===
constants
.
IDX_CREATE
)[
0
];
if
(
!
source
)
{
const
reducable
=
await
dal
.
sindexDAL
.
sqlFind
({
const
reducable
=
await
dal
.
sindexDAL
.
sqlFind
({
identifier
:
ENTRY
.
identifier
,
identifier
:
ENTRY
.
identifier
,
pos
:
ENTRY
.
pos
,
pos
:
ENTRY
.
pos
,
amount
:
ENTRY
.
amount
,
amount
:
ENTRY
.
amount
,
base
:
ENTRY
.
base
base
:
ENTRY
.
base
});
});
ENTRY
.
conditions
=
reduce
(
reducable
).
conditions
;
// We valuate the input conditions, so we can map these records to a same account
source
=
reduce
(
reducable
)
ENTRY
.
available
=
reduce
(
reducable
).
consumed
===
false
;
}
return
source
}
// BR_G46
await
Promise
.
all
(
_
.
where
(
sindex
,
{
op
:
constants
.
IDX_UPDATE
}).
map
(
async
(
ENTRY
:
SindexEntry
)
=>
{
const
source
=
await
getInputLocalFirstOrFallbackGlobally
(
sindex
,
ENTRY
)
ENTRY
.
conditions
=
source
.
conditions
;
// We valuate the input conditions, so we can map these records to a same account
ENTRY
.
available
=
source
.
consumed
===
false
;
}))
}))
// BR_G47
// BR_G47
await
Promise
.
all
(
_
.
where
(
sindex
,
{
op
:
constants
.
IDX_UPDATE
}).
map
(
async
(
ENTRY
:
SindexEntry
)
=>
{
await
Promise
.
all
(
_
.
where
(
sindex
,
{
op
:
constants
.
IDX_UPDATE
}).
map
(
async
(
ENTRY
:
SindexEntry
)
=>
{
let
source
=
_
.
filter
(
sindex
,
(
src
:
SindexEntry
)
=>
src
.
identifier
==
ENTRY
.
identifier
&&
src
.
pos
==
ENTRY
.
pos
&&
src
.
conditions
&&
src
.
op
===
constants
.
IDX_CREATE
)[
0
];
const
source
=
await
getInputLocalFirstOrFallbackGlobally
(
sindex
,
ENTRY
)
if
(
!
source
)
{
const
reducable
=
await
dal
.
sindexDAL
.
sqlFind
({
identifier
:
ENTRY
.
identifier
,
pos
:
ENTRY
.
pos
,
amount
:
ENTRY
.
amount
,
base
:
ENTRY
.
base
});
source
=
reduce
(
reducable
);
}
ENTRY
.
conditions
=
source
.
conditions
;
ENTRY
.
conditions
=
source
.
conditions
;
ENTRY
.
isLocked
=
!
txSourceUnlock
(
ENTRY
,
source
,
HEAD
);
ENTRY
.
isLocked
=
!
txSourceUnlock
(
ENTRY
,
source
,
HEAD
);
}))
}))
// BR_G48
// BR_G48
await
Promise
.
all
(
_
.
where
(
sindex
,
{
op
:
constants
.
IDX_UPDATE
}).
map
(
async
(
ENTRY
:
SindexEntry
)
=>
{
await
Promise
.
all
(
_
.
where
(
sindex
,
{
op
:
constants
.
IDX_UPDATE
}).
map
(
async
(
ENTRY
:
SindexEntry
)
=>
{
ENTRY
.
isTimeLocked
=
ENTRY
.
written_time
-
reduce
(
await
dal
.
sindexDAL
.
sqlFind
({
const
source
=
await
getInputLocalFirstOrFallbackGlobally
(
sindex
,
ENTRY
)
identifier
:
ENTRY
.
identifier
,
ENTRY
.
isTimeLocked
=
ENTRY
.
written_time
-
source
.
written_time
<
ENTRY
.
locktime
;
pos
:
ENTRY
.
pos
,
amount
:
ENTRY
.
amount
,
base
:
ENTRY
.
base
})).
written_time
<
ENTRY
.
locktime
;
}))
}))
return
HEAD
;
return
HEAD
;
...
...
This diff is collapsed.
Click to expand it.
doc/Protocol.md
+
18
−
4
View file @
080f32dd
...
@@ -2244,7 +2244,7 @@ Else:
...
@@ -2244,7 +2244,7 @@ Else:
####### BR_G102 - ENTRY.age
####### BR_G102 - ENTRY.age
For each ENTRY in local
I
INDEX where `
op = 'UPDATE'
`:
For each ENTRY in local
S
INDEX where `
op = 'UPDATE'
`:
REF_BLOCK = HEAD~<HEAD~1.number + 1 - NUMBER(ENTRY.hash)>[hash=HASH(ENTRY.created_on)]
REF_BLOCK = HEAD~<HEAD~1.number + 1 - NUMBER(ENTRY.hash)>[hash=HASH(ENTRY.created_on)]
...
@@ -2266,17 +2266,31 @@ EndIf
...
@@ -2266,17 +2266,31 @@ EndIf
For each `
LOCAL_SINDEX[op='UPDATE'] as ENTRY
`:
For each `
LOCAL_SINDEX[op='UPDATE'] as ENTRY
`:
INPUT = REDUCE(GLOBAL_SINDEX[identifier=ENTRY.identifier,pos=ENTRY.pos,amount=ENTRY.amount,base=ENTRY.base])
INPUT_ENTRIES = LOCAL_SINDEX[op='CREATE',identifier=ENTRY.identifier,pos=ENTRY.pos,amount=ENTRY.amount,base=ENTRY.base]
If COUNT(INPUT_ENTRIES) == 0 Then
INPUT_ENTRIES = GLOBAL_SINDEX[identifier=ENTRY.identifier,pos=ENTRY.pos,amount=ENTRY.amount,base=ENTRY.base]
EndIf
INPUT = REDUCE(INPUT_ENTRIES)
ENTRY.conditions = INPUT.conditions
ENTRY.conditions = INPUT.conditions
ENTRY.available = INPUT.consumed == false
ENTRY.available = INPUT.consumed == false
####### BR_G47 - ENTRY.isLocked
####### BR_G47 - ENTRY.isLocked
ENTRY.isLocked = TX_SOURCE_UNLOCK(REDUCE(GLOBAL_SINDEX[identifier=ENTRY.identifier,pos=ENTRY.pos,amount=ENTRY.amount,base=ENTRY.base]).conditions, ENTRY)
INPUT_ENTRIES = LOCAL_SINDEX[op='CREATE',identifier=ENTRY.identifier,pos=ENTRY.pos,amount=ENTRY.amount,base=ENTRY.base]
If COUNT(INPUT_ENTRIES) == 0 Then
INPUT_ENTRIES = GLOBAL_SINDEX[identifier=ENTRY.identifier,pos=ENTRY.pos,amount=ENTRY.amount,base=ENTRY.base]
EndIf
INPUT = REDUCE(INPUT_ENTRIES)
ENTRY.isLocked = TX_SOURCE_UNLOCK(INPUT.conditions, ENTRY)
####### BR_G48 - ENTRY.isTimeLocked
####### BR_G48 - ENTRY.isTimeLocked
ENTRY.isTimeLocked = ENTRY.written_time - REDUCE(GLOBAL_SINDEX[identifier=ENTRY.identifier,pos=ENTRY.pos,amount=ENTRY.amount,base=ENTRY.base]).written_time < ENTRY.locktime
INPUT_ENTRIES = LOCAL_SINDEX[op='CREATE',identifier=ENTRY.identifier,pos=ENTRY.pos,amount=ENTRY.amount,base=ENTRY.base]
If COUNT(INPUT_ENTRIES) == 0 Then
INPUT_ENTRIES = GLOBAL_SINDEX[identifier=ENTRY.identifier,pos=ENTRY.pos,amount=ENTRY.amount,base=ENTRY.base]
EndIf
INPUT = REDUCE(INPUT_ENTRIES)
ENTRY.isTimeLocked = ENTRY.written_time - INPUT.written_time < ENTRY.locktime
##### Rules
##### Rules
...
...
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