mirror of
https://github.com/PeernetOfficial/core.git
synced 2026-07-16 18:37:51 +01:00
added new REST API for config file
This commit is contained in:
@@ -116,25 +116,10 @@ func (cache *BlockchainCache) SeenBlockchainVersion(peer *PeerInfo) {
|
||||
downloadAndProcessBlocks(peer, header, 0, peer.BlockchainHeight)
|
||||
|
||||
case blockchain.MultiStatusNewBlocks:
|
||||
//offset := header.Height
|
||||
//limit := peer.BlockchainHeight - header.Height
|
||||
//
|
||||
//header.Height = peer.BlockchainHeight
|
||||
//
|
||||
//fmt.Println("new peer height")
|
||||
//
|
||||
//downloadAndProcessBlocks(peer, header, offset, limit)
|
||||
// delete existing data first, then create it new
|
||||
// Temporary Fix to force update the public key
|
||||
cache.Store.DeleteBlockchain(header)
|
||||
|
||||
cache.backend.SearchIndex.UnindexBlockchain(peer.PublicKey)
|
||||
|
||||
if header, err = cache.Store.NewBlockchainHeader(peer.PublicKey, peer.BlockchainVersion, peer.BlockchainHeight); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
downloadAndProcessBlocks(peer, header, 0, peer.BlockchainHeight)
|
||||
offset := header.Height
|
||||
limit := peer.BlockchainHeight - header.Height
|
||||
header.Height = peer.BlockchainHeight
|
||||
downloadAndProcessBlocks(peer, header, offset, limit)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,6 @@ LocalFirewall: false # Indicates that a local firewall may drop unsolicited i
|
||||
PortForward: 0 # Default not set.
|
||||
|
||||
# Global blockchain cache limits
|
||||
CacheMaxBlockSize: 4096 # Max block size to accept in bytes.
|
||||
CacheMaxBlockSize: 50096 # Max block size to accept in bytes.
|
||||
CacheMaxBlockCount: 256 # Max block count to cache per peer.
|
||||
LimitTotalRecords: 0 # Record count limit. 0 = unlimited. Max Records * Max Block Size = Size Limit.
|
||||
|
||||
@@ -83,6 +83,7 @@ func Start(Backend *core.Backend, ListenAddresses []string, UseSSL bool, Certifi
|
||||
api.Router.HandleFunc("/test", apiTest).Methods("GET")
|
||||
api.Router.HandleFunc("/status", api.apiStatus).Methods("GET")
|
||||
api.Router.HandleFunc("/status/peers", api.apiStatusPeers).Methods("GET")
|
||||
api.Router.HandleFunc("/status/config", api.apiStatusConfig).Methods("GET")
|
||||
api.Router.HandleFunc("/account/info", api.apiAccountInfo).Methods("GET")
|
||||
api.Router.HandleFunc("/account/delete", api.apiAccountDelete).Methods("GET")
|
||||
api.Router.HandleFunc("/blockchain/header", api.apiBlockchainHeaderFunc).Methods("GET")
|
||||
|
||||
@@ -124,3 +124,21 @@ type apiResponsePeerInfo struct {
|
||||
BlockchainHeight uint64 `json:"blockchainheight"` // Blockchain height
|
||||
BlockchainVersion uint64 `json:"blockchainversion"` // Blockchain version
|
||||
}
|
||||
|
||||
/*
|
||||
apiConfigPeers return the appropriate config information of the current Peer
|
||||
connected.
|
||||
|
||||
Request: GET /status/config
|
||||
Result: 200 with JSON apiResponseConfig
|
||||
*/
|
||||
func (api *WebapiInstance) apiStatusConfig(w http.ResponseWriter, r *http.Request) {
|
||||
var peer apiResponseConfig
|
||||
peer.BlockSize = api.Backend.Config.CacheMaxBlockSize
|
||||
|
||||
EncodeJSON(api.Backend, w, r, peer)
|
||||
}
|
||||
|
||||
type apiResponseConfig struct {
|
||||
BlockSize uint64 `json:"blockSize"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user