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
eb026d15
Commit
eb026d15
authored
9 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
Other DALs will all use CFS, these are not performance sensitive
parent
b3031419
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
app/lib/dal/coreDAL.js
+4
-4
4 additions, 4 deletions
app/lib/dal/coreDAL.js
app/lib/dal/fileDAL.js
+16
-49
16 additions, 49 deletions
app/lib/dal/fileDAL.js
app/lib/dal/fileDALs/DividendDAL.js
+1
-1
1 addition, 1 deletion
app/lib/dal/fileDALs/DividendDAL.js
package.json
+1
-1
1 addition, 1 deletion
package.json
with
22 additions
and
55 deletions
app/lib/dal/coreDAL.js
+
4
−
4
View file @
eb026d15
...
...
@@ -4,15 +4,15 @@ var fileDAL = require('./fileDAL');
var
util
=
require
(
'
util
'
);
var
_
=
require
(
'
underscore
'
);
module
.
exports
=
function
(
profile
,
home
,
coreName
,
myFS
,
rootDAL
,
levelUpInstance
,
core
,
loki
)
{
return
new
CoreDAL
(
profile
,
home
,
coreName
,
myFS
,
rootDAL
,
levelUpInstance
,
core
,
loki
);
module
.
exports
=
function
(
profile
,
home
,
coreName
,
myFS
,
rootDAL
,
core
,
loki
)
{
return
new
CoreDAL
(
profile
,
home
,
coreName
,
myFS
,
rootDAL
,
core
,
loki
);
};
function
CoreDAL
(
profile
,
home
,
coreName
,
myFS
,
rootDAL
,
levelUpInstance
,
core
,
loki
)
{
function
CoreDAL
(
profile
,
home
,
coreName
,
myFS
,
rootDAL
,
core
,
loki
)
{
let
that
=
this
;
fileDAL
.
FileDAL
.
call
(
this
,
profile
,
home
,
'
/branches/
'
+
coreName
,
myFS
,
rootDAL
,
levelUpInstance
,
coreName
,
core
,
loki
);
fileDAL
.
FileDAL
.
call
(
this
,
profile
,
home
,
'
/branches/
'
+
coreName
,
myFS
,
rootDAL
,
coreName
,
core
,
loki
);
this
.
setRootDAL
=
function
(
dal
)
{
rootDAL
=
dal
;
...
...
This diff is collapsed.
Click to expand it.
app/lib/dal/fileDAL.js
+
16
−
49
View file @
eb026d15
...
...
@@ -4,7 +4,6 @@ var co = require('co');
var
_
=
require
(
'
underscore
'
);
var
sha1
=
require
(
'
sha1
'
);
var
path
=
require
(
'
path
'
);
var
levelup
=
require
(
'
levelup
'
);
var
Membership
=
require
(
'
../entity/membership
'
);
var
Merkle
=
require
(
'
../entity/merkle
'
);
var
Transaction
=
require
(
'
../entity/transaction
'
);
...
...
@@ -22,7 +21,6 @@ var IndicatorsDAL = require('./fileDALs/IndicatorsDAL');
var
PeerDAL
=
require
(
'
./fileDALs/PeerDAL
'
);
var
BlockDAL
=
require
(
'
./fileDALs/BlockDAL
'
);
var
DividendDAL
=
require
(
'
./fileDALs/DividendDAL
'
);
var
LevelDBStorage
=
require
(
'
./fileDALs/AbstractLevelDB
'
);
var
CFSStorage
=
require
(
'
./fileDALs/AbstractCFS
'
);
var
lokijs
=
require
(
'
lokijs
'
);
...
...
@@ -30,20 +28,21 @@ module.exports = {
memory
:
function
(
profile
)
{
return
getHomeFS
(
profile
,
true
)
.
then
(
function
(
params
)
{
let
levelupInstance
=
()
=>
levelup
({
db
:
require
(
'
memdown
'
)
});
let
loki
=
new
lokijs
(
'
ucoin
'
,
{
autosave
:
false
});
return
Q
(
new
FileDAL
(
profile
,
params
.
home
,
""
,
params
.
fs
,
null
,
levelupInstance
,
'
fileDal
'
,
null
,
loki
));
return
Q
(
new
FileDAL
(
profile
,
params
.
home
,
""
,
params
.
fs
,
null
,
'
fileDal
'
,
null
,
loki
));
});
},
file
:
function
(
profile
,
forConf
)
{
return
getHomeFS
(
profile
,
false
)
.
then
(
function
(
params
)
{
let
l
evelupInstance
=
(
pathToLevelDB
)
=>
levelup
(
pathToLevelDB
,
{
db
:
require
(
'
leveldown
'
)
})
;
let
l
oki
;
if
(
forConf
)
{
// Memory only service dals
levelupInstance
=
()
=>
levelup
({
db
:
require
(
'
memdown
'
)
});
loki
=
new
lokijs
(
'
temp
'
,
{
autosave
:
false
});
}
else
{
loki
=
new
lokijs
(
'
ucoin
'
,
{
autosave
:
true
,
autosaveInterval
:
300
});
}
return
new
FileDAL
(
profile
,
params
.
home
,
""
,
params
.
fs
,
null
,
levelupInstance
);
return
new
FileDAL
(
profile
,
params
.
home
,
""
,
params
.
fs
,
null
,
'
fileDal
'
,
null
,
loki
);
});
},
FileDAL
:
FileDAL
...
...
@@ -69,13 +68,11 @@ function getHomeFS(profile, isMemory) {
});
}
function
FileDAL
(
profile
,
home
,
localDir
,
myFS
,
parentFileDAL
,
levelupInstance
,
dalName
,
core
,
loki
)
{
function
FileDAL
(
profile
,
home
,
localDir
,
myFS
,
parentFileDAL
,
dalName
,
core
,
loki
)
{
var
that
=
this
;
let
localHome
=
path
.
join
(
home
,
localDir
);
let
levelDBPath
=
path
.
join
(
localHome
,
'
leveldb
'
);
let
myDB
=
levelupInstance
(
levelDBPath
);
this
.
name
=
dalName
;
this
.
profile
=
profile
;
...
...
@@ -90,21 +87,22 @@ function FileDAL(profile, home, localDir, myFS, parentFileDAL, levelupInstance,
this
.
blockDAL
=
new
BlockDAL
(
that
,
loki
);
this
.
sourcesDAL
=
new
SourcesDAL
(
that
,
loki
);
this
.
txsDAL
=
new
TxsDAL
(
that
,
loki
);
this
.
indicatorsDAL
=
new
IndicatorsDAL
(
rootPath
,
my
DB
,
parentFileDAL
&&
parentFileDAL
.
indicatorsDAL
.
coreFS
,
that
,
LevelDB
Storage
);
this
.
statDAL
=
new
StatDAL
(
rootPath
,
my
DB
,
parentFileDAL
&&
parentFileDAL
.
statDAL
.
coreFS
,
that
,
LevelDB
Storage
);
this
.
coresDAL
=
new
CoresDAL
(
rootPath
,
my
DB
,
parentFileDAL
&&
parentFileDAL
.
coresDAL
.
coreFS
,
that
,
LevelDB
Storage
);
this
.
indicatorsDAL
=
new
IndicatorsDAL
(
rootPath
,
my
FS
,
parentFileDAL
&&
parentFileDAL
.
indicatorsDAL
.
coreFS
,
that
,
CFS
Storage
);
this
.
statDAL
=
new
StatDAL
(
rootPath
,
my
FS
,
parentFileDAL
&&
parentFileDAL
.
statDAL
.
coreFS
,
that
,
CFS
Storage
);
this
.
coresDAL
=
new
CoresDAL
(
rootPath
,
my
FS
,
parentFileDAL
&&
parentFileDAL
.
coresDAL
.
coreFS
,
that
,
CFS
Storage
);
this
.
linksDAL
=
new
LinksDAL
(
that
,
loki
);
this
.
idtyDAL
=
new
IdentityDAL
(
that
,
loki
);
this
.
certDAL
=
new
CertDAL
(
that
,
loki
);
this
.
msDAL
=
new
MembershipDAL
(
that
,
loki
);
this
.
udDAL
=
new
DividendDAL
(
rootPath
,
my
DB
,
parentFileDAL
&&
parentFileDAL
.
udDAL
.
coreFS
,
that
,
LevelDB
Storage
);
this
.
udDAL
=
new
DividendDAL
(
rootPath
,
my
FS
,
parentFileDAL
&&
parentFileDAL
.
udDAL
.
coreFS
,
that
,
CFS
Storage
);
this
.
newDals
=
{
'
peerDAL
'
:
that
.
peerDAL
,
'
indicatorsDAL
'
:
that
.
indicatorsDAL
,
'
confDAL
'
:
that
.
confDAL
,
'
statDAL
'
:
that
.
statDAL
,
'
coresDAL
'
:
that
.
coresDAL
'
coresDAL
'
:
that
.
coresDAL
,
'
udDAL
'
:
that
.
udDAL
};
var
currency
=
''
;
...
...
@@ -118,39 +116,11 @@ function FileDAL(profile, home, localDir, myFS, parentFileDAL, levelupInstance,
this
.
dumpDB
=
()
=>
co
(
function
*
()
{
let
dump
=
{};
return
Q
.
Promise
(
function
(
resolve
,
reject
){
myDB
.
createReadStream
()
.
on
(
'
data
'
,
function
(
data
)
{
dump
[
data
.
key
]
=
data
.
value
;
})
.
on
(
'
error
'
,
function
(
err
)
{
reject
(
err
);
})
.
on
(
'
close
'
,
function
()
{
reject
(
'
Stream closed
'
);
})
.
on
(
'
end
'
,
function
()
{
resolve
(
dump
);
});
});
return
Q
(
dump
);
});
this
.
loadDump
=
(
dump
)
=>
co
(
function
*
()
{
let
keys
=
_
.
keys
(
dump
);
let
operations
=
keys
.
map
((
key
)
=>
{
return
{
type
:
'
put
'
,
key
:
key
,
value
:
dump
[
key
]
};
});
return
Q
.
Promise
(
function
(
resolve
,
reject
){
myDB
.
batch
(
operations
,
null
,
function
(
err
)
{
if
(
err
)
{
return
reject
(
err
);
}
resolve
();
});
});
return
Q
();
});
this
.
getCurrency
=
function
()
{
...
...
@@ -160,9 +130,6 @@ function FileDAL(profile, home, localDir, myFS, parentFileDAL, levelupInstance,
this
.
removeHome
=
function
()
{
return
myFS
.
removeTree
(
localHome
)
.
catch
(
function
(){
if
(
myDB
.
destroy
)
{
//return Q.nbind(myDB.destroy, myDB)(levelDBPath);
}
});
};
...
...
@@ -179,7 +146,7 @@ function FileDAL(profile, home, localDir, myFS, parentFileDAL, levelupInstance,
let
coreName
=
[
core
.
forkPointNumber
,
core
.
forkPointHash
].
join
(
'
-
'
);
let
coreHome
=
home
+
'
/branches/
'
+
coreName
;
yield
myFS
.
makeTree
(
coreHome
);
var
theCore
=
require
(
'
./coreDAL
'
)(
profile
,
home
,
coreName
,
myFS
,
that
,
levelupInstance
,
core
,
loki
);
var
theCore
=
require
(
'
./coreDAL
'
)(
profile
,
home
,
coreName
,
myFS
,
that
,
core
,
loki
);
yield
theCore
.
init
();
return
theCore
;
});
...
...
This diff is collapsed.
Click to expand it.
app/lib/dal/fileDALs/DividendDAL.js
+
1
−
1
View file @
eb026d15
...
...
@@ -22,7 +22,7 @@ function DividendDAL(rootPath, qioFS, parentCore, localDAL, AbstractStorage) {
.
then
((
res
)
=>
res
||
{
history
:
[]
})
.
catch
(()
=>
{
return
{
history
:
[]
};
});
obj
.
history
.
push
(
new
Source
(
ud
).
UDjson
());
return
that
.
coreFS
.
writeJSON
(
'
/ud_history/
'
+
pubkey
+
'
.json
'
);
return
that
.
coreFS
.
writeJSON
(
'
/ud_history/
'
+
pubkey
+
'
.json
'
,
obj
);
});
this
.
getUDHistory
=
(
pubkey
)
=>
this
.
coreFS
.
readJSON
(
'
/ud_history/
'
+
pubkey
+
'
.json
'
).
catch
(()
=>
{
return
{
history
:
[]
};
});
...
...
This diff is collapsed.
Click to expand it.
package.json
+
1
−
1
View file @
eb026d15
...
...
@@ -43,7 +43,7 @@
"
leveldown
"
:
"
1.4.1
"
,
"
levelup
"
:
"
1.2.1
"
,
"
log4js
"
:
"
0.6.9
"
,
"
lokijs
"
:
"
^
1.3.10
"
,
"
lokijs
"
:
"
1.3.10
"
,
"
memdown
"
:
"
1.1.0
"
,
"
merkle
"
:
"
0.1.0
"
,
"
moment
"
:
"
2.6.0
"
,
...
...
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