diff options
author | Maran <maran.hidskes@gmail.com> | 2014-05-13 20:43:29 +0800 |
---|---|---|
committer | Maran <maran.hidskes@gmail.com> | 2014-05-13 20:43:29 +0800 |
commit | 28357d657b8c46e841fc96a61758652d2617b068 (patch) | |
tree | cf0f61c753f50087029c96f3499b722894edd2b3 /ethpub | |
parent | 8ec1bb382aade4aaba20b7fd051a7e52cee61d6e (diff) | |
download | dexon-28357d657b8c46e841fc96a61758652d2617b068.tar dexon-28357d657b8c46e841fc96a61758652d2617b068.tar.gz dexon-28357d657b8c46e841fc96a61758652d2617b068.tar.bz2 dexon-28357d657b8c46e841fc96a61758652d2617b068.tar.lz dexon-28357d657b8c46e841fc96a61758652d2617b068.tar.xz dexon-28357d657b8c46e841fc96a61758652d2617b068.tar.zst dexon-28357d657b8c46e841fc96a61758652d2617b068.zip |
Implemented new JS/EthPub methods
- getTxCountAt
- getPeerCount
- getIsMining
- getIsListening
- getCoinbase
Diffstat (limited to 'ethpub')
-rw-r--r-- | ethpub/pub.go | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/ethpub/pub.go b/ethpub/pub.go index 4ced632f5..1866d6fdf 100644 --- a/ethpub/pub.go +++ b/ethpub/pub.go @@ -1,6 +1,8 @@ package ethpub import ( + "encoding/hex" + "fmt" "github.com/ethereum/eth-go/ethchain" "github.com/ethereum/eth-go/ethutil" ) @@ -56,11 +58,32 @@ func (lib *PEthereum) GetStateObject(address string) *PStateObject { return NewPStateObject(nil) } +func (lib *PEthereum) GetPeerCount() int { + return lib.manager.PeerCount() +} + +func (lib *PEthereum) GetIsMining() bool { + return lib.manager.IsMining() +} + +func (lib *PEthereum) GetIsListening() bool { + return lib.manager.IsListening() +} + +func (lib *PEthereum) GetCoinBase() string { + data, _ := ethutil.Config.Db.Get([]byte("KeyRing")) + keyRing := ethutil.NewValueFromBytes(data) + key := keyRing.Get(0).Bytes() + + return lib.SecretToAddress(hex.EncodeToString(key)) +} + func (lib *PEthereum) GetStorage(address, storageAddress string) string { return lib.GetStateObject(address).GetStorage(storageAddress) } -func (lib *PEthereum) GetTxCount(address string) int { +func (lib *PEthereum) GetTxCountAt(address string) int { + fmt.Println("GO") return lib.GetStateObject(address).Nonce() } |