2021-02-01 10:50:08 +00:00
|
|
|
package fakechain
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"math/big"
|
|
|
|
"sync/atomic"
|
|
|
|
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/config"
|
2021-03-25 12:22:16 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
2021-02-01 10:50:08 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/core/block"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/core/interop"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/core/mempool"
|
2021-07-30 13:57:42 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/core/mpt"
|
2021-02-01 10:50:08 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/core/native"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
2021-03-25 12:22:16 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
2021-02-01 10:50:08 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
2021-09-06 12:16:47 +00:00
|
|
|
uatomic "go.uber.org/atomic"
|
2021-02-01 10:50:08 +00:00
|
|
|
)
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// FakeChain implements the Blockchainer interface, but does not provide real functionality.
|
2021-02-01 10:50:08 +00:00
|
|
|
type FakeChain struct {
|
2022-12-06 13:34:38 +00:00
|
|
|
config.Blockchain
|
2021-02-01 10:50:08 +00:00
|
|
|
*mempool.Pool
|
2022-08-19 17:47:55 +00:00
|
|
|
blocksCh []chan *block.Block
|
2021-02-01 10:50:08 +00:00
|
|
|
Blockheight uint32
|
|
|
|
PoolTxF func(*transaction.Transaction) error
|
|
|
|
poolTxWithData func(*transaction.Transaction, interface{}, *mempool.Pool) error
|
|
|
|
blocks map[util.Uint256]*block.Block
|
|
|
|
hdrHashes map[uint32]util.Uint256
|
|
|
|
txs map[util.Uint256]*transaction.Transaction
|
2021-10-25 14:42:20 +00:00
|
|
|
VerifyWitnessF func() (int64, error)
|
2021-02-01 10:50:08 +00:00
|
|
|
MaxVerificationGAS int64
|
|
|
|
NotaryContractScriptHash util.Uint160
|
|
|
|
NotaryDepositExpiration uint32
|
2022-01-14 01:09:54 +00:00
|
|
|
PostBlock []func(func(*transaction.Transaction, *mempool.Pool, bool) bool, *mempool.Pool, *block.Block)
|
2021-02-01 10:50:08 +00:00
|
|
|
UtilityTokenBalance *big.Int
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// FakeStateSync implements the StateSync interface.
|
2021-07-30 13:57:42 +00:00
|
|
|
type FakeStateSync struct {
|
2021-09-06 12:16:47 +00:00
|
|
|
IsActiveFlag uatomic.Bool
|
|
|
|
IsInitializedFlag uatomic.Bool
|
2021-09-27 13:13:37 +00:00
|
|
|
RequestHeaders uatomic.Bool
|
2021-07-30 13:57:42 +00:00
|
|
|
InitFunc func(h uint32) error
|
2021-09-06 12:16:47 +00:00
|
|
|
TraverseFunc func(root util.Uint256, process func(node mpt.Node, nodeBytes []byte) bool) error
|
|
|
|
AddMPTNodesFunc func(nodes [][]byte) error
|
2021-07-30 13:57:42 +00:00
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// NewFakeChain returns a new FakeChain structure.
|
2021-02-01 10:50:08 +00:00
|
|
|
func NewFakeChain() *FakeChain {
|
2021-09-13 08:41:54 +00:00
|
|
|
return NewFakeChainWithCustomCfg(nil)
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// NewFakeChainWithCustomCfg returns a new FakeChain structure with the specified protocol configuration.
|
2022-12-06 13:34:38 +00:00
|
|
|
func NewFakeChainWithCustomCfg(protocolCfg func(c *config.Blockchain)) *FakeChain {
|
|
|
|
cfg := config.Blockchain{ProtocolConfiguration: config.ProtocolConfiguration{Magic: netmode.UnitTestNet, P2PNotaryRequestPayloadPoolSize: 10}}
|
2021-09-13 08:41:54 +00:00
|
|
|
if protocolCfg != nil {
|
|
|
|
protocolCfg(&cfg)
|
|
|
|
}
|
2021-02-01 10:50:08 +00:00
|
|
|
return &FakeChain{
|
2022-12-06 13:34:38 +00:00
|
|
|
Pool: mempool.New(10, 0, false),
|
|
|
|
PoolTxF: func(*transaction.Transaction) error { return nil },
|
|
|
|
poolTxWithData: func(*transaction.Transaction, interface{}, *mempool.Pool) error { return nil },
|
|
|
|
blocks: make(map[util.Uint256]*block.Block),
|
|
|
|
hdrHashes: make(map[uint32]util.Uint256),
|
|
|
|
txs: make(map[util.Uint256]*transaction.Transaction),
|
|
|
|
Blockchain: cfg,
|
2021-02-01 10:50:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// PutBlock implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) PutBlock(b *block.Block) {
|
|
|
|
chain.blocks[b.Hash()] = b
|
|
|
|
chain.hdrHashes[b.Index] = b.Hash()
|
|
|
|
atomic.StoreUint32(&chain.Blockheight, b.Index)
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// PutHeader implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) PutHeader(b *block.Block) {
|
|
|
|
chain.hdrHashes[b.Index] = b.Hash()
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// PutTx implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) PutTx(tx *transaction.Transaction) {
|
|
|
|
chain.txs[tx.Hash()] = tx
|
|
|
|
}
|
|
|
|
|
2022-01-12 22:34:46 +00:00
|
|
|
// InitVerificationContext initializes context for witness check.
|
|
|
|
func (chain *FakeChain) InitVerificationContext(ic *interop.Context, hash util.Uint160, witness *transaction.Witness) error {
|
2021-03-11 17:15:23 +00:00
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// IsExtensibleAllowed implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (*FakeChain) IsExtensibleAllowed(uint160 util.Uint160) bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetNatives implements the blockchainer.Blockchainer interface.
|
2021-02-09 09:25:38 +00:00
|
|
|
func (*FakeChain) GetNatives() []state.NativeContract {
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetNotaryDepositExpiration implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) GetNotaryDepositExpiration(acc util.Uint160) uint32 {
|
|
|
|
if chain.NotaryDepositExpiration != 0 {
|
|
|
|
return chain.NotaryDepositExpiration
|
|
|
|
}
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetNotaryContractScriptHash implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) GetNotaryContractScriptHash() util.Uint160 {
|
|
|
|
if !chain.NotaryContractScriptHash.Equals(util.Uint160{}) {
|
|
|
|
return chain.NotaryContractScriptHash
|
|
|
|
}
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetNotaryBalance implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) GetNotaryBalance(acc util.Uint160) *big.Int {
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetNotaryServiceFeePerKey implements the Blockchainer interface.
|
2022-03-01 10:10:54 +00:00
|
|
|
func (chain *FakeChain) GetNotaryServiceFeePerKey() int64 {
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetBaseExecFee implements the Policer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) GetBaseExecFee() int64 {
|
|
|
|
return interop.DefaultBaseExecFee
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetStoragePrice implements the Policer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) GetStoragePrice() int64 {
|
2021-02-02 15:46:43 +00:00
|
|
|
return native.DefaultStoragePrice
|
2021-02-01 10:50:08 +00:00
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetMaxVerificationGAS implements the Policer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) GetMaxVerificationGAS() int64 {
|
|
|
|
if chain.MaxVerificationGAS != 0 {
|
|
|
|
return chain.MaxVerificationGAS
|
|
|
|
}
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// PoolTxWithData implements the Blockchainer interface.
|
2022-01-14 01:09:54 +00:00
|
|
|
func (chain *FakeChain) PoolTxWithData(t *transaction.Transaction, data interface{}, mp *mempool.Pool, feer mempool.Feer, verificationFunction func(t *transaction.Transaction, data interface{}) error) error {
|
2021-02-01 10:50:08 +00:00
|
|
|
return chain.poolTxWithData(t, data, mp)
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// RegisterPostBlock implements the Blockchainer interface.
|
2022-01-14 01:09:54 +00:00
|
|
|
func (chain *FakeChain) RegisterPostBlock(f func(func(*transaction.Transaction, *mempool.Pool, bool) bool, *mempool.Pool, *block.Block)) {
|
2021-02-01 10:50:08 +00:00
|
|
|
chain.PostBlock = append(chain.PostBlock, f)
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetConfig implements the Blockchainer interface.
|
2022-12-06 13:34:38 +00:00
|
|
|
func (chain *FakeChain) GetConfig() config.Blockchain {
|
|
|
|
return chain.Blockchain
|
2021-02-01 10:50:08 +00:00
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// CalculateClaimable implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) CalculateClaimable(util.Uint160, uint32) (*big.Int, error) {
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
|
|
|
// FeePerByte implements Feer interface.
|
|
|
|
func (chain *FakeChain) FeePerByte() int64 {
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
|
|
|
// P2PSigExtensionsEnabled implements Feer interface.
|
|
|
|
func (chain *FakeChain) P2PSigExtensionsEnabled() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// AddHeaders implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) AddHeaders(...*block.Header) error {
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// AddBlock implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) AddBlock(block *block.Block) error {
|
|
|
|
if block.Index == atomic.LoadUint32(&chain.Blockheight)+1 {
|
|
|
|
chain.PutBlock(block)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// BlockHeight implements the Feer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) BlockHeight() uint32 {
|
|
|
|
return atomic.LoadUint32(&chain.Blockheight)
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// HeaderHeight implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) HeaderHeight() uint32 {
|
|
|
|
return atomic.LoadUint32(&chain.Blockheight)
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetAppExecResults implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) GetAppExecResults(hash util.Uint256, trig trigger.Type) ([]state.AppExecResult, error) {
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetBlock implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) GetBlock(hash util.Uint256) (*block.Block, error) {
|
|
|
|
if b, ok := chain.blocks[hash]; ok {
|
|
|
|
return b, nil
|
|
|
|
}
|
|
|
|
return nil, errors.New("not found")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetCommittee implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) GetCommittee() (keys.PublicKeys, error) {
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetContractState implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) GetContractState(hash util.Uint160) *state.Contract {
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetContractScriptHash implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) GetContractScriptHash(id int32) (util.Uint160, error) {
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetNativeContractScriptHash implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) GetNativeContractScriptHash(name string) (util.Uint160, error) {
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetHeaderHash implements the Blockchainer interface.
|
2022-11-18 20:19:50 +00:00
|
|
|
func (chain *FakeChain) GetHeaderHash(n uint32) util.Uint256 {
|
|
|
|
return chain.hdrHashes[n]
|
2021-02-01 10:50:08 +00:00
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetHeader implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) GetHeader(hash util.Uint256) (*block.Header, error) {
|
|
|
|
b, err := chain.GetBlock(hash)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2021-03-01 13:44:47 +00:00
|
|
|
return &b.Header, nil
|
2021-02-01 10:50:08 +00:00
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetNextBlockValidators implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) GetNextBlockValidators() ([]*keys.PublicKey, error) {
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetNEP17Contracts implements the Blockchainer interface.
|
2021-11-16 20:09:04 +00:00
|
|
|
func (chain *FakeChain) GetNEP11Contracts() []util.Uint160 {
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetNEP17Contracts implements the Blockchainer interface.
|
2021-07-25 12:00:44 +00:00
|
|
|
func (chain *FakeChain) GetNEP17Contracts() []util.Uint160 {
|
2021-02-01 10:50:08 +00:00
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetNEP17LastUpdated implements the Blockchainer interface.
|
2021-11-16 20:09:04 +00:00
|
|
|
func (chain *FakeChain) GetTokenLastUpdated(acc util.Uint160) (map[int32]uint32, error) {
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// ForEachNEP17Transfer implements the Blockchainer interface.
|
2022-01-18 15:28:24 +00:00
|
|
|
func (chain *FakeChain) ForEachNEP11Transfer(util.Uint160, uint64, func(*state.NEP11Transfer) (bool, error)) error {
|
2021-07-25 12:00:44 +00:00
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// ForEachNEP17Transfer implements the Blockchainer interface.
|
2022-01-18 15:28:24 +00:00
|
|
|
func (chain *FakeChain) ForEachNEP17Transfer(util.Uint160, uint64, func(*state.NEP17Transfer) (bool, error)) error {
|
2021-02-01 10:50:08 +00:00
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetValidators implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) GetValidators() ([]*keys.PublicKey, error) {
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetEnrollments implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) GetEnrollments() ([]state.Validator, error) {
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetStorageItem implements the Blockchainer interface.
|
2021-03-05 14:06:54 +00:00
|
|
|
func (chain *FakeChain) GetStorageItem(id int32, key []byte) state.StorageItem {
|
2021-02-01 10:50:08 +00:00
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetTestVM implements the Blockchainer interface.
|
2022-10-06 10:24:57 +00:00
|
|
|
func (chain *FakeChain) GetTestVM(t trigger.Type, tx *transaction.Transaction, b *block.Block) (*interop.Context, error) {
|
2021-02-01 10:50:08 +00:00
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// CurrentBlockHash implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) CurrentBlockHash() util.Uint256 {
|
|
|
|
return util.Uint256{}
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// HasBlock implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) HasBlock(h util.Uint256) bool {
|
|
|
|
_, ok := chain.blocks[h]
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// HasTransaction implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) HasTransaction(h util.Uint256) bool {
|
|
|
|
_, ok := chain.txs[h]
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetTransaction implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) GetTransaction(h util.Uint256) (*transaction.Transaction, uint32, error) {
|
|
|
|
if tx, ok := chain.txs[h]; ok {
|
|
|
|
return tx, 1, nil
|
|
|
|
}
|
|
|
|
return nil, 0, errors.New("not found")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetMemPool implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) GetMemPool() *mempool.Pool {
|
|
|
|
return chain.Pool
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetGoverningTokenBalance implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) GetGoverningTokenBalance(acc util.Uint160) (*big.Int, uint32) {
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetUtilityTokenBalance implements Feer interface.
|
|
|
|
func (chain *FakeChain) GetUtilityTokenBalance(uint160 util.Uint160) *big.Int {
|
|
|
|
if chain.UtilityTokenBalance != nil {
|
|
|
|
return chain.UtilityTokenBalance
|
|
|
|
}
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// PoolTx implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) PoolTx(tx *transaction.Transaction, _ ...*mempool.Pool) error {
|
|
|
|
return chain.PoolTxF(tx)
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// SubscribeForBlocks implements the Blockchainer interface.
|
2022-08-19 17:47:55 +00:00
|
|
|
func (chain *FakeChain) SubscribeForBlocks(ch chan *block.Block) {
|
2021-02-01 10:50:08 +00:00
|
|
|
chain.blocksCh = append(chain.blocksCh, ch)
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// SubscribeForExecutions implements the Blockchainer interface.
|
2022-08-19 17:47:55 +00:00
|
|
|
func (chain *FakeChain) SubscribeForExecutions(ch chan *state.AppExecResult) {
|
2021-02-01 10:50:08 +00:00
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// SubscribeForNotifications implements the Blockchainer interface.
|
2022-08-19 17:47:55 +00:00
|
|
|
func (chain *FakeChain) SubscribeForNotifications(ch chan *state.ContainedNotificationEvent) {
|
2021-02-01 10:50:08 +00:00
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// SubscribeForTransactions implements the Blockchainer interface.
|
2022-08-19 17:47:55 +00:00
|
|
|
func (chain *FakeChain) SubscribeForTransactions(ch chan *transaction.Transaction) {
|
2021-02-01 10:50:08 +00:00
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// VerifyTx implements the Blockchainer interface.
|
2021-02-01 10:50:08 +00:00
|
|
|
func (chain *FakeChain) VerifyTx(*transaction.Transaction) error {
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// VerifyWitness implements the Blockchainer interface.
|
2021-10-25 14:42:20 +00:00
|
|
|
func (chain *FakeChain) VerifyWitness(util.Uint160, hash.Hashable, *transaction.Witness, int64) (int64, error) {
|
2021-02-01 10:50:08 +00:00
|
|
|
if chain.VerifyWitnessF != nil {
|
|
|
|
return chain.VerifyWitnessF()
|
|
|
|
}
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// UnsubscribeFromBlocks implements the Blockchainer interface.
|
2022-08-19 17:47:55 +00:00
|
|
|
func (chain *FakeChain) UnsubscribeFromBlocks(ch chan *block.Block) {
|
2021-02-01 10:50:08 +00:00
|
|
|
for i, c := range chain.blocksCh {
|
|
|
|
if c == ch {
|
|
|
|
if i < len(chain.blocksCh) {
|
|
|
|
copy(chain.blocksCh[i:], chain.blocksCh[i+1:])
|
|
|
|
}
|
|
|
|
chain.blocksCh = chain.blocksCh[:len(chain.blocksCh)]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// UnsubscribeFromExecutions implements the Blockchainer interface.
|
2022-08-19 17:47:55 +00:00
|
|
|
func (chain *FakeChain) UnsubscribeFromExecutions(ch chan *state.AppExecResult) {
|
2021-02-01 10:50:08 +00:00
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// UnsubscribeFromNotifications implements the Blockchainer interface.
|
2022-08-19 17:47:55 +00:00
|
|
|
func (chain *FakeChain) UnsubscribeFromNotifications(ch chan *state.ContainedNotificationEvent) {
|
2021-02-01 10:50:08 +00:00
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// UnsubscribeFromTransactions implements the Blockchainer interface.
|
2022-08-19 17:47:55 +00:00
|
|
|
func (chain *FakeChain) UnsubscribeFromTransactions(ch chan *transaction.Transaction) {
|
2021-02-01 10:50:08 +00:00
|
|
|
panic("TODO")
|
|
|
|
}
|
2021-07-30 13:57:42 +00:00
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// AddBlock implements the StateSync interface.
|
2021-07-30 13:57:42 +00:00
|
|
|
func (s *FakeStateSync) AddBlock(block *block.Block) error {
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// AddHeaders implements the StateSync interface.
|
2021-07-30 13:57:42 +00:00
|
|
|
func (s *FakeStateSync) AddHeaders(...*block.Header) error {
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// AddMPTNodes implements the StateSync interface.
|
2021-09-06 12:16:47 +00:00
|
|
|
func (s *FakeStateSync) AddMPTNodes(nodes [][]byte) error {
|
|
|
|
if s.AddMPTNodesFunc != nil {
|
|
|
|
return s.AddMPTNodesFunc(nodes)
|
|
|
|
}
|
2021-07-30 13:57:42 +00:00
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// BlockHeight implements the StateSync interface.
|
2021-07-30 13:57:42 +00:00
|
|
|
func (s *FakeStateSync) BlockHeight() uint32 {
|
2021-10-31 09:23:07 +00:00
|
|
|
return 0
|
2021-07-30 13:57:42 +00:00
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// IsActive implements the StateSync interface.
|
2021-09-06 12:16:47 +00:00
|
|
|
func (s *FakeStateSync) IsActive() bool { return s.IsActiveFlag.Load() }
|
2021-07-30 13:57:42 +00:00
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// IsInitialized implements the StateSync interface.
|
2021-07-30 13:57:42 +00:00
|
|
|
func (s *FakeStateSync) IsInitialized() bool {
|
2021-09-06 12:16:47 +00:00
|
|
|
return s.IsInitializedFlag.Load()
|
2021-07-30 13:57:42 +00:00
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// Init implements the StateSync interface.
|
2021-07-30 13:57:42 +00:00
|
|
|
func (s *FakeStateSync) Init(currChainHeight uint32) error {
|
|
|
|
if s.InitFunc != nil {
|
|
|
|
return s.InitFunc(currChainHeight)
|
|
|
|
}
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// NeedHeaders implements the StateSync interface.
|
2021-09-27 13:13:37 +00:00
|
|
|
func (s *FakeStateSync) NeedHeaders() bool { return s.RequestHeaders.Load() }
|
2021-07-30 13:57:42 +00:00
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// NeedMPTNodes implements the StateSync interface.
|
2021-07-30 13:57:42 +00:00
|
|
|
func (s *FakeStateSync) NeedMPTNodes() bool {
|
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// Traverse implements the StateSync interface.
|
2021-07-30 13:57:42 +00:00
|
|
|
func (s *FakeStateSync) Traverse(root util.Uint256, process func(node mpt.Node, nodeBytes []byte) bool) error {
|
2021-09-06 12:16:47 +00:00
|
|
|
if s.TraverseFunc != nil {
|
|
|
|
return s.TraverseFunc(root, process)
|
|
|
|
}
|
2021-07-30 13:57:42 +00:00
|
|
|
panic("TODO")
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// GetUnknownMPTNodesBatch implements the StateSync interface.
|
2021-08-13 09:46:23 +00:00
|
|
|
func (s *FakeStateSync) GetUnknownMPTNodesBatch(limit int) []util.Uint256 {
|
|
|
|
panic("TODO")
|
|
|
|
}
|