Browse Source

First crack it providing fast-sync endpoint

pull/587/head
Adrian Brink 8 years ago
parent
commit
05c0dfac12
5 changed files with 15 additions and 1 deletions
  1. +5
    -0
      blockchain/reactor.go
  2. +1
    -0
      node/node.go
  3. +6
    -0
      rpc/core/pipe.go
  4. +2
    -1
      rpc/core/status.go
  5. +1
    -0
      rpc/core/types/responses.go

+ 5
- 0
blockchain/reactor.go View File

@ -267,6 +267,11 @@ func (bcR *BlockchainReactor) SetEventSwitch(evsw types.EventSwitch) {
bcR.evsw = evsw
}
// FastSync returns whether the blockchain reactor is currently fast syncing
func (bcR *BlockchainReactor) FastSync() bool {
return bcR.fastSync
}
//-----------------------------------------------------------------------------
// Messages


+ 1
- 0
node/node.go View File

@ -315,6 +315,7 @@ func (n *Node) ConfigureRPC() {
rpccore.SetAddrBook(n.addrBook)
rpccore.SetProxyAppQuery(n.proxyApp.Query())
rpccore.SetTxIndexer(n.txIndexer)
rpccore.SetBlockchainReactor(n.bcReactor)
rpccore.SetLogger(n.Logger.With("module", "rpc"))
}


+ 6
- 0
rpc/core/pipe.go View File

@ -2,6 +2,7 @@ package core
import (
crypto "github.com/tendermint/go-crypto"
"github.com/tendermint/tendermint/blockchain"
"github.com/tendermint/tendermint/consensus"
p2p "github.com/tendermint/tendermint/p2p"
"github.com/tendermint/tendermint/proxy"
@ -45,6 +46,7 @@ var (
genDoc *types.GenesisDoc // cache the genesis structure
addrBook *p2p.AddrBook
txIndexer txindex.TxIndexer
bcReactor *blockchain.BlockchainReactor
logger log.Logger
)
@ -89,6 +91,10 @@ func SetTxIndexer(indexer txindex.TxIndexer) {
txIndexer = indexer
}
func SetBlockchainReactor(bc *blockchain.BlockchainReactor) {
bcReactor = bc
}
func SetLogger(l log.Logger) {
logger = l
}

+ 2
- 1
rpc/core/status.go View File

@ -27,5 +27,6 @@ func Status() (*ctypes.ResultStatus, error) {
LatestBlockHash: latestBlockHash,
LatestAppHash: latestAppHash,
LatestBlockHeight: latestHeight,
LatestBlockTime: latestBlockTime}, nil
LatestBlockTime: latestBlockTime,
Syncing: bcReactor.FastSync()}, nil
}

+ 1
- 0
rpc/core/types/responses.go View File

@ -38,6 +38,7 @@ type ResultStatus struct {
LatestAppHash data.Bytes `json:"latest_app_hash"`
LatestBlockHeight int `json:"latest_block_height"`
LatestBlockTime int64 `json:"latest_block_time"` // nano
Syncing bool `json:"syncing"`
}
func (s *ResultStatus) TxIndexEnabled() bool {


Loading…
Cancel
Save