blockchainer/services: drop this package
It doesn't add any value.
This commit is contained in:
parent
dc7950d050
commit
fcbda00f8a
6 changed files with 27 additions and 40 deletions
|
@ -16,7 +16,6 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/config/limits"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/block"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/blockchainer"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/blockchainer/services"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/dao"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/interop"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/interop/contract"
|
||||
|
@ -291,7 +290,7 @@ func NewBlockchain(s storage.Store, cfg config.ProtocolConfiguration, log *zap.L
|
|||
|
||||
// SetOracle sets oracle module. It doesn't protected by mutex and
|
||||
// must be called before `bc.Run()` to avoid data race.
|
||||
func (bc *Blockchain) SetOracle(mod services.Oracle) {
|
||||
func (bc *Blockchain) SetOracle(mod native.OracleService) {
|
||||
orc := bc.contracts.Oracle
|
||||
md, ok := orc.GetMethod(manifest.MethodVerify, -1)
|
||||
if !ok {
|
||||
|
@ -305,7 +304,7 @@ func (bc *Blockchain) SetOracle(mod services.Oracle) {
|
|||
|
||||
// SetNotary sets notary module. It doesn't protected by mutex and
|
||||
// must be called before `bc.Run()` to avoid data race.
|
||||
func (bc *Blockchain) SetNotary(mod services.Notary) {
|
||||
func (bc *Blockchain) SetNotary(mod native.NotaryService) {
|
||||
bc.contracts.Designate.NotaryService.Store(mod)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
package services
|
||||
|
||||
import "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
|
||||
// Notary is a Notary module interface.
|
||||
type Notary interface {
|
||||
UpdateNotaryNodes(pubs keys.PublicKeys)
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package services
|
||||
|
||||
import (
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
)
|
||||
|
||||
// Oracle specifies oracle service interface.
|
||||
type Oracle interface {
|
||||
// AddRequests processes new requests.
|
||||
AddRequests(map[uint64]*state.OracleRequest)
|
||||
// RemoveRequests removes already processed requests.
|
||||
RemoveRequests([]uint64)
|
||||
// UpdateOracleNodes updates oracle nodes.
|
||||
UpdateOracleNodes(keys.PublicKeys)
|
||||
// UpdateNativeContract updates oracle contract native script and hash.
|
||||
UpdateNativeContract([]byte, []byte, util.Uint160, int)
|
||||
// Start runs oracle module.
|
||||
Start()
|
||||
// Shutdown shutdowns oracle module.
|
||||
Shutdown()
|
||||
}
|
|
@ -9,7 +9,6 @@ import (
|
|||
"sort"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/blockchainer/services"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/dao"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/interop"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/interop/runtime"
|
||||
|
@ -239,11 +238,11 @@ func (s *Designate) updateCachedRoleData(cache *DesignationCache, d *dao.Simple,
|
|||
func (s *Designate) notifyRoleChanged(v *roleData, r noderoles.Role) {
|
||||
switch r {
|
||||
case noderoles.Oracle:
|
||||
if orc, _ := s.OracleService.Load().(services.Oracle); orc != nil {
|
||||
if orc, _ := s.OracleService.Load().(OracleService); orc != nil {
|
||||
orc.UpdateOracleNodes(v.nodes.Copy())
|
||||
}
|
||||
case noderoles.P2PNotary:
|
||||
if ntr, _ := s.NotaryService.Load().(services.Notary); ntr != nil {
|
||||
if ntr, _ := s.NotaryService.Load().(NotaryService); ntr != nil {
|
||||
ntr.UpdateNotaryNodes(v.nodes.Copy())
|
||||
}
|
||||
case noderoles.StateValidator:
|
||||
|
|
|
@ -38,6 +38,11 @@ type NotaryCache struct {
|
|||
notaryServiceFeePerKey int64
|
||||
}
|
||||
|
||||
// NotaryService is a Notary module interface.
|
||||
type NotaryService interface {
|
||||
UpdateNotaryNodes(pubs keys.PublicKeys)
|
||||
}
|
||||
|
||||
const (
|
||||
notaryContractID = -10
|
||||
// prefixDeposit is a prefix for storing Notary deposits.
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"strings"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/blockchainer/services"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/dao"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/interop"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/interop/contract"
|
||||
|
@ -50,6 +49,22 @@ type OracleCache struct {
|
|||
requestPrice int64
|
||||
}
|
||||
|
||||
// OracleService specifies oracle module interface.
|
||||
type OracleService interface {
|
||||
// AddRequests processes new requests.
|
||||
AddRequests(map[uint64]*state.OracleRequest)
|
||||
// RemoveRequests removes already processed requests.
|
||||
RemoveRequests([]uint64)
|
||||
// UpdateOracleNodes updates oracle nodes.
|
||||
UpdateOracleNodes(keys.PublicKeys)
|
||||
// UpdateNativeContract updates oracle contract native script and hash.
|
||||
UpdateNativeContract([]byte, []byte, util.Uint160, int)
|
||||
// Start runs oracle module.
|
||||
Start()
|
||||
// Shutdown shutdowns oracle module.
|
||||
Shutdown()
|
||||
}
|
||||
|
||||
const (
|
||||
oracleContractID = -9
|
||||
maxURLLength = 256
|
||||
|
@ -164,7 +179,7 @@ func (o *Oracle) PostPersist(ic *interop.Context) error {
|
|||
single := big.NewInt(p)
|
||||
var removedIDs []uint64
|
||||
|
||||
orc, _ := o.Module.Load().(services.Oracle)
|
||||
orc, _ := o.Module.Load().(OracleService)
|
||||
for _, tx := range ic.Block.Transactions {
|
||||
resp := getResponse(tx)
|
||||
if resp == nil {
|
||||
|
@ -521,7 +536,7 @@ func (o *Oracle) getConvertibleFromDAO(d *dao.Simple, key []byte, item stackitem
|
|||
|
||||
// updateCache updates cached Oracle values if they've been changed.
|
||||
func (o *Oracle) updateCache(d *dao.Simple) error {
|
||||
orc, _ := o.Module.Load().(services.Oracle)
|
||||
orc, _ := o.Module.Load().(OracleService)
|
||||
if orc == nil {
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue