rpc: return protocol parameters in getversion, fix #2160

`StateRootInHeader` is duplicated similarly to `Network`.
It will be removed in future as it is surely a protocol parameter.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgeniy Stratonikov 2021-09-07 15:42:04 +03:00
parent 63e00ac128
commit c465b18cb2
4 changed files with 53 additions and 4 deletions

View file

@ -520,12 +520,25 @@ func (s *Server) getVersion(_ request.Params) (interface{}, *response.Error) {
if err != nil {
return nil, response.NewInternalServerError("Cannot fetch tcp port", err)
}
cfg := s.chain.GetConfig()
return result.Version{
Magic: s.network,
TCPPort: port,
Nonce: s.coreServer.ID(),
UserAgent: s.coreServer.UserAgent,
StateRootInHeader: s.chain.GetConfig().StateRootInHeader,
StateRootInHeader: cfg.StateRootInHeader,
Protocol: result.Protocol{
AddressVersion: address.NEO3Prefix,
Network: cfg.Magic,
MillisecondsPerBlock: cfg.SecondsPerBlock * 1000,
MaxTraceableBlocks: cfg.MaxTraceableBlocks,
MaxValidUntilBlockIncrement: cfg.MaxValidUntilBlockIncrement,
MaxTransactionsPerBlock: cfg.MaxTransactionsPerBlock,
MemoryPoolMaxTransactions: cfg.MemPoolSize,
InitialGasDistribution: cfg.InitialGASSupply,
StateRootInHeader: cfg.StateRootInHeader,
},
}, nil
}