generated from TrueCloudLab/basic
[#45] morph: Pass actor providers instead actors themselves
All checks were successful
DCO action / DCO (pull_request) Successful in 58s
Tests and linters / Tests (1.21) (pull_request) Successful in 1m3s
Tests and linters / Tests (1.20) (pull_request) Successful in 1m12s
Tests and linters / Staticcheck (pull_request) Successful in 1m27s
Tests and linters / Tests with -race (pull_request) Successful in 1m35s
Tests and linters / Lint (pull_request) Successful in 2m7s
All checks were successful
DCO action / DCO (pull_request) Successful in 58s
Tests and linters / Tests (1.21) (pull_request) Successful in 1m3s
Tests and linters / Tests (1.20) (pull_request) Successful in 1m12s
Tests and linters / Staticcheck (pull_request) Successful in 1m27s
Tests and linters / Tests with -race (pull_request) Successful in 1m35s
Tests and linters / Lint (pull_request) Successful in 2m7s
* Make NewContractStorage and NewContractStorageWithSimpleActor recieve actor providers instead actors themselves because actors may be expired if websocket connection was broken. Signed-off-by: Airat Arifullin <aarifullin@yadro.com>
This commit is contained in:
parent
06cbfe8691
commit
5ac9578435
1 changed files with 15 additions and 5 deletions
|
@ -29,18 +29,28 @@ type ContractStorage struct {
|
||||||
|
|
||||||
var _ engine.MorphRuleChainStorage = (*ContractStorage)(nil)
|
var _ engine.MorphRuleChainStorage = (*ContractStorage)(nil)
|
||||||
|
|
||||||
func NewContractStorage(actor client.Actor, contract util.Uint160) *ContractStorage {
|
type ActorProvider interface {
|
||||||
|
GetActor() client.Actor
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewContractStorage(actorProvider ActorProvider, contract util.Uint160) *ContractStorage {
|
||||||
return &ContractStorage{
|
return &ContractStorage{
|
||||||
contractInterface: client.New(actor, contract),
|
contractInterface: client.New(actorProvider.GetActor(), contract),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewContractStorageWithSimpleActor(rpcActor actor.RPCActor, acc *wallet.Account, contract util.Uint160) (*ContractStorage, error) {
|
type RPCActorProvider interface {
|
||||||
act, err := actor.NewSimple(rpcActor, acc)
|
GetRPCActor() actor.RPCActor
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewContractStorageWithSimpleActor(rpcActorProvider RPCActorProvider, acc *wallet.Account, contract util.Uint160) (*ContractStorage, error) {
|
||||||
|
act, err := actor.NewSimple(rpcActorProvider.GetRPCActor(), acc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to create simple actor: %w", err)
|
return nil, fmt.Errorf("failed to create simple actor: %w", err)
|
||||||
}
|
}
|
||||||
return NewContractStorage(act, contract), nil
|
return &ContractStorage{
|
||||||
|
contractInterface: client.New(act, contract),
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ContractStorage) AddMorphRuleChain(name chain.Name, target engine.Target, c *chain.Chain) (txHash util.Uint256, vub uint32, err error) {
|
func (s *ContractStorage) AddMorphRuleChain(name chain.Name, target engine.Target, c *chain.Chain) (txHash util.Uint256, vub uint32, err error) {
|
||||||
|
|
Loading…
Reference in a new issue