mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-01-05 19:35:48 +00:00
core: extend Blockchainer interface with StateHeight()
Allow to query current verified state root height.
This commit is contained in:
parent
f665843887
commit
f8051da0bd
5 changed files with 14 additions and 7 deletions
|
@ -1776,6 +1776,12 @@ func (bc *Blockchain) isTxStillRelevant(t *transaction.Transaction) bool {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StateHeight returns height of the verified state root.
|
||||||
|
func (bc *Blockchain) StateHeight() uint32 {
|
||||||
|
h, _ := bc.dao.GetCurrentStateRootHeight()
|
||||||
|
return h
|
||||||
|
}
|
||||||
|
|
||||||
// AddStateRoot add new (possibly unverified) state root to the blockchain.
|
// AddStateRoot add new (possibly unverified) state root to the blockchain.
|
||||||
func (bc *Blockchain) AddStateRoot(r *state.MPTRoot) error {
|
func (bc *Blockchain) AddStateRoot(r *state.MPTRoot) error {
|
||||||
our, err := bc.GetStateRoot(r.Index)
|
our, err := bc.GetStateRoot(r.Index)
|
||||||
|
|
|
@ -49,6 +49,7 @@ type Blockchainer interface {
|
||||||
References(t *transaction.Transaction) ([]transaction.InOut, error)
|
References(t *transaction.Transaction) ([]transaction.InOut, error)
|
||||||
mempool.Feer // fee interface
|
mempool.Feer // fee interface
|
||||||
PoolTx(*transaction.Transaction) error
|
PoolTx(*transaction.Transaction) error
|
||||||
|
StateHeight() uint32
|
||||||
SubscribeForBlocks(ch chan<- *block.Block)
|
SubscribeForBlocks(ch chan<- *block.Block)
|
||||||
SubscribeForExecutions(ch chan<- *state.AppExecResult)
|
SubscribeForExecutions(ch chan<- *state.AppExecResult)
|
||||||
SubscribeForNotifications(ch chan<- *state.NotificationEvent)
|
SubscribeForNotifications(ch chan<- *state.NotificationEvent)
|
||||||
|
|
|
@ -154,7 +154,9 @@ func (chain testChain) IsLowPriority(util.Fixed8) bool {
|
||||||
func (chain testChain) PoolTx(*transaction.Transaction) error {
|
func (chain testChain) PoolTx(*transaction.Transaction) error {
|
||||||
panic("TODO")
|
panic("TODO")
|
||||||
}
|
}
|
||||||
|
func (chain testChain) StateHeight() uint32 {
|
||||||
|
panic("TODO")
|
||||||
|
}
|
||||||
func (chain testChain) SubscribeForBlocks(ch chan<- *block.Block) {
|
func (chain testChain) SubscribeForBlocks(ch chan<- *block.Block) {
|
||||||
panic("TODO")
|
panic("TODO")
|
||||||
}
|
}
|
||||||
|
|
|
@ -745,10 +745,9 @@ func (s *Server) verifyProof(ps request.Params) (interface{}, *response.Error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) getStateHeight(_ request.Params) (interface{}, *response.Error) {
|
func (s *Server) getStateHeight(_ request.Params) (interface{}, *response.Error) {
|
||||||
height := s.chain.BlockHeight()
|
|
||||||
return &result.StateHeight{
|
return &result.StateHeight{
|
||||||
BlockHeight: height,
|
BlockHeight: s.chain.BlockHeight(),
|
||||||
StateHeight: height,
|
StateHeight: s.chain.StateHeight(),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -246,9 +246,8 @@ var rpcTestCases = map[string][]rpcTestCase{
|
||||||
sh, ok := res.(*result.StateHeight)
|
sh, ok := res.(*result.StateHeight)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
|
|
||||||
h := e.chain.BlockHeight()
|
require.Equal(t, e.chain.BlockHeight(), sh.BlockHeight)
|
||||||
require.Equal(t, h, sh.BlockHeight)
|
require.Equal(t, e.chain.StateHeight(), sh.StateHeight)
|
||||||
require.Equal(t, h, sh.StateHeight)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue