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
Commits
80b1380d
Commit
80b1380d
authored
7 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
[fix]
#1073
/tx/history returns wrong JSON
parent
81bc5b48
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
app/lib/constants.ts
+3
-0
3 additions, 0 deletions
app/lib/constants.ts
app/lib/dal/sqliteDAL/MetaDAL.ts
+31
-0
31 additions, 0 deletions
app/lib/dal/sqliteDAL/MetaDAL.ts
app/lib/dto/TransactionDTO.ts
+5
-1
5 additions, 1 deletion
app/lib/dto/TransactionDTO.ts
test/dal/dal.js
+1
-1
1 addition, 1 deletion
test/dal/dal.js
with
40 additions
and
2 deletions
app/lib/constants.ts
+
3
−
0
View file @
80b1380d
...
...
@@ -94,6 +94,9 @@ module.exports = {
FIRST_UNIT_BASE
:
0
,
PEER
:
CommonConstants
.
PEER
,
CURRENT_DB_VERSION
:
26
,
NETWORK
:
{
MAX_MEMBERS_TO_FORWARD_TO_FOR_SELF_DOCUMENTS
:
10
,
MAX_NON_MEMBERS_TO_FORWARD_TO_FOR_SELF_DOCUMENTS
:
6
,
...
...
This diff is collapsed.
Click to expand it.
app/lib/dal/sqliteDAL/MetaDAL.ts
+
31
−
0
View file @
80b1380d
...
...
@@ -13,6 +13,7 @@ import {DBBlock} from "../../db/DBBlock"
import
{
IdentityDTO
}
from
"
../../dto/IdentityDTO
"
import
{
rawer
}
from
"
../../common-libs/index
"
import
{
CommonConstants
}
from
"
../../common-libs/constants
"
import
{
TxsDAL
}
from
"
./TxsDAL
"
const
_
=
require
(
'
underscore
'
)
const
logger
=
require
(
'
../../logger
'
).
NewLogger
(
'
metaDAL
'
);
...
...
@@ -364,6 +365,36 @@ export class MetaDAL extends AbstractSQLite<DBMeta> {
await
mindexDAL
.
exec
(
updateQuery
)
}
},
/**
* Wrong transaction storage
*/
25
:
async
()
=>
{
const
txsDAL
=
new
TxsDAL
(
this
.
driverCopy
)
const
wrongTXS
=
await
txsDAL
.
query
(
'
SELECT * FROM txs WHERE outputs LIKE ? OR inputs LIKE ?
'
,
[
'
%amount%
'
,
'
%amount%
'
])
let
i
=
1
for
(
const
tx
of
wrongTXS
)
{
logger
.
info
(
'
Updating incorrect transaction %s/%s.
'
,
i
,
wrongTXS
.
length
)
i
++
const
dto
=
TransactionDTO
.
fromJSONObject
(
tx
)
dto
.
outputs
=
dto
.
outputs
.
map
(
o
=>
{
if
(
typeof
o
===
'
object
'
)
{
return
TransactionDTO
.
outputObj2Str
(
o
)
}
return
o
})
dto
.
inputs
=
dto
.
inputs
.
map
(
o
=>
{
if
(
typeof
o
===
'
object
'
)
{
return
TransactionDTO
.
inputObj2Str
(
o
)
}
return
o
})
await
txsDAL
.
exec
(
'
UPDATE txs SET
'
+
'
outputs =
\'
'
+
JSON
.
stringify
(
dto
.
outputs
)
+
'
\'
,
'
+
'
inputs =
\'
'
+
JSON
.
stringify
(
dto
.
inputs
)
+
'
\'
'
+
'
WHERE hash =
\'
'
+
tx
.
hash
+
'
\'
'
)
}
},
};
async
init
()
{
...
...
This diff is collapsed.
Click to expand it.
app/lib/dto/TransactionDTO.ts
+
5
−
1
View file @
80b1380d
import
{
hashf
}
from
"
../common
"
import
{
Cloneable
}
from
"
./Cloneable
"
;
import
{
Cloneable
}
from
"
./Cloneable
"
export
interface
BaseDTO
{
base
:
number
...
...
@@ -250,6 +250,10 @@ export class TransactionDTO implements Cloneable {
return
[
o
.
amount
,
o
.
base
,
o
.
conditions
].
join
(
'
:
'
)
}
static
inputObj2Str
(
i
:
InputDTO
)
{
return
[
i
.
amount
,
i
.
base
,
i
.
type
,
i
.
identifier
,
i
.
pos
].
join
(
'
:
'
)
}
static
outputStr2Obj
(
outputStr
:
string
)
{
const
sp
=
outputStr
.
split
(
'
:
'
);
return
{
...
...
This diff is collapsed.
Click to expand it.
test/dal/dal.js
+
1
−
1
View file @
80b1380d
...
...
@@ -103,7 +103,7 @@ describe("DAL", function(){
it
(
'
should have DB version 21
'
,
()
=>
co
(
function
*
()
{
let
version
=
yield
fileDAL
.
getDBVersion
();
should
.
exist
(
version
);
version
.
should
.
equal
(
25
);
version
.
should
.
equal
(
constants
.
CURRENT_DB_VERSION
);
}));
it
(
'
should have no peer in a first time
'
,
function
(){
...
...
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