OSDN Git Service

rename (#465)
[bytom/vapor.git] / api / api.go
index 4a8fb96..cc54ae8 100644 (file)
@@ -11,24 +11,22 @@ import (
        log "github.com/sirupsen/logrus"
        cmn "github.com/tendermint/tmlibs/common"
 
-       "github.com/vapor/accesstoken"
-       "github.com/vapor/blockchain/txfeed"
-       cfg "github.com/vapor/config"
-       "github.com/vapor/dashboard/dashboard"
-       "github.com/vapor/dashboard/equity"
-       "github.com/vapor/errors"
-       "github.com/vapor/event"
-       "github.com/vapor/mining/cpuminer"
-       "github.com/vapor/mining/miningpool"
-       "github.com/vapor/net/http/authn"
-       "github.com/vapor/net/http/gzip"
-       "github.com/vapor/net/http/httpjson"
-       "github.com/vapor/net/http/static"
-       "github.com/vapor/net/websocket"
-       "github.com/vapor/netsync"
-       "github.com/vapor/p2p"
-       "github.com/vapor/protocol"
-       "github.com/vapor/wallet"
+       "github.com/bytom/vapor/accesstoken"
+       cfg "github.com/bytom/vapor/config"
+       "github.com/bytom/vapor/dashboard/dashboard"
+       "github.com/bytom/vapor/dashboard/equity"
+       "github.com/bytom/vapor/errors"
+       "github.com/bytom/vapor/event"
+       "github.com/bytom/vapor/net/http/authn"
+       "github.com/bytom/vapor/net/http/gzip"
+       "github.com/bytom/vapor/net/http/httpjson"
+       "github.com/bytom/vapor/net/http/static"
+       "github.com/bytom/vapor/net/websocket"
+       "github.com/bytom/vapor/netsync/peers"
+       "github.com/bytom/vapor/p2p"
+       "github.com/bytom/vapor/proposal/blockproposer"
+       "github.com/bytom/vapor/protocol"
+       "github.com/bytom/vapor/wallet"
 )
 
 var (
@@ -113,9 +111,7 @@ type API struct {
        chain           *protocol.Chain
        server          *http.Server
        handler         http.Handler
-       txFeedTracker   *txfeed.Tracker
-       cpuMiner        *cpuminer.CPUMiner
-       miningPool      *miningpool.MiningPool
+       blockProposer   *blockproposer.BlockProposer
        notificationMgr *websocket.WSNotificationManager
        eventDispatcher *event.Dispatcher
 }
@@ -175,23 +171,20 @@ type NetSync interface {
        IsCaughtUp() bool
        PeerCount() int
        GetNetwork() string
-       BestPeer() *netsync.PeerInfo
+       BestPeer() *peers.PeerInfo
        DialPeerWithAddress(addr *p2p.NetAddress) error
-       GetPeerInfos() []*netsync.PeerInfo
+       GetPeerInfos() []*peers.PeerInfo
        StopPeer(peerID string) error
 }
 
 // NewAPI create and initialize the API
-func NewAPI(sync NetSync, wallet *wallet.Wallet, txfeeds *txfeed.Tracker, cpuMiner *cpuminer.CPUMiner, miningPool *miningpool.MiningPool, chain *protocol.Chain, config *cfg.Config, token *accesstoken.CredentialStore, dispatcher *event.Dispatcher, notificationMgr *websocket.WSNotificationManager) *API {
+func NewAPI(sync NetSync, wallet *wallet.Wallet, blockProposer *blockproposer.BlockProposer, chain *protocol.Chain, config *cfg.Config, token *accesstoken.CredentialStore, dispatcher *event.Dispatcher, notificationMgr *websocket.WSNotificationManager) *API {
        api := &API{
-               sync:          sync,
-               wallet:        wallet,
-               chain:         chain,
-               accessTokens:  token,
-               txFeedTracker: txfeeds,
-               cpuMiner:      cpuMiner,
-               miningPool:    miningPool,
-
+               sync:            sync,
+               wallet:          wallet,
+               chain:           chain,
+               accessTokens:    token,
+               blockProposer:   blockProposer,
                eventDispatcher: dispatcher,
                notificationMgr: notificationMgr,
        }
@@ -227,7 +220,6 @@ func (a *API) buildHandler() {
                m.Handle("/get-coinbase-arbitrary", jsonHandler(a.getCoinbaseArbitrary))
                m.Handle("/set-coinbase-arbitrary", jsonHandler(a.setCoinbaseArbitrary))
 
-               m.Handle("/create-asset", jsonHandler(a.createAsset))
                m.Handle("/update-asset-alias", jsonHandler(a.updateAssetAlias))
                m.Handle("/get-asset", jsonHandler(a.getAsset))
                m.Handle("/list-assets", jsonHandler(a.listAssets))
@@ -250,6 +242,7 @@ func (a *API) buildHandler() {
 
                m.Handle("/list-balances", jsonHandler(a.listBalances))
                m.Handle("/list-unspent-outputs", jsonHandler(a.listUnspentOutputs))
+               m.Handle("/list-account-votes", jsonHandler(a.listAccountVotes))
 
                m.Handle("/decode-program", jsonHandler(a.decodeProgram))
 
@@ -270,12 +263,6 @@ func (a *API) buildHandler() {
        m.Handle("/delete-access-token", jsonHandler(a.deleteAccessToken))
        m.Handle("/check-access-token", jsonHandler(a.checkAccessToken))
 
-       m.Handle("/create-transaction-feed", jsonHandler(a.createTxFeed))
-       m.Handle("/get-transaction-feed", jsonHandler(a.getTxFeed))
-       m.Handle("/update-transaction-feed", jsonHandler(a.updateTxFeed))
-       m.Handle("/delete-transaction-feed", jsonHandler(a.deleteTxFeed))
-       m.Handle("/list-transaction-feeds", jsonHandler(a.listTxFeeds))
-
        m.Handle("/submit-transaction", jsonHandler(a.submit))
        m.Handle("/submit-transactions", jsonHandler(a.submitTxs))
        m.Handle("/estimate-transaction-gas", jsonHandler(a.estimateTxGas))
@@ -289,18 +276,10 @@ func (a *API) buildHandler() {
        m.Handle("/get-block-hash", jsonHandler(a.getBestBlockHash))
        m.Handle("/get-block-header", jsonHandler(a.getBlockHeader))
        m.Handle("/get-block-count", jsonHandler(a.getBlockCount))
-       m.Handle("/get-difficulty", jsonHandler(a.getDifficulty))
-       m.Handle("/get-hash-rate", jsonHandler(a.getHashRate))
 
        m.Handle("/is-mining", jsonHandler(a.isMining))
        m.Handle("/set-mining", jsonHandler(a.setMining))
 
-       m.Handle("/get-work", jsonHandler(a.getWork))
-       m.Handle("/get-work-json", jsonHandler(a.getWorkJSON))
-       m.Handle("/submit-block", jsonHandler(a.submitBlock))
-       m.Handle("/submit-work", jsonHandler(a.submitWork))
-       m.Handle("/submit-work-json", jsonHandler(a.submitWorkJSON))
-
        m.Handle("/verify-message", jsonHandler(a.verifyMessage))
        m.Handle("/compile", jsonHandler(a.compileEquity))
 
@@ -313,6 +292,8 @@ func (a *API) buildHandler() {
 
        m.Handle("/get-merkle-proof", jsonHandler(a.getMerkleProof))
 
+       m.Handle("/get-vote-result", jsonHandler(a.getVoteResult))
+
        m.HandleFunc("/websocket-subscribe", a.websocketHandler)
 
        handler := walletHandler(m, walletEnable)