EcoParameters economic governance parameters
(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
| 222 | |
| 223 | // EcoParameters economic governance parameters |
| 224 | func (s *Server) EcoParameters(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { |
| 225 | // unmarshal the requested chain id |
| 226 | post := new(chainRequest) |
| 227 | if ok := unmarshal(w, r, post); !ok { |
| 228 | return |
| 229 | } |
| 230 | // create a read-only state for the latest block and determine economic parameters |
| 231 | s.readOnlyState(0, func(state *fsm.StateMachine) lib.ErrorI { |
| 232 | // get the root id |
| 233 | rootChainId, err := state.GetRootChainId() |
| 234 | if err != nil { |
| 235 | return err |
| 236 | } |
| 237 | // get the lottery winner |
| 238 | s.rcManager.l.Lock() |
| 239 | delegate, err := s.rcManager.GetLotteryWinner(rootChainId, 0, s.config.ChainId) |
| 240 | s.rcManager.l.Unlock() |
| 241 | // if an error occurred |
| 242 | if err != nil { |
| 243 | return err |
| 244 | } |
| 245 | // ensure non-nil delegate |
| 246 | if delegate == nil { |
| 247 | return lib.ErrEmptyLotteryWinner() |
| 248 | } |
| 249 | // find proposer cut |
| 250 | proposerCut := 100 - delegate.Cut |
| 251 | // remove sub-validator and sub-delegate cuts if requested chain id is non-root id |
| 252 | if post.ChainId != rootChainId { |
| 253 | proposerCut -= delegate.Cut // sub-validator |
| 254 | proposerCut -= delegate.Cut // sub-delegate |
| 255 | } |
| 256 | _, daoCut, totalMint, committeeMint, err := state.GetBlockMintStats(post.ChainId) |
| 257 | if err != nil { |
| 258 | write(w, err.Error(), http.StatusBadRequest) |
| 259 | return nil |
| 260 | } |
| 261 | write(w, economicParameterResponse{ |
| 262 | DAOCut: daoCut, |
| 263 | MintPerBlock: totalMint, |
| 264 | MintPerCommittee: committeeMint, |
| 265 | ProposerCut: proposerCut, |
| 266 | DelegateCut: delegate.Cut, |
| 267 | }, http.StatusOK) |
| 268 | return nil |
| 269 | }) |
| 270 | } |
| 271 | |
| 272 | // Order gets an order for the specified chain |
| 273 | func (s *Server) Order(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { |
nothing calls this directly
no test coverage detected