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
d3ef3e19
Unverified
Commit
d3ef3e19
authored
May 13, 2021
by
acud
Committed by
GitHub
May 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add block-time cli flag (#1697)
parent
995af63f
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
30 additions
and
17 deletions
+30
-17
beekeeper.yml
.github/workflows/beekeeper.yml
+1
-1
cmd.go
cmd/bee/cmd/cmd.go
+2
-0
deploy.go
cmd/bee/cmd/deploy.go
+3
-0
start.go
cmd/bee/cmd/start.go
+1
-0
chain.go
pkg/node/chain.go
+2
-1
node.go
pkg/node/node.go
+3
-1
listener.go
pkg/postage/listener/listener.go
+13
-9
listener_test.go
pkg/postage/listener/listener_test.go
+5
-5
No files found.
.github/workflows/beekeeper.yml
View file @
d3ef3e19
...
...
@@ -76,7 +76,7 @@ jobs:
run
:
./beekeeper check settlements --api-scheme http --debug-api-scheme http --disable-namespace --debug-api-domain localhost --api-domain localhost --node-count "${REPLICA}" --upload-node-count "${REPLICA}" -t
1000000000000
-
name
:
Test pushsync (chunks)
id
:
pushsync-chunks-1
run
:
./beekeeper check pushsync --api-scheme http --debug-api-scheme http --disable-namespace --debug-api-domain localhost --api-domain localhost --node-count "${REPLICA}" --upload-node-count "${REPLICA}" --chunks-per-node 3 --upload-chunks
run
:
./beekeeper check pushsync --api-scheme http --debug-api-scheme http --disable-namespace --debug-api-domain localhost --api-domain localhost --node-count "${REPLICA}" --upload-node-count "${REPLICA}" --chunks-per-node 3 --upload-chunks
--retry-delay 10s
-
name
:
Test retrieval
id
:
retrieval-1
run
:
./beekeeper check retrieval --api-scheme http --debug-api-scheme http --disable-namespace --debug-api-domain localhost --api-domain localhost --node-count "${REPLICA}" --upload-node-count "${REPLICA}" --chunks-per-node
3
...
...
cmd/bee/cmd/cmd.go
View file @
d3ef3e19
...
...
@@ -62,6 +62,7 @@ const (
optionNameFullNode
=
"full-node"
optionNamePostageContractAddress
=
"postage-stamp-address"
optionNamePriceOracleAddress
=
"price-oracle-address"
optionNameBlockTime
=
"block-time"
)
func
init
()
{
...
...
@@ -232,6 +233,7 @@ func (c *command) setAllFlags(cmd *cobra.Command) {
cmd
.
Flags
()
.
String
(
optionNamePostageContractAddress
,
""
,
"postage stamp contract address"
)
cmd
.
Flags
()
.
String
(
optionNamePriceOracleAddress
,
""
,
"price oracle address"
)
cmd
.
Flags
()
.
String
(
optionNameTransactionHash
,
""
,
"proof-of-identity transaction hash"
)
cmd
.
Flags
()
.
Uint64
(
optionNameBlockTime
,
15
,
"chain block time"
)
}
func
newLogger
(
cmd
*
cobra
.
Command
,
verbosity
string
)
(
logging
.
Logger
,
error
)
{
...
...
cmd/bee/cmd/deploy.go
View file @
d3ef3e19
...
...
@@ -12,6 +12,8 @@ import (
"github.com/spf13/cobra"
)
const
blocktime
=
15
func
(
c
*
command
)
initDeployCmd
()
error
{
cmd
:=
&
cobra
.
Command
{
Use
:
"deploy"
,
...
...
@@ -58,6 +60,7 @@ func (c *command) initDeployCmd() error {
stateStore
,
swapEndpoint
,
signer
,
blocktime
,
)
if
err
!=
nil
{
return
err
...
...
cmd/bee/cmd/start.go
View file @
d3ef3e19
...
...
@@ -151,6 +151,7 @@ Welcome to the Swarm.... Bzzz Bzzzz Bzzzz
Transaction
:
c
.
config
.
GetString
(
optionNameTransactionHash
),
PostageContractAddress
:
c
.
config
.
GetString
(
optionNamePostageContractAddress
),
PriceOracleAddress
:
c
.
config
.
GetString
(
optionNamePriceOracleAddress
),
BlockTime
:
c
.
config
.
GetUint64
(
optionNameBlockTime
),
})
if
err
!=
nil
{
return
err
...
...
pkg/node/chain.go
View file @
d3ef3e19
...
...
@@ -25,7 +25,6 @@ import (
const
(
maxDelay
=
1
*
time
.
Minute
pollingInterval
=
15
*
time
.
Second
cancellationDepth
=
6
)
...
...
@@ -37,6 +36,7 @@ func InitChain(
stateStore
storage
.
StateStorer
,
endpoint
string
,
signer
crypto
.
Signer
,
blocktime
uint64
,
)
(
*
ethclient
.
Client
,
common
.
Address
,
int64
,
transaction
.
Monitor
,
transaction
.
Service
,
error
)
{
backend
,
err
:=
ethclient
.
Dial
(
endpoint
)
if
err
!=
nil
{
...
...
@@ -49,6 +49,7 @@ func InitChain(
return
nil
,
common
.
Address
{},
0
,
nil
,
nil
,
fmt
.
Errorf
(
"get chain id: %w"
,
err
)
}
pollingInterval
:=
time
.
Duration
(
blocktime
)
*
time
.
Second
overlayEthAddress
,
err
:=
signer
.
EthereumAddress
()
if
err
!=
nil
{
return
nil
,
common
.
Address
{},
0
,
nil
,
nil
,
fmt
.
Errorf
(
"eth address: %w"
,
err
)
...
...
pkg/node/node.go
View file @
d3ef3e19
...
...
@@ -131,6 +131,7 @@ type Options struct {
Transaction
string
PostageContractAddress
string
PriceOracleAddress
string
BlockTime
uint64
}
func
NewBee
(
addr
string
,
swarmAddress
swarm
.
Address
,
publicKey
ecdsa
.
PublicKey
,
signer
crypto
.
Signer
,
networkID
uint64
,
logger
logging
.
Logger
,
libp2pPrivateKey
,
pssPrivateKey
*
ecdsa
.
PrivateKey
,
o
Options
)
(
b
*
Bee
,
err
error
)
{
...
...
@@ -223,6 +224,7 @@ func NewBee(addr string, swarmAddress swarm.Address, publicKey ecdsa.PublicKey,
stateStore
,
o
.
SwapEndpoint
,
signer
,
o
.
BlockTime
,
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"init chain: %w"
,
err
)
...
...
@@ -351,7 +353,7 @@ func NewBee(addr string, swarmAddress swarm.Address, publicKey ecdsa.PublicKey,
return
nil
,
errors
.
New
(
"no known postage stamp addresses for this network"
)
}
eventListener
:=
listener
.
New
(
logger
,
swapBackend
,
postageContractAddress
,
priceOracleAddress
)
eventListener
:=
listener
.
New
(
logger
,
swapBackend
,
postageContractAddress
,
priceOracleAddress
,
o
.
BlockTime
)
b
.
listenerCloser
=
eventListener
batchSvc
=
batchservice
.
New
(
batchStore
,
logger
,
eventListener
)
...
...
pkg/postage/listener/listener.go
View file @
d3ef3e19
...
...
@@ -25,14 +25,13 @@ import (
)
const
(
blockPage
=
10000
// how many blocks to sync every tim
e
tailSize
=
4
// how many blocks to tail from the tip of the chain
blockPage
=
5000
// how many blocks to sync every time we pag
e
tailSize
=
4
// how many blocks to tail from the tip of the chain
)
var
(
chainUpdateInterval
=
5
*
time
.
Second
postageStampABI
=
parseABI
(
postageabi
.
PostageStampABIv0_1_0
)
priceOracleABI
=
parseABI
(
postageabi
.
PriceOracleABIv0_1_0
)
postageStampABI
=
parseABI
(
postageabi
.
PostageStampABIv0_1_0
)
priceOracleABI
=
parseABI
(
postageabi
.
PriceOracleABIv0_1_0
)
// batchCreatedTopic is the postage contract's batch created event topic
batchCreatedTopic
=
postageStampABI
.
Events
[
"BatchCreated"
]
.
ID
// batchTopupTopic is the postage contract's batch topup event topic
...
...
@@ -49,8 +48,9 @@ type BlockHeightContractFilterer interface {
}
type
listener
struct
{
logger
logging
.
Logger
ev
BlockHeightContractFilterer
logger
logging
.
Logger
ev
BlockHeightContractFilterer
blockTime
uint64
postageStampAddress
common
.
Address
priceOracleAddress
common
.
Address
...
...
@@ -63,10 +63,12 @@ func New(
ev
BlockHeightContractFilterer
,
postageStampAddress
,
priceOracleAddress
common
.
Address
,
blockTime
uint64
,
)
postage
.
Listener
{
return
&
listener
{
logger
:
logger
,
ev
:
ev
,
logger
:
logger
,
ev
:
ev
,
blockTime
:
blockTime
,
postageStampAddress
:
postageStampAddress
,
priceOracleAddress
:
priceOracleAddress
,
...
...
@@ -149,6 +151,8 @@ func (l *listener) Listen(from uint64, updater postage.EventUpdater) <-chan stru
cancel
()
}()
chainUpdateInterval
:=
(
time
.
Duration
(
l
.
blockTime
)
*
time
.
Second
)
/
2
synced
:=
make
(
chan
struct
{})
closeOnce
:=
new
(
sync
.
Once
)
paged
:=
make
(
chan
struct
{},
1
)
...
...
pkg/postage/listener/listener_test.go
View file @
d3ef3e19
...
...
@@ -45,7 +45,7 @@ func TestListener(t *testing.T) {
c
.
toLog
(),
),
)
listener
:=
listener
.
New
(
logger
,
mf
,
postageStampAddress
,
priceOracleAddress
)
listener
:=
listener
.
New
(
logger
,
mf
,
postageStampAddress
,
priceOracleAddress
,
1
)
listener
.
Listen
(
0
,
ev
)
select
{
...
...
@@ -76,7 +76,7 @@ func TestListener(t *testing.T) {
topup
.
toLog
(),
),
)
listener
:=
listener
.
New
(
logger
,
mf
,
postageStampAddress
,
priceOracleAddress
)
listener
:=
listener
.
New
(
logger
,
mf
,
postageStampAddress
,
priceOracleAddress
,
1
)
listener
.
Listen
(
0
,
ev
)
select
{
...
...
@@ -107,7 +107,7 @@ func TestListener(t *testing.T) {
depthIncrease
.
toLog
(),
),
)
listener
:=
listener
.
New
(
logger
,
mf
,
postageStampAddress
,
priceOracleAddress
)
listener
:=
listener
.
New
(
logger
,
mf
,
postageStampAddress
,
priceOracleAddress
,
1
)
listener
.
Listen
(
0
,
ev
)
select
{
...
...
@@ -136,7 +136,7 @@ func TestListener(t *testing.T) {
priceUpdate
.
toLog
(),
),
)
listener
:=
listener
.
New
(
logger
,
mf
,
postageStampAddress
,
priceOracleAddress
)
listener
:=
listener
.
New
(
logger
,
mf
,
postageStampAddress
,
priceOracleAddress
,
1
)
listener
.
Listen
(
0
,
ev
)
select
{
...
...
@@ -191,7 +191,7 @@ func TestListener(t *testing.T) {
),
WithBlockNumber
(
blockNumber
),
)
l
:=
listener
.
New
(
logger
,
mf
,
postageStampAddress
,
priceOracleAddress
)
l
:=
listener
.
New
(
logger
,
mf
,
postageStampAddress
,
priceOracleAddress
,
1
)
l
.
Listen
(
0
,
ev
)
select
{
...
...
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