Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
44900e36
Commit
44900e36
authored
Jan 14, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated to temporary trie
parent
578b63e2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
10 deletions
+34
-10
dagger.go
dagger.go
+3
-2
dev_console.go
dev_console.go
+30
-6
ethereum.go
ethereum.go
+1
-2
No files found.
dagger.go
View file @
44900e36
...
...
@@ -116,8 +116,8 @@ func (dag *Dagger) Node(L uint64, i uint64) *big.Int {
}
func
Sum
(
sha
hash
.
Hash
)
[]
byte
{
in
:=
make
([]
byte
,
32
)
return
sha
.
Sum
(
in
)
//
in := make([]byte, 32)
return
sha
.
Sum
(
nil
)
}
func
(
dag
*
Dagger
)
Eval
(
N
*
big
.
Int
)
*
big
.
Int
{
...
...
@@ -146,3 +146,4 @@ func (dag *Dagger) Eval(N *big.Int) *big.Int {
return
ret
.
SetBytes
(
Sum
(
sha
))
}
dev_console.go
View file @
44900e36
...
...
@@ -37,6 +37,12 @@ func (i *Console) ValidateInput(action string, argumentLength int) error {
case
action
==
"dag"
&&
argumentLength
!=
2
:
err
=
true
expArgCount
=
2
case
action
==
"decode"
&&
argumentLength
!=
1
:
err
=
true
expArgCount
=
1
case
action
==
"encode"
&&
argumentLength
!=
1
:
err
=
true
expArgCount
=
1
}
if
err
{
...
...
@@ -46,6 +52,15 @@ func (i *Console) ValidateInput(action string, argumentLength int) error {
}
}
func
(
i
*
Console
)
PrintRoot
()
{
root
:=
ethutil
.
Conv
(
i
.
trie
.
RootT
)
if
len
(
root
.
AsBytes
())
!=
0
{
fmt
.
Println
(
hex
.
EncodeToString
(
root
.
AsBytes
()))
}
else
{
fmt
.
Println
(
i
.
trie
.
RootT
)
}
}
func
(
i
*
Console
)
ParseInput
(
input
string
)
bool
{
scanner
:=
bufio
.
NewScanner
(
strings
.
NewReader
(
input
))
scanner
.
Split
(
bufio
.
ScanWords
)
...
...
@@ -70,21 +85,26 @@ func (i *Console) ParseInput(input string) bool {
}
else
{
switch
tokens
[
0
]
{
case
"update"
:
i
.
trie
.
Update
(
tokens
[
1
],
tokens
[
2
])
i
.
trie
.
Update
T
(
tokens
[
1
],
tokens
[
2
])
fmt
.
Println
(
hex
.
EncodeToString
([]
byte
(
i
.
trie
.
Root
))
)
i
.
PrintRoot
(
)
case
"get"
:
fmt
.
Println
(
i
.
trie
.
Get
(
tokens
[
1
]))
fmt
.
Println
(
i
.
trie
.
Get
T
(
tokens
[
1
]))
case
"root"
:
fmt
.
Println
(
hex
.
EncodeToString
([]
byte
(
i
.
trie
.
Root
))
)
i
.
PrintRoot
(
)
case
"rawroot"
:
fmt
.
Println
(
i
.
trie
.
Root
)
fmt
.
Println
(
i
.
trie
.
Root
T
)
case
"print"
:
i
.
db
.
Print
()
case
"dag"
:
fmt
.
Println
(
DaggerVerify
(
ethutil
.
Big
(
tokens
[
1
]),
// hash
ethutil
.
BigPow
(
2
,
36
),
// diff
ethutil
.
Big
(
tokens
[
2
])))
// nonce
case
"decode"
:
d
,
_
:=
ethutil
.
Decode
([]
byte
(
tokens
[
1
]),
0
)
fmt
.
Printf
(
"%q
\n
"
,
d
)
case
"encode"
:
fmt
.
Printf
(
"%q
\n
"
,
ethutil
.
Encode
(
tokens
[
1
]))
case
"exit"
,
"quit"
,
"q"
:
return
false
case
"help"
:
...
...
@@ -95,7 +115,11 @@ func (i *Console) ParseInput(input string) bool {
"root - Prints the hex encoded merkle root
\n
"
+
"rawroot - Prints the raw merkle root
\n
"
+
"
\0
33[1m= Dagger =
\0
33[0m
\n
"
+
"dag HASH NONCE - Verifies a nonce with the given hash with dagger
\n
"
)
"dag HASH NONCE - Verifies a nonce with the given hash with dagger
\n
"
+
"
\0
33[1m= Enroding =
\0
33[0m
\n
"
+
"decode STR
\n
"
+
"encode STR
\n
"
)
default
:
fmt
.
Println
(
"Unknown command:"
,
tokens
[
0
])
}
...
...
ethereum.go
View file @
44900e36
...
...
@@ -64,7 +64,7 @@ func main() {
go
func
()
{
for
{
res
:=
dagger
.
Search
(
ethutil
.
Big
(
"01001"
),
ethutil
.
BigPow
(
2
,
2
6
))
res
:=
dagger
.
Search
(
ethutil
.
Big
(
"01001"
),
ethutil
.
BigPow
(
2
,
3
6
))
server
.
Broadcast
(
"blockmine"
,
ethutil
.
Encode
(
res
.
String
()))
}
}()
...
...
@@ -72,7 +72,6 @@ func main() {
server
.
Start
()
// Wait for shutdown
server
.
WaitForShutdown
()
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment