forked from TrueCloudLab/neoneo-go
rpcsrv: return more configuration data to the client
These are extensions, but they're important for the client to make various decisions.
This commit is contained in:
parent
afef8b85d9
commit
95b72db707
4 changed files with 47 additions and 5 deletions
|
@ -162,6 +162,15 @@ latest state synchronization point P the node working against,
|
|||
`LastUpdatedBlock` equals P. For NEP-11 NFTs `LastUpdatedBlock` is equal for
|
||||
all tokens of the same asset.
|
||||
|
||||
##### `getversion`
|
||||
|
||||
NeoGo can return additional fields in the `protocol` object depending on the
|
||||
extensions enabled. Specifically that's `p2psigextensions` and
|
||||
`staterootinheader` booleans and `committeehistory` and `validatorshistory`
|
||||
objects (that are effectively maps from stringified integers to other
|
||||
integers. These fields are only returned when corresponding settings are
|
||||
enabled in the server's protocol configuration.
|
||||
|
||||
##### `getnep11transfers` and `getnep17transfers`
|
||||
`transfernotifyindex` is not tracked by NeoGo, thus this field is always zero.
|
||||
|
||||
|
|
|
@ -39,8 +39,18 @@ type (
|
|||
MemoryPoolMaxTransactions int
|
||||
ValidatorsCount byte
|
||||
InitialGasDistribution fixedn.Fixed8
|
||||
|
||||
// Below are NeoGo-specific extensions to the protocol that are
|
||||
// returned by the server in case they're enabled.
|
||||
|
||||
// CommitteeHistory stores height:size map of the committee size.
|
||||
CommitteeHistory map[uint32]int
|
||||
// P2PSigExtensions is true when Notary subsystem is enabled on the network.
|
||||
P2PSigExtensions bool
|
||||
// StateRootInHeader is true if state root is contained in block header.
|
||||
StateRootInHeader bool
|
||||
// ValidatorsHistory stores height:size map of the validators count.
|
||||
ValidatorsHistory map[uint32]int
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -67,7 +77,11 @@ type (
|
|||
MemoryPoolMaxTransactions int `json:"memorypoolmaxtransactions"`
|
||||
ValidatorsCount byte `json:"validatorscount"`
|
||||
InitialGasDistribution int64 `json:"initialgasdistribution"`
|
||||
|
||||
CommitteeHistory map[uint32]int `json:"committeehistory,omitempty"`
|
||||
P2PSigExtensions bool `json:"p2psigextensions,omitempty"`
|
||||
StateRootInHeader bool `json:"staterootinheader,omitempty"`
|
||||
ValidatorsHistory map[uint32]int `json:"validatorshistory,omitempty"`
|
||||
}
|
||||
|
||||
// versionUnmarshallerAux is an auxiliary struct used for Version JSON unmarshalling.
|
||||
|
@ -92,7 +106,11 @@ type (
|
|||
MemoryPoolMaxTransactions int `json:"memorypoolmaxtransactions"`
|
||||
ValidatorsCount byte `json:"validatorscount"`
|
||||
InitialGasDistribution json.RawMessage `json:"initialgasdistribution"`
|
||||
|
||||
CommitteeHistory map[uint32]int `json:"committeehistory,omitempty"`
|
||||
P2PSigExtensions bool `json:"p2psigextensions,omitempty"`
|
||||
StateRootInHeader bool `json:"staterootinheader,omitempty"`
|
||||
ValidatorsHistory map[uint32]int `json:"validatorshistory,omitempty"`
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -118,7 +136,11 @@ func (v *Version) MarshalJSON() ([]byte, error) {
|
|||
MemoryPoolMaxTransactions: v.Protocol.MemoryPoolMaxTransactions,
|
||||
ValidatorsCount: v.Protocol.ValidatorsCount,
|
||||
InitialGasDistribution: int64(v.Protocol.InitialGasDistribution),
|
||||
|
||||
CommitteeHistory: v.Protocol.CommitteeHistory,
|
||||
P2PSigExtensions: v.Protocol.P2PSigExtensions,
|
||||
StateRootInHeader: v.Protocol.StateRootInHeader,
|
||||
ValidatorsHistory: v.Protocol.ValidatorsHistory,
|
||||
},
|
||||
StateRootInHeader: v.StateRootInHeader,
|
||||
}
|
||||
|
@ -145,7 +167,10 @@ func (v *Version) UnmarshalJSON(data []byte) error {
|
|||
v.Protocol.MaxTransactionsPerBlock = aux.Protocol.MaxTransactionsPerBlock
|
||||
v.Protocol.MemoryPoolMaxTransactions = aux.Protocol.MemoryPoolMaxTransactions
|
||||
v.Protocol.ValidatorsCount = aux.Protocol.ValidatorsCount
|
||||
v.Protocol.CommitteeHistory = aux.Protocol.CommitteeHistory
|
||||
v.Protocol.P2PSigExtensions = aux.Protocol.P2PSigExtensions
|
||||
v.Protocol.StateRootInHeader = aux.Protocol.StateRootInHeader
|
||||
v.Protocol.ValidatorsHistory = aux.Protocol.ValidatorsHistory
|
||||
v.StateRootInHeader = aux.StateRootInHeader
|
||||
if len(aux.Protocol.InitialGasDistribution) == 0 {
|
||||
return nil
|
||||
|
|
|
@ -694,7 +694,11 @@ func (s *Server) getVersion(_ params.Params) (interface{}, *neorpc.Error) {
|
|||
MemoryPoolMaxTransactions: cfg.MemPoolSize,
|
||||
ValidatorsCount: byte(cfg.GetNumOfCNs(s.chain.BlockHeight())),
|
||||
InitialGasDistribution: cfg.InitialGASSupply,
|
||||
|
||||
CommitteeHistory: cfg.CommitteeHistory,
|
||||
P2PSigExtensions: cfg.P2PSigExtensions,
|
||||
StateRootInHeader: cfg.StateRootInHeader,
|
||||
ValidatorsHistory: cfg.ValidatorsHistory,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -875,7 +875,11 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
require.EqualValues(t, cfg.MemPoolSize, resp.Protocol.MemoryPoolMaxTransactions)
|
||||
require.EqualValues(t, cfg.ValidatorsCount, resp.Protocol.ValidatorsCount)
|
||||
require.EqualValues(t, cfg.InitialGASSupply, resp.Protocol.InitialGasDistribution)
|
||||
require.EqualValues(t, false, resp.Protocol.StateRootInHeader)
|
||||
|
||||
require.Equal(t, 0, len(resp.Protocol.CommitteeHistory))
|
||||
require.True(t, resp.Protocol.P2PSigExtensions) // Yeah, notary is enabled.
|
||||
require.False(t, resp.Protocol.StateRootInHeader)
|
||||
require.Equal(t, 0, len(resp.Protocol.ValidatorsHistory))
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue