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
ea178d68
Unverified
Commit
ea178d68
authored
May 18, 2021
by
Ralph Pichler
Committed by
GitHub
May 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: start syncing at a later block (#1745)
parent
dbfd7452
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
9 deletions
+22
-9
node.go
pkg/node/node.go
+6
-2
batchservice.go
pkg/postage/batchservice/batchservice.go
+5
-2
interface.go
pkg/postage/interface.go
+1
-1
listener.go
pkg/postage/listener/listener.go
+9
-3
listener_test.go
pkg/postage/listener/listener_test.go
+1
-1
No files found.
pkg/node/node.go
View file @
ea178d68
...
...
@@ -343,8 +343,9 @@ func NewBee(addr string, swarmAddress swarm.Address, publicKey ecdsa.PublicKey,
batchSvc
postage
.
EventUpdater
)
var
postageSyncStart
uint64
=
0
if
!
o
.
Standalone
{
postageContractAddress
,
priceOracleAddress
,
found
:=
listener
.
DiscoverAddresses
(
chainID
)
postageContractAddress
,
priceOracleAddress
,
startBlock
,
found
:=
listener
.
DiscoverAddresses
(
chainID
)
if
o
.
PostageContractAddress
!=
""
{
if
!
common
.
IsHexAddress
(
o
.
PostageContractAddress
)
{
return
nil
,
errors
.
New
(
"malformed postage stamp address"
)
...
...
@@ -360,6 +361,9 @@ func NewBee(addr string, swarmAddress swarm.Address, publicKey ecdsa.PublicKey,
if
(
o
.
PostageContractAddress
==
""
||
o
.
PriceOracleAddress
==
""
)
&&
!
found
{
return
nil
,
errors
.
New
(
"no known postage stamp addresses for this network"
)
}
if
found
{
postageSyncStart
=
startBlock
}
eventListener
:=
listener
.
New
(
logger
,
swapBackend
,
postageContractAddress
,
priceOracleAddress
,
o
.
BlockTime
)
b
.
listenerCloser
=
eventListener
...
...
@@ -438,7 +442,7 @@ func NewBee(addr string, swarmAddress swarm.Address, publicKey ecdsa.PublicKey,
batchStore
.
SetRadiusSetter
(
kad
)
if
batchSvc
!=
nil
{
syncedChan
:=
batchSvc
.
Start
()
syncedChan
:=
batchSvc
.
Start
(
postageSyncStart
)
// wait for the postage contract listener to sync
logger
.
Info
(
"waiting to sync postage contract data, this may take a while... more info available in Debug loglevel"
)
...
...
pkg/postage/batchservice/batchservice.go
View file @
ea178d68
...
...
@@ -108,7 +108,10 @@ func (svc *batchService) UpdateBlockNumber(blockNumber uint64) error {
return
nil
}
func
(
svc
*
batchService
)
Start
()
<-
chan
struct
{}
{
func
(
svc
*
batchService
)
Start
(
startBlock
uint64
)
<-
chan
struct
{}
{
cs
:=
svc
.
storer
.
GetChainState
()
return
svc
.
listener
.
Listen
(
cs
.
Block
+
1
,
svc
)
if
cs
.
Block
>
startBlock
{
startBlock
=
cs
.
Block
}
return
svc
.
listener
.
Listen
(
startBlock
+
1
,
svc
)
}
pkg/postage/interface.go
View file @
ea178d68
...
...
@@ -17,7 +17,7 @@ type EventUpdater interface {
UpdateDepth
(
id
[]
byte
,
depth
uint8
,
normalisedBalance
*
big
.
Int
)
error
UpdatePrice
(
price
*
big
.
Int
)
error
UpdateBlockNumber
(
blockNumber
uint64
)
error
Start
()
<-
chan
struct
{}
Start
(
startBlock
uint64
)
<-
chan
struct
{}
}
// Storer represents the persistence layer for batches on the current (highest
...
...
pkg/postage/listener/listener.go
View file @
ea178d68
...
...
@@ -278,11 +278,17 @@ type priceUpdateEvent struct {
Price
*
big
.
Int
}
var
(
GoerliPostageStampContractAddress
=
common
.
HexToAddress
(
"0xF7a041E7e2B79ccA1975852Eb6D4c6cE52986b4a"
)
GoerliPriceOracleContractAddress
=
common
.
HexToAddress
(
"0x1044534090de6f4014ece6d036C699130Bd5Df43"
)
GoerliStartBlock
=
uint64
(
4247101
)
)
// DiscoverAddresses returns the canonical contracts for this chainID
func
DiscoverAddresses
(
chainID
int64
)
(
postageStamp
,
priceOracle
common
.
Address
,
found
bool
)
{
func
DiscoverAddresses
(
chainID
int64
)
(
postageStamp
,
priceOracle
common
.
Address
,
startBlock
uint64
,
found
bool
)
{
if
chainID
==
5
{
// goerli
return
common
.
HexToAddress
(
"0xF7a041E7e2B79ccA1975852Eb6D4c6cE52986b4a"
),
common
.
HexToAddress
(
"0x1044534090de6f4014ece6d036C699130Bd5Df43"
)
,
true
return
GoerliPostageStampContractAddress
,
GoerliPriceOracleContractAddress
,
GoerliStartBlock
,
true
}
return
common
.
Address
{},
common
.
Address
{},
false
return
common
.
Address
{},
common
.
Address
{},
0
,
false
}
pkg/postage/listener/listener_test.go
View file @
ea178d68
...
...
@@ -279,7 +279,7 @@ func (u *updater) UpdateBlockNumber(blockNumber uint64) error {
return
nil
}
func
(
u
*
updater
)
Start
()
<-
chan
struct
{}
{
return
nil
}
func
(
u
*
updater
)
Start
(
_
uint64
)
<-
chan
struct
{}
{
return
nil
}
type
mockFilterer
struct
{
filterLogEvents
[]
types
.
Log
...
...
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