added new REST API for config file

This commit is contained in:
2023-07-27 18:41:57 +01:00
parent 50085c6b11
commit 23397e3d4a
4 changed files with 167 additions and 163 deletions

View File

@@ -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)
}

View File

@@ -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.

View File

@@ -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")

View File

@@ -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"`
}