Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-nameservice
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
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
savoirfairelinux
jami-nameservice
Commits
bdfff40a
Commit
bdfff40a
authored
5 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
scripts: update for new contract
Change-Id: I5741f072e11057d94a84540df4a6bbf67a0df125
parent
4af9851e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
read_names.js
+9
-5
9 additions, 5 deletions
read_names.js
write_names.js
+3
-4
3 additions, 4 deletions
write_names.js
with
12 additions
and
9 deletions
read_names.js
+
9
−
5
View file @
bdfff40a
#!/usr/bin/env nodejs
#!/usr/bin/env nodejs
var
BigNumber
=
require
(
'
bignumber.js
'
);
var
fs
=
require
(
'
fs
'
);
var
fs
=
require
(
'
fs
'
);
var
Web3
=
require
(
'
web3
'
);
var
Web3
=
require
(
'
web3
'
);
...
@@ -10,7 +9,7 @@ web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));
...
@@ -10,7 +9,7 @@ web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));
var
REG_ADDR_FILE
=
"
contractAddress.txt
"
;
var
REG_ADDR_FILE
=
"
contractAddress.txt
"
;
var
REG_ADDR
=
"
0xe53cb2ace8707526a5050bec7bcf979c57f8b44f
"
;
var
REG_ADDR
=
"
0xe53cb2ace8707526a5050bec7bcf979c57f8b44f
"
;
var
REG_ABI_re
gister
For
=
[
'
bytes32
'
,
'
address
'
,
'
address
'
];
var
REG_ABI_re
serve
For
=
[
'
bytes32
'
,
'
address
'
,
'
address
'
,
'
string
'
,
'
string
'
];
var
NAME_LIST
=
[];
var
NAME_LIST
=
[];
function
readContractAddress
()
{
function
readContractAddress
()
{
fs
.
readFile
(
REG_ADDR_FILE
,
function
(
err
,
content
)
{
fs
.
readFile
(
REG_ADDR_FILE
,
function
(
err
,
content
)
{
...
@@ -37,10 +36,15 @@ function getAllNames() {
...
@@ -37,10 +36,15 @@ function getAllNames() {
try
{
try
{
var
tr
=
block
.
transactions
[
t
];
var
tr
=
block
.
transactions
[
t
];
if
(
tr
.
to
==
REG_ADDR
)
{
if
(
tr
.
to
==
REG_ADDR
)
{
var
p
=
web3
.
SolidityCoder
.
decodeParams
(
REG_ABI_re
gister
For
,
tr
.
input
.
substr
(
10
));
const
p
=
web3
.
SolidityCoder
.
decodeParams
(
REG_ABI_re
serve
For
,
tr
.
input
.
substr
(
10
));
var
n
=
web3
.
toUtf8
(
p
[
0
]);
const
n
=
web3
.
toUtf8
(
p
[
0
]);
console
.
log
(
"
Entry:
"
+
n
+
"
->
"
+
p
[
1
]
+
"
"
+
p
[
2
]);
console
.
log
(
"
Entry:
"
+
n
+
"
->
"
+
p
[
1
]
+
"
"
+
p
[
2
]);
NAME_LIST
.
push
({
"
name
"
:
n
,
"
addr
"
:
p
[
2
],
"
owner
"
:
p
[
1
]});
const
newObj
=
{
"
name
"
:
n
,
"
addr
"
:
p
[
2
],
"
owner
"
:
p
[
1
]};
if
(
p
[
3
])
newObj
[
"
publickey
"
]
=
p
[
3
];
if
(
p
[
4
])
newObj
[
"
signature
"
]
=
p
[
4
];
NAME_LIST
.
push
(
newObj
);
}
else
{
}
else
{
console
.
log
(
"
Wrong contract:
"
+
tr
.
to
+
"
expected
"
+
REG_ADDR
);
console
.
log
(
"
Wrong contract:
"
+
tr
.
to
+
"
expected
"
+
REG_ADDR
);
}
}
...
...
This diff is collapsed.
Click to expand it.
write_names.js
+
3
−
4
View file @
bdfff40a
...
@@ -23,7 +23,6 @@ if(!batchInputFile)
...
@@ -23,7 +23,6 @@ if(!batchInputFile)
throw
"
File
"
+
providedPath
+
"
does not exist
"
throw
"
File
"
+
providedPath
+
"
does not exist
"
Object
.
getPrototypeOf
(
web3
.
eth
).
awaitConsensus
=
function
(
txhash
,
mined_cb
)
{
Object
.
getPrototypeOf
(
web3
.
eth
).
awaitConsensus
=
function
(
txhash
,
mined_cb
)
{
var
ethP
=
this
;
var
ethP
=
this
;
var
tries
=
5
;
var
tries
=
5
;
...
@@ -140,7 +139,7 @@ function formatAddress(address) {
...
@@ -140,7 +139,7 @@ function formatAddress(address) {
}
}
return
undefined
;
return
undefined
;
}
}
function
registerName
(
addressparam
,
nameparam
,
ownerparam
,
mined_cb
){
function
registerName
(
addressparam
,
nameparam
,
ownerparam
,
pk
,
sig
,
mined_cb
){
try
{
try
{
var
addr
=
formatAddress
(
addressparam
);
var
addr
=
formatAddress
(
addressparam
);
if
(
!
addr
)
{
if
(
!
addr
)
{
...
@@ -174,7 +173,7 @@ function registerName(addressparam, nameparam, ownerparam, mined_cb){
...
@@ -174,7 +173,7 @@ function registerName(addressparam, nameparam, ownerparam, mined_cb){
}
else
{
}
else
{
console
.
log
(
"
Remaing gaz:
"
+
getRemainingGaz
());
console
.
log
(
"
Remaing gaz:
"
+
getRemainingGaz
());
unlockAccount
();
unlockAccount
();
reg
.
reserveFor
.
sendTransaction
(
formatName
(
nameparam
),
ownerparam
,
addr
,
{
reg
.
reserveFor
.
sendTransaction
(
formatName
(
nameparam
),
ownerparam
,
addr
,
pk
,
sig
,
{
from
:
coinbase
,
from
:
coinbase
,
gas
:
3000000
gas
:
3000000
},
function
(
terr
,
reg_c
)
{
},
function
(
terr
,
reg_c
)
{
...
@@ -226,7 +225,7 @@ function startWrites(){
...
@@ -226,7 +225,7 @@ function startWrites(){
console
.
log
(
String
(
NAME_LIST
.
length
)
+
"
inserts to do
"
);
console
.
log
(
String
(
NAME_LIST
.
length
)
+
"
inserts to do
"
);
//create parallel queue that does 256 registerNames parallely
//create parallel queue that does 256 registerNames parallely
var
q
=
async
.
queue
(
function
(
task
,
callback
)
{
var
q
=
async
.
queue
(
function
(
task
,
callback
)
{
registerName
(
task
[
'
addr
'
],
task
[
'
name
'
],
task
[
'
owner
'
],
callback
);
registerName
(
task
[
'
addr
'
],
task
[
'
name
'
],
task
[
'
owner
'
],
task
[
'
publickey
'
],
task
[
'
signature
'
],
callback
);
},
256
);
},
256
);
for
(
var
i
=
0
;
i
<
NAME_LIST
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
NAME_LIST
.
length
;
i
++
)
{
...
...
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