diff options
author | zelig <viktor.tron@gmail.com> | 2015-03-16 23:50:29 +0800 |
---|---|---|
committer | zelig <viktor.tron@gmail.com> | 2015-03-16 23:50:29 +0800 |
commit | b3e133dd159749a625c4b0245af293607ba12c8c (patch) | |
tree | 9ba8e8c4afe9168f5bc83219d402efb00387d616 /eth | |
parent | 8139d444f8d8163251d1c96ef8034d186825ce32 (diff) | |
parent | 73af0302bed5076260ac935e452064aee423934d (diff) | |
download | go-tangerine-b3e133dd159749a625c4b0245af293607ba12c8c.tar.gz go-tangerine-b3e133dd159749a625c4b0245af293607ba12c8c.tar.zst go-tangerine-b3e133dd159749a625c4b0245af293607ba12c8c.zip |
Merge branch 'frontier/js' into frontier/nodeadmin.js
Diffstat (limited to 'eth')
-rw-r--r-- | eth/backend.go | 26 | ||||
-rw-r--r-- | eth/peer_util.go | 6 | ||||
-rw-r--r-- | eth/protocol.go | 14 | ||||
-rw-r--r-- | eth/protocol_test.go | 4 |
4 files changed, 25 insertions, 25 deletions
diff --git a/eth/backend.go b/eth/backend.go index 1d637c367..18093008b 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -14,7 +14,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethdb" - "github.com/ethereum/go-ethereum/ethutil" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/miner" @@ -65,7 +65,7 @@ type Config struct { // NewDB is used to create databases. // If nil, the default is to create leveldb databases on disk. - NewDB func(path string) (ethutil.Database, error) + NewDB func(path string) (common.Database, error) } func (cfg *Config) parseBootNodes() []*discover.Node { @@ -113,9 +113,9 @@ type Ethereum struct { shutdownChan chan bool // DB interfaces - blockDb ethutil.Database // Block chain database - stateDb ethutil.Database // State changes database - extraDb ethutil.Database // Extra database (txs, etc) + blockDb common.Database // Block chain database + stateDb common.Database // State changes database + extraDb common.Database // Extra database (txs, etc) //*** SERVICES *** // State manager for processing new blocks and managing the over all states @@ -146,7 +146,7 @@ func New(config *Config) (*Ethereum, error) { newdb := config.NewDB if newdb == nil { - newdb = func(path string) (ethutil.Database, error) { return ethdb.NewLDBDatabase(path) } + newdb = func(path string) (common.Database, error) { return ethdb.NewLDBDatabase(path) } } blockDb, err := newdb(path.Join(config.DataDir, "blockchain")) if err != nil { @@ -160,7 +160,7 @@ func New(config *Config) (*Ethereum, error) { // Perform database sanity checks d, _ := blockDb.Get([]byte("ProtocolVersion")) - protov := ethutil.NewValue(d).Uint() + protov := common.NewValue(d).Uint() if protov != ProtocolVersion && protov != 0 { path := path.Join(config.DataDir, "blockchain") return nil, fmt.Errorf("Database version mismatch. Protocol(%d / %d). `rm -rf %s`", protov, ProtocolVersion, path) @@ -304,9 +304,9 @@ func (s *Ethereum) TxPool() *core.TxPool { return s.txPool } func (s *Ethereum) BlockPool() *blockpool.BlockPool { return s.blockPool } func (s *Ethereum) Whisper() *whisper.Whisper { return s.whisper } func (s *Ethereum) EventMux() *event.TypeMux { return s.eventMux } -func (s *Ethereum) BlockDb() ethutil.Database { return s.blockDb } -func (s *Ethereum) StateDb() ethutil.Database { return s.stateDb } -func (s *Ethereum) ExtraDb() ethutil.Database { return s.extraDb } +func (s *Ethereum) BlockDb() common.Database { return s.blockDb } +func (s *Ethereum) StateDb() common.Database { return s.stateDb } +func (s *Ethereum) ExtraDb() common.Database { return s.extraDb } func (s *Ethereum) IsListening() bool { return true } // Always listening func (s *Ethereum) PeerCount() int { return s.net.PeerCount() } func (s *Ethereum) PeerInfo() int { return s.net.PeerCount() } @@ -413,11 +413,11 @@ func (self *Ethereum) blockBroadcastLoop() { } } -func saveProtocolVersion(db ethutil.Database) { +func saveProtocolVersion(db common.Database) { d, _ := db.Get([]byte("ProtocolVersion")) - protocolVersion := ethutil.NewValue(d).Uint() + protocolVersion := common.NewValue(d).Uint() if protocolVersion == 0 { - db.Put([]byte("ProtocolVersion"), ethutil.NewValue(ProtocolVersion).Bytes()) + db.Put([]byte("ProtocolVersion"), common.NewValue(ProtocolVersion).Bytes()) } } diff --git a/eth/peer_util.go b/eth/peer_util.go index 6cf80cde2..18fef0ab5 100644 --- a/eth/peer_util.go +++ b/eth/peer_util.go @@ -3,19 +3,19 @@ package eth import ( "encoding/json" - "github.com/ethereum/go-ethereum/ethutil" + "github.com/ethereum/go-ethereum/common" ) func WritePeers(path string, addresses []string) { if len(addresses) > 0 { data, _ := json.MarshalIndent(addresses, "", " ") - ethutil.WriteFile(path, data) + common.WriteFile(path, data) } } func ReadPeers(path string) (ips []string, err error) { var data string - data, err = ethutil.ReadAllFile(path) + data, err = common.ReadAllFile(path) if err != nil { json.Unmarshal([]byte(data), &ips) } diff --git a/eth/protocol.go b/eth/protocol.go index 708e22087..e368bbec5 100644 --- a/eth/protocol.go +++ b/eth/protocol.go @@ -7,7 +7,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/errs" - "github.com/ethereum/go-ethereum/ethutil" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/rlp" @@ -167,7 +167,7 @@ func (self *ethProtocol) handle() error { } for _, tx := range txs { jsonlogger.LogJson(&logger.EthTxReceived{ - TxHash: ethutil.Bytes2Hex(tx.Hash()), + TxHash: common.Bytes2Hex(tx.Hash()), RemoteId: self.peer.ID().String(), }) } @@ -183,7 +183,7 @@ func (self *ethProtocol) handle() error { request.Amount = maxHashes } hashes := self.chainManager.GetBlockHashesFromHash(request.Hash, request.Amount) - return p2p.EncodeMsg(self.rw, BlockHashesMsg, ethutil.ByteSliceToInterface(hashes)...) + return p2p.EncodeMsg(self.rw, BlockHashesMsg, common.ByteSliceToInterface(hashes)...) case BlockHashesMsg: msgStream := rlp.NewStream(msg.Payload) @@ -259,10 +259,10 @@ func (self *ethProtocol) handle() error { _, chainHead, _ := self.chainManager.Status() jsonlogger.LogJson(&logger.EthChainReceivedNewBlock{ - BlockHash: ethutil.Bytes2Hex(hash), + BlockHash: common.Bytes2Hex(hash), BlockNumber: request.Block.Number(), // this surely must be zero - ChainHeadHash: ethutil.Bytes2Hex(chainHead), - BlockPrevHash: ethutil.Bytes2Hex(request.Block.ParentHash()), + ChainHeadHash: common.Bytes2Hex(chainHead), + BlockPrevHash: common.Bytes2Hex(request.Block.ParentHash()), RemoteId: self.peer.ID().String(), }) // to simplify backend interface adding a new block @@ -351,7 +351,7 @@ func (self *ethProtocol) requestBlockHashes(from []byte) error { func (self *ethProtocol) requestBlocks(hashes [][]byte) error { self.peer.Debugf("fetching %v blocks", len(hashes)) - return p2p.EncodeMsg(self.rw, GetBlocksMsg, ethutil.ByteSliceToInterface(hashes)...) + return p2p.EncodeMsg(self.rw, GetBlocksMsg, common.ByteSliceToInterface(hashes)...) } func (self *ethProtocol) protoError(code int, format string, params ...interface{}) (err *errs.Error) { diff --git a/eth/protocol_test.go b/eth/protocol_test.go index f499d033e..a2b59f117 100644 --- a/eth/protocol_test.go +++ b/eth/protocol_test.go @@ -12,7 +12,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/errs" - "github.com/ethereum/go-ethereum/ethutil" + "github.com/ethereum/go-ethereum/common" ethlogger "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p/discover" @@ -223,7 +223,7 @@ func (self *ethProtocolTester) run() { func TestStatusMsgErrors(t *testing.T) { logInit() eth := newEth(t) - td := ethutil.Big1 + td := common.Big1 currentBlock := []byte{1} genesis := []byte{2} eth.chainManager.status = func() (*big.Int, []byte, []byte) { return td, currentBlock, genesis } |