Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nucleo
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
blockchain
nucleo
Commits
113e0725
Commit
113e0725
authored
6 years ago
by
Robert Martin-Legene
Browse files
Options
Downloads
Patches
Plain Diff
Distribution works too now.
parent
87f9ad23
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/GasAdmin.js
+25
-26
25 additions, 26 deletions
bin/GasAdmin.js
with
25 additions
and
26 deletions
bin/GasAdmin.js
+
25
−
26
View file @
113e0725
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
var
port
=
14349
;
// cloud
var
port
=
14349
;
// cloud
port
=
16437
;
// bc
port
=
16437
;
// bc
const
contractaddr
=
'
0x283bc55557c08dbc4f902b2b8479a2201a47e1c1
'
;
const
networkdir
=
'
network5445
'
;
const
readline
=
require
(
'
readline
'
);
const
readline
=
require
(
'
readline
'
);
const
rl
=
readline
.
createInterface
(
{
input
:
process
.
stdin
,
output
:
process
.
stdout
}
);
const
rl
=
readline
.
createInterface
(
{
input
:
process
.
stdin
,
output
:
process
.
stdout
}
);
const
Web3
=
require
(
'
web3
'
);
const
Web3
=
require
(
'
web3
'
);
...
@@ -11,19 +11,28 @@ const Personal = require('web3-eth-personal');
...
@@ -11,19 +11,28 @@ const Personal = require('web3-eth-personal');
var
web3
;
var
web3
;
var
GasWell
;
var
GasWell
;
var
from
;
var
from
;
var
contractbalance
;
var
contractaddr
;
function
fatal
(
txt
)
{
console
.
log
(
txt
);
process
.
exit
(
1
);
}
function
init
()
function
init
()
{
{
if
(
process
.
env
.
BFAHOME
==
undefined
)
if
(
process
.
env
.
BFAHOME
==
undefined
)
{
fatal
(
"
$BFAHOME not set. Did you source bfa/bin/env ?
"
);
console
.
log
(
"
$BFAHOME not set. Did you source bfa/bin/env ?
"
);
process
.
exit
(
1
);
}
web3
=
new
Web3
(
"
http://127.0.0.1:
"
+
port
);
web3
=
new
Web3
(
"
http://127.0.0.1:
"
+
port
);
//accounts = new Accounts( web3 );
//accounts = new Accounts( web3 );
var
abi
=
""
;
var
abi
=
""
;
var
abifile
=
fs
.
createReadStream
(
contractaddr
=
fs
.
realpathSync
([
process
.
env
.
BFAHOME
,
networkdir
,
'
contracts
'
,
'
GasWell
'
].
join
(
'
/
'
));
process
.
env
.
BFAHOME
+
"
/network5445/contracts/
"
+
contractaddr
+
"
/abi
"
)
if
(
contractaddr
==
undefined
)
fatal
(
"
I can't seem to find the contract directory containing the Gas Well's ABI
"
);
contractaddr
=
contractaddr
.
replace
(
/^.*
\/
/
,
''
);
var
abipath
=
[
process
.
env
.
BFAHOME
,
networkdir
,
'
contracts
'
,
contractaddr
,
'
abi
'
].
join
(
'
/
'
);
var
abifile
=
fs
.
createReadStream
(
abipath
)
.
on
(
'
readable
'
,
()
=>
{
.
on
(
'
readable
'
,
()
=>
{
var
data
;
var
data
;
while
(
data
=
abifile
.
read
())
while
(
data
=
abifile
.
read
())
...
@@ -31,6 +40,7 @@ function init()
...
@@ -31,6 +40,7 @@ function init()
})
})
.
on
(
'
end
'
,
()
=>
{
.
on
(
'
end
'
,
()
=>
{
GasWell
=
new
web3
.
eth
.
Contract
(
JSON
.
parse
(
abi
),
contractaddr
);
GasWell
=
new
web3
.
eth
.
Contract
(
JSON
.
parse
(
abi
),
contractaddr
);
web3
.
eth
.
getBalance
(
contractaddr
).
then
(
function
(
v
){
contractbalance
=
v
}
);
getlist
();
getlist
();
})
})
;
;
...
@@ -52,12 +62,11 @@ function getAccount()
...
@@ -52,12 +62,11 @@ function getAccount()
personal
.
getAccounts
().
then
(
personal
.
getAccounts
().
then
(
function
gotPersonalAccounts
(
obj
)
{
function
gotPersonalAccounts
(
obj
)
{
console
.
log
(
"
Setting default account to
"
+
obj
[
0
]);
console
.
log
(
"
Setting default account to
"
+
obj
[
0
]);
from
=
obj
[
0
];
from
=
obj
[
0
];
web3
.
eth
.
defaultAccount
=
obj
[
0
];
web3
.
eth
.
defaultAccount
=
obj
[
0
];
},
},
function
failedGettingPersonalAccounts
(
err
){
function
failedGettingPersonalAccounts
(
err
){
console
.
log
(
"
Did you remember to allow 'personal' via the RPC port?
"
+
err
)
fatal
(
"
Did you remember to allow 'personal' via the RPC port?
"
+
err
)
process
.
exit
(
1
);
}
}
);
);
}
}
...
@@ -190,10 +199,7 @@ function editAccount( entry, well )
...
@@ -190,10 +199,7 @@ function editAccount( entry, well )
return
;
return
;
}
}
else
else
{
fatal
(
"
I don't know what to do with
\"
"
+
entry
+
"
\"
.
"
);
console
.
log
(
"
I don't know what to do with
\"
"
+
entry
+
"
\"
.
"
);
process
.
exit
(
1
);
}
rl
.
question
(
"
Adjust the Mwei fill value of
"
+
acct
+
"
(setting to 0 is the same as deleting)
\n
Amount?:
"
,
(
answer
)
=>
{
rl
.
question
(
"
Adjust the Mwei fill value of
"
+
acct
+
"
(setting to 0 is the same as deleting)
\n
Amount?:
"
,
(
answer
)
=>
{
if
(
isNumeric
(
answer
)
)
if
(
isNumeric
(
answer
)
)
{
{
...
@@ -206,17 +212,13 @@ function editAccount( entry, well )
...
@@ -206,17 +212,13 @@ function editAccount( entry, well )
getlist
();
getlist
();
},
},
function
(
b
){
function
(
b
){
console
.
log
(
"
\n
Maybe you are not authorized:
\n
"
+
b
+
"
\n\n\n
I think you should leave now.
\n
"
);
fatal
(
"
\n
Maybe you are not authorized:
\n
"
+
b
+
"
\n\n\n
I think you should leave now.
\n
"
);
process
.
exit
(
1
);
}
}
)
)
;
;
}
}
else
else
{
fatal
(
"
I have no idea what to do with
\"
"
+
answer
+
"
\"
.
"
);
console
.
log
(
"
I have no idea what to do with
\"
"
+
answer
+
"
\"
.
"
);
process
.
exit
(
1
);
}
rl
.
close
;
rl
.
close
;
});
});
}
}
...
@@ -226,12 +228,9 @@ function displayBalances( well )
...
@@ -226,12 +228,9 @@ function displayBalances( well )
var
n
=
well
.
length
;
var
n
=
well
.
length
;
var
i
;
var
i
;
if
(
well
==
undefined
)
if
(
well
==
undefined
)
{
fatal
(
"
Bank is not defined.
"
);
console
.
log
(
"
Bank is not defined.
"
);
process
.
exit
(
1
);
}
well
.
sort
(
wellSort
);
well
.
sort
(
wellSort
);
console
.
log
(
""
);
console
.
log
(
"
The contract's account (
"
+
contractaddr
+
"
) has
"
+
Math
.
floor
(
contractbalance
/
1000000
)
+
"
Mwei.
\n
"
);
var
longestbefore
=
1
;
var
longestbefore
=
1
;
var
longestafter
=
9
;
var
longestafter
=
9
;
for
(
i
=
0
;
i
<
n
;
i
++
)
for
(
i
=
0
;
i
<
n
;
i
++
)
...
@@ -266,7 +265,7 @@ function displayBalances( well )
...
@@ -266,7 +265,7 @@ function displayBalances( well )
console
.
log
(
i
+
"
:
"
+
well
[
i
][
0
]
+
"
fills to
"
+
numstr
+
"
Mwei (has
"
+
has
+
"
).
"
);
console
.
log
(
i
+
"
:
"
+
well
[
i
][
0
]
+
"
fills to
"
+
numstr
+
"
Mwei (has
"
+
has
+
"
).
"
);
}
}
}
}
console
.
log
(
""
);
console
.
log
(
"
\n
[ Q=quit x=distribute ]
"
);
rl
.
question
(
"
Which account to edit (enter index number of full account number)?:
"
,
rl
.
question
(
"
Which account to edit (enter index number of full account number)?:
"
,
(
answer
)
=>
{
(
answer
)
=>
{
if
(
answer
!=
undefined
)
if
(
answer
!=
undefined
)
...
...
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