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
9d86a49a
Commit
9d86a49a
authored
Oct 08, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed Sha3Bin to Sha3
parent
f3196c91
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
22 additions
and
20 deletions
+22
-20
block.go
ethchain/block.go
+4
-4
dagger.go
ethchain/dagger.go
+1
-1
genesis.go
ethchain/genesis.go
+3
-3
transaction.go
ethchain/transaction.go
+4
-4
crypto.go
ethcrypto/crypto.go
+2
-3
keypair.go
ethcrypto/keypair.go
+3
-2
ethereum.go
ethereum.go
+2
-0
state_object.go
ethstate/state_object.go
+1
-1
trie.go
ethtrie/trie.go
+1
-1
vm.go
ethvm/vm.go
+1
-1
No files found.
ethchain/block.go
View file @
9d86a49a
...
...
@@ -144,12 +144,12 @@ func CreateBlock(root interface{},
// Returns a hash of the block
func
(
block
*
Block
)
Hash
()
ethutil
.
Bytes
{
return
ethcrypto
.
Sha3
Bin
(
ethutil
.
NewValue
(
block
.
header
())
.
Encode
())
//return ethcrypto.Sha3
Bin
(block.Value().Encode())
return
ethcrypto
.
Sha3
(
ethutil
.
NewValue
(
block
.
header
())
.
Encode
())
//return ethcrypto.Sha3(block.Value().Encode())
}
func
(
block
*
Block
)
HashNoNonce
()
[]
byte
{
return
ethcrypto
.
Sha3
Bin
(
ethutil
.
Encode
([]
interface
{}{
block
.
PrevHash
,
return
ethcrypto
.
Sha3
(
ethutil
.
Encode
([]
interface
{}{
block
.
PrevHash
,
block
.
UncleSha
,
block
.
Coinbase
,
block
.
state
.
Trie
.
Root
,
block
.
TxSha
,
block
.
Difficulty
,
block
.
Number
,
block
.
MinGasPrice
,
block
.
GasLimit
,
block
.
GasUsed
,
block
.
Time
,
block
.
Extra
}))
...
...
@@ -237,7 +237,7 @@ func (block *Block) SetUncles(uncles []*Block) {
block
.
Uncles
=
uncles
// Sha of the concatenated uncles
block
.
UncleSha
=
ethcrypto
.
Sha3
Bin
(
ethutil
.
Encode
(
block
.
rlpUncles
()))
block
.
UncleSha
=
ethcrypto
.
Sha3
(
ethutil
.
Encode
(
block
.
rlpUncles
()))
}
func
(
self
*
Block
)
SetReceipts
(
receipts
[]
*
Receipt
,
txs
[]
*
Transaction
)
{
...
...
ethchain/dagger.go
View file @
9d86a49a
...
...
@@ -61,7 +61,7 @@ func (pow *EasyPow) Search(block *Block, reactChan chan ethreact.Event) []byte {
t
=
time
.
Now
()
}
sha
:=
ethcrypto
.
Sha3
Bin
(
big
.
NewInt
(
r
.
Int63
())
.
Bytes
())
sha
:=
ethcrypto
.
Sha3
(
big
.
NewInt
(
r
.
Int63
())
.
Bytes
())
if
pow
.
Verify
(
hash
,
diff
,
sha
)
{
return
sha
}
...
...
ethchain/genesis.go
View file @
9d86a49a
...
...
@@ -13,13 +13,13 @@ import (
var
ZeroHash256
=
make
([]
byte
,
32
)
var
ZeroHash160
=
make
([]
byte
,
20
)
var
EmptyShaList
=
ethcrypto
.
Sha3
Bin
(
ethutil
.
Encode
([]
interface
{}{}))
var
EmptyShaList
=
ethcrypto
.
Sha3
(
ethutil
.
Encode
([]
interface
{}{}))
var
GenesisHeader
=
[]
interface
{}{
// Previous hash (none)
ZeroHash256
,
// Sha of uncles
ethcrypto
.
Sha3
Bin
(
ethutil
.
Encode
([]
interface
{}{})),
ethcrypto
.
Sha3
(
ethutil
.
Encode
([]
interface
{}{})),
// Coinbase
ZeroHash160
,
// Root state
...
...
@@ -42,7 +42,7 @@ var GenesisHeader = []interface{}{
// Extra
nil
,
// Nonce
ethcrypto
.
Sha3
Bin
(
big
.
NewInt
(
42
)
.
Bytes
()),
ethcrypto
.
Sha3
(
big
.
NewInt
(
42
)
.
Bytes
()),
}
var
Genesis
=
[]
interface
{}{
GenesisHeader
,
[]
interface
{}{},
[]
interface
{}{}}
ethchain/transaction.go
View file @
9d86a49a
...
...
@@ -66,7 +66,7 @@ func (self *Transaction) TotalValue() *big.Int {
func
(
tx
*
Transaction
)
Hash
()
[]
byte
{
data
:=
[]
interface
{}{
tx
.
Nonce
,
tx
.
GasPrice
,
tx
.
Gas
,
tx
.
Recipient
,
tx
.
Value
,
tx
.
Data
}
return
ethcrypto
.
Sha3
Bin
(
ethutil
.
NewValue
(
data
)
.
Encode
())
return
ethcrypto
.
Sha3
(
ethutil
.
NewValue
(
data
)
.
Encode
())
}
func
(
tx
*
Transaction
)
CreatesContract
()
bool
{
...
...
@@ -80,9 +80,9 @@ func (tx *Transaction) IsContract() bool {
func
(
tx
*
Transaction
)
CreationAddress
(
state
*
ethstate
.
State
)
[]
byte
{
// Generate a new address
addr
:=
ethcrypto
.
Sha3
Bin
(
ethutil
.
NewValue
([]
interface
{}{
tx
.
Sender
(),
tx
.
Nonce
})
.
Encode
())[
12
:
]
addr
:=
ethcrypto
.
Sha3
(
ethutil
.
NewValue
([]
interface
{}{
tx
.
Sender
(),
tx
.
Nonce
})
.
Encode
())[
12
:
]
//for i := uint64(0); state.GetStateObject(addr) != nil; i++ {
// addr = ethcrypto.Sha3
Bin
(ethutil.NewValue([]interface{}{tx.Sender(), tx.Nonce + i}).Encode())[12:]
// addr = ethcrypto.Sha3(ethutil.NewValue([]interface{}{tx.Sender(), tx.Nonce + i}).Encode())[12:]
//}
return
addr
...
...
@@ -120,7 +120,7 @@ func (tx *Transaction) Sender() []byte {
return
nil
}
return
ethcrypto
.
Sha3
Bin
(
pubkey
[
1
:
])[
12
:
]
return
ethcrypto
.
Sha3
(
pubkey
[
1
:
])[
12
:
]
}
func
(
tx
*
Transaction
)
Sign
(
privk
[]
byte
)
error
{
...
...
ethcrypto/crypto.go
View file @
9d86a49a
package
ethcrypto
import
(
//"code.google.com/p/go.crypto/sha3"
"crypto/sha256"
"code.google.com/p/go.crypto/ripemd160"
...
...
@@ -12,7 +11,7 @@ import (
)
// TODO refactor, remove (bin)
func
Sha3
Bin
(
data
[]
byte
)
[]
byte
{
func
Sha3
(
data
[]
byte
)
[]
byte
{
d
:=
sha3
.
NewKeccak256
()
d
.
Write
(
data
)
...
...
@@ -21,7 +20,7 @@ func Sha3Bin(data []byte) []byte {
// Creates an ethereum address given the bytes and the nonce
func
CreateAddress
(
b
[]
byte
,
nonce
uint64
)
[]
byte
{
return
Sha3
Bin
(
ethutil
.
NewValue
([]
interface
{}{
b
,
nonce
})
.
Encode
())[
12
:
]
return
Sha3
(
ethutil
.
NewValue
([]
interface
{}{
b
,
nonce
})
.
Encode
())[
12
:
]
}
func
Sha256
(
data
[]
byte
)
[]
byte
{
...
...
ethcrypto/keypair.go
View file @
9d86a49a
package
ethcrypto
import
(
"strings"
"github.com/ethereum/eth-go/ethutil"
"github.com/obscuren/secp256k1-go"
"strings"
)
type
KeyPair
struct
{
...
...
@@ -32,7 +33,7 @@ func NewKeyPairFromSec(seckey []byte) (*KeyPair, error) {
func
(
k
*
KeyPair
)
Address
()
[]
byte
{
if
k
.
address
==
nil
{
k
.
address
=
Sha3
Bin
(
k
.
PublicKey
[
1
:
])[
12
:
]
k
.
address
=
Sha3
(
k
.
PublicKey
[
1
:
])[
12
:
]
}
return
k
.
address
}
...
...
ethereum.go
View file @
9d86a49a
...
...
@@ -431,6 +431,8 @@ func (s *Ethereum) Start(seed bool) {
}
func
(
s
*
Ethereum
)
Seed
()
{
// Sorry Py person. I must blacklist. you perform badly
s
.
blacklist
=
append
(
s
.
blacklist
,
ethutil
.
Hex2Bytes
(
"64656330303561383532336435376331616537643864663236623336313863373537353163636634333530626263396330346237336262623931383064393031"
))
ips
:=
PastPeers
()
if
len
(
ips
)
>
0
{
for
_
,
ip
:=
range
ips
{
...
...
ethstate/state_object.go
View file @
9d86a49a
...
...
@@ -304,7 +304,7 @@ func (c *StateObject) RlpEncode() []byte {
func
(
c
*
StateObject
)
CodeHash
()
ethutil
.
Bytes
{
var
codeHash
[]
byte
if
len
(
c
.
Code
)
>
0
{
codeHash
=
ethcrypto
.
Sha3
Bin
(
c
.
Code
)
codeHash
=
ethcrypto
.
Sha3
(
c
.
Code
)
}
return
codeHash
...
...
ethtrie/trie.go
View file @
9d86a49a
...
...
@@ -67,7 +67,7 @@ func (cache *Cache) PutValue(v interface{}, force bool) interface{} {
enc
:=
value
.
Encode
()
if
len
(
enc
)
>=
32
||
force
{
sha
:=
ethcrypto
.
Sha3
Bin
(
enc
)
sha
:=
ethcrypto
.
Sha3
(
enc
)
cache
.
nodes
[
string
(
sha
)]
=
NewNode
(
sha
,
value
,
true
)
cache
.
IsDirty
=
true
...
...
ethvm/vm.go
View file @
9d86a49a
...
...
@@ -490,7 +490,7 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
case
SHA3
:
require
(
2
)
size
,
offset
:=
stack
.
Popn
()
data
:=
ethcrypto
.
Sha3
Bin
(
mem
.
Get
(
offset
.
Int64
(),
size
.
Int64
()))
data
:=
ethcrypto
.
Sha3
(
mem
.
Get
(
offset
.
Int64
(),
size
.
Int64
()))
stack
.
Push
(
ethutil
.
BigD
(
data
))
...
...
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