forked from TrueCloudLab/neoneo-go
core: refactor block queue
It requires only two methods from Blockchainer: AddBlock and BlockHeight. New interface will allow to easily reuse the block queue for state exchange purposes.
This commit is contained in:
parent
35501a281a
commit
72e654332e
3 changed files with 12 additions and 3 deletions
|
@ -22,7 +22,7 @@ type Blockchainer interface {
|
||||||
ApplyPolicyToTxSet([]*transaction.Transaction) []*transaction.Transaction
|
ApplyPolicyToTxSet([]*transaction.Transaction) []*transaction.Transaction
|
||||||
GetConfig() config.ProtocolConfiguration
|
GetConfig() config.ProtocolConfiguration
|
||||||
AddHeaders(...*block.Header) error
|
AddHeaders(...*block.Header) error
|
||||||
AddBlock(*block.Block) error
|
Blockqueuer // Blockqueuer interface
|
||||||
CalculateClaimable(h util.Uint160, endHeight uint32) (*big.Int, error)
|
CalculateClaimable(h util.Uint160, endHeight uint32) (*big.Int, error)
|
||||||
Close()
|
Close()
|
||||||
InitVerificationVM(v *vm.VM, getContract func(util.Uint160) (*state.Contract, error), hash util.Uint160, witness *transaction.Witness) error
|
InitVerificationVM(v *vm.VM, getContract func(util.Uint160) (*state.Contract, error), hash util.Uint160, witness *transaction.Witness) error
|
||||||
|
|
9
pkg/core/blockchainer/blockqueuer.go
Normal file
9
pkg/core/blockchainer/blockqueuer.go
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
package blockchainer
|
||||||
|
|
||||||
|
import "github.com/nspcc-dev/neo-go/pkg/core/block"
|
||||||
|
|
||||||
|
// Blockqueuer is an interface for blockqueue.
|
||||||
|
type Blockqueuer interface {
|
||||||
|
AddBlock(block *block.Block) error
|
||||||
|
BlockHeight() uint32
|
||||||
|
}
|
|
@ -11,7 +11,7 @@ type blockQueue struct {
|
||||||
log *zap.Logger
|
log *zap.Logger
|
||||||
queue *queue.PriorityQueue
|
queue *queue.PriorityQueue
|
||||||
checkBlocks chan struct{}
|
checkBlocks chan struct{}
|
||||||
chain blockchainer.Blockchainer
|
chain blockchainer.Blockqueuer
|
||||||
relayF func(*block.Block)
|
relayF func(*block.Block)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ const (
|
||||||
blockCacheSize = 2000
|
blockCacheSize = 2000
|
||||||
)
|
)
|
||||||
|
|
||||||
func newBlockQueue(capacity int, bc blockchainer.Blockchainer, log *zap.Logger, relayer func(*block.Block)) *blockQueue {
|
func newBlockQueue(capacity int, bc blockchainer.Blockqueuer, log *zap.Logger, relayer func(*block.Block)) *blockQueue {
|
||||||
if log == nil {
|
if log == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue