Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
c3f52524
Unverified
Commit
c3f52524
authored
Feb 22, 2021
by
Ralph Pichler
Committed by
GitHub
Feb 22, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chequebook: continue waiting for previous deploy transaction (#1310)
parent
de2af56c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
11 deletions
+28
-11
init.go
pkg/settlement/swap/chequebook/init.go
+28
-11
No files found.
pkg/settlement/swap/chequebook/init.go
View file @
c3f52524
...
...
@@ -17,7 +17,10 @@ import (
"github.com/ethersphere/bee/pkg/storage"
)
const
chequebookKey
=
"swap_chequebook"
const
(
chequebookKey
=
"swap_chequebook"
chequebookDeploymentKey
=
"swap_chequebook_transaction_deployment"
)
func
checkBalance
(
ctx
context
.
Context
,
...
...
@@ -127,21 +130,35 @@ func Init(
return
nil
,
err
}
logger
.
Info
(
"no chequebook found, deploying new one."
)
if
swapInitialDeposit
.
Cmp
(
big
.
NewInt
(
0
))
!=
0
{
err
=
checkBalance
(
ctx
,
logger
,
swapInitialDeposit
,
swapBackend
,
chainId
,
overlayEthAddress
,
erc20BindingFunc
,
erc20Address
,
20
*
time
.
Second
,
10
)
var
txHash
common
.
Hash
err
=
stateStore
.
Get
(
chequebookDeploymentKey
,
&
txHash
)
if
err
!=
nil
&&
err
!=
storage
.
ErrNotFound
{
return
nil
,
err
}
if
err
==
storage
.
ErrNotFound
{
logger
.
Info
(
"no chequebook found, deploying new one."
)
if
swapInitialDeposit
.
Cmp
(
big
.
NewInt
(
0
))
!=
0
{
err
=
checkBalance
(
ctx
,
logger
,
swapInitialDeposit
,
swapBackend
,
chainId
,
overlayEthAddress
,
erc20BindingFunc
,
erc20Address
,
20
*
time
.
Second
,
10
)
if
err
!=
nil
{
return
nil
,
err
}
}
// if we don't yet have a chequebook, deploy a new one
txHash
,
err
=
chequebookFactory
.
Deploy
(
ctx
,
overlayEthAddress
,
big
.
NewInt
(
0
))
if
err
!=
nil
{
return
nil
,
err
}
}
// if we don't yet have a chequebook, deploy a new one
txHash
,
err
:=
chequebookFactory
.
Deploy
(
ctx
,
overlayEthAddress
,
big
.
NewInt
(
0
))
if
err
!=
nil
{
return
nil
,
err
}
logger
.
Infof
(
"deploying new chequebook in transaction %x"
,
txHash
)
logger
.
Infof
(
"deploying new chequebook in transaction %x"
,
txHash
)
err
=
stateStore
.
Put
(
chequebookDeploymentKey
,
txHash
)
if
err
!=
nil
{
return
nil
,
err
}
}
else
{
logger
.
Infof
(
"waiting for chequebook deployment in transaction %x"
,
txHash
)
}
chequebookAddress
,
err
=
chequebookFactory
.
WaitDeployed
(
ctx
,
txHash
)
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment