diff options
-rw-r--r-- | ethchain/block.go | 8 | ||||
-rw-r--r-- | ethchain/dagger.go | 2 | ||||
-rw-r--r-- | ethchain/genesis.go | 6 | ||||
-rw-r--r-- | ethchain/transaction.go | 8 | ||||
-rw-r--r-- | ethcrypto/crypto.go | 5 | ||||
-rw-r--r-- | ethcrypto/keypair.go | 5 | ||||
-rw-r--r-- | ethereum.go | 2 | ||||
-rw-r--r-- | ethstate/state_object.go | 2 | ||||
-rw-r--r-- | ethtrie/trie.go | 2 | ||||
-rw-r--r-- | ethvm/vm.go | 2 |
10 files changed, 22 insertions, 20 deletions
diff --git a/ethchain/block.go b/ethchain/block.go index 5e8aca33a..d6ff5ef7e 100644 --- a/ethchain/block.go +++ b/ethchain/block.go @@ -144,12 +144,12 @@ func CreateBlock(root interface{}, // Returns a hash of the block func (block *Block) Hash() ethutil.Bytes { - return ethcrypto.Sha3Bin(ethutil.NewValue(block.header()).Encode()) - //return ethcrypto.Sha3Bin(block.Value().Encode()) + return ethcrypto.Sha3(ethutil.NewValue(block.header()).Encode()) + //return ethcrypto.Sha3(block.Value().Encode()) } func (block *Block) HashNoNonce() []byte { - return ethcrypto.Sha3Bin(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.Sha3Bin(ethutil.Encode(block.rlpUncles())) + block.UncleSha = ethcrypto.Sha3(ethutil.Encode(block.rlpUncles())) } func (self *Block) SetReceipts(receipts []*Receipt, txs []*Transaction) { diff --git a/ethchain/dagger.go b/ethchain/dagger.go index 478b7e877..916d7e9c8 100644 --- a/ethchain/dagger.go +++ b/ethchain/dagger.go @@ -61,7 +61,7 @@ func (pow *EasyPow) Search(block *Block, reactChan chan ethreact.Event) []byte { t = time.Now() } - sha := ethcrypto.Sha3Bin(big.NewInt(r.Int63()).Bytes()) + sha := ethcrypto.Sha3(big.NewInt(r.Int63()).Bytes()) if pow.Verify(hash, diff, sha) { return sha } diff --git a/ethchain/genesis.go b/ethchain/genesis.go index 8a1219acb..3edbf32de 100644 --- a/ethchain/genesis.go +++ b/ethchain/genesis.go @@ -13,13 +13,13 @@ import ( var ZeroHash256 = make([]byte, 32) var ZeroHash160 = make([]byte, 20) -var EmptyShaList = ethcrypto.Sha3Bin(ethutil.Encode([]interface{}{})) +var EmptyShaList = ethcrypto.Sha3(ethutil.Encode([]interface{}{})) var GenesisHeader = []interface{}{ // Previous hash (none) ZeroHash256, // Sha of uncles - ethcrypto.Sha3Bin(ethutil.Encode([]interface{}{})), + ethcrypto.Sha3(ethutil.Encode([]interface{}{})), // Coinbase ZeroHash160, // Root state @@ -42,7 +42,7 @@ var GenesisHeader = []interface{}{ // Extra nil, // Nonce - ethcrypto.Sha3Bin(big.NewInt(42).Bytes()), + ethcrypto.Sha3(big.NewInt(42).Bytes()), } var Genesis = []interface{}{GenesisHeader, []interface{}{}, []interface{}{}} diff --git a/ethchain/transaction.go b/ethchain/transaction.go index ae77ee58d..fe11be3bb 100644 --- a/ethchain/transaction.go +++ b/ethchain/transaction.go @@ -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.Sha3Bin(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.Sha3Bin(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.Sha3Bin(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.Sha3Bin(pubkey[1:])[12:] + return ethcrypto.Sha3(pubkey[1:])[12:] } func (tx *Transaction) Sign(privk []byte) error { diff --git a/ethcrypto/crypto.go b/ethcrypto/crypto.go index 624c5169f..ebc8b171b 100644 --- a/ethcrypto/crypto.go +++ b/ethcrypto/crypto.go @@ -1,7 +1,6 @@ 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 Sha3Bin(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 Sha3Bin(ethutil.NewValue([]interface{}{b, nonce}).Encode())[12:] + return Sha3(ethutil.NewValue([]interface{}{b, nonce}).Encode())[12:] } func Sha256(data []byte) []byte { diff --git a/ethcrypto/keypair.go b/ethcrypto/keypair.go index 18fa5b788..ebb982306 100644 --- a/ethcrypto/keypair.go +++ b/ethcrypto/keypair.go @@ -1,9 +1,10 @@ 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 = Sha3Bin(k.PublicKey[1:])[12:] + k.address = Sha3(k.PublicKey[1:])[12:] } return k.address } diff --git a/ethereum.go b/ethereum.go index 013214726..987cd2016 100644 --- a/ethereum.go +++ b/ethereum.go @@ -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 { diff --git a/ethstate/state_object.go b/ethstate/state_object.go index be083e80a..fe4c5f73b 100644 --- a/ethstate/state_object.go +++ b/ethstate/state_object.go @@ -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.Sha3Bin(c.Code) + codeHash = ethcrypto.Sha3(c.Code) } return codeHash diff --git a/ethtrie/trie.go b/ethtrie/trie.go index 695ff436a..24f6a1f08 100644 --- a/ethtrie/trie.go +++ b/ethtrie/trie.go @@ -67,7 +67,7 @@ func (cache *Cache) PutValue(v interface{}, force bool) interface{} { enc := value.Encode() if len(enc) >= 32 || force { - sha := ethcrypto.Sha3Bin(enc) + sha := ethcrypto.Sha3(enc) cache.nodes[string(sha)] = NewNode(sha, value, true) cache.IsDirty = true diff --git a/ethvm/vm.go b/ethvm/vm.go index 8206d0278..a8884f9fe 100644 --- a/ethvm/vm.go +++ b/ethvm/vm.go @@ -490,7 +490,7 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) { case SHA3: require(2) size, offset := stack.Popn() - data := ethcrypto.Sha3Bin(mem.Get(offset.Int64(), size.Int64())) + data := ethcrypto.Sha3(mem.Get(offset.Int64(), size.Int64())) stack.Push(ethutil.BigD(data)) |