diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/faucet/faucet.go | 19 | ||||
-rw-r--r-- | cmd/swarm/manifest.go | 6 |
2 files changed, 19 insertions, 6 deletions
diff --git a/cmd/faucet/faucet.go b/cmd/faucet/faucet.go index 095668c86..5bad09bbd 100644 --- a/cmd/faucet/faucet.go +++ b/cmd/faucet/faucet.go @@ -533,9 +533,11 @@ func (f *faucet) loop() { } defer sub.Unsubscribe() - for { - select { - case head := <-heads: + // Start a goroutine to update the state from head notifications in the background + update := make(chan *types.Header) + + go func() { + for head := range update { // New chain head arrived, query the current stats and stream to clients var ( balance *big.Int @@ -588,6 +590,17 @@ func (f *faucet) loop() { } } f.lock.RUnlock() + } + }() + // Wait for various events and assing to the appropriate background threads + for { + select { + case head := <-heads: + // New head arrived, send if for state update if there's none running + select { + case update <- head: + default: + } case <-f.update: // Pending requests updated, stream to clients diff --git a/cmd/swarm/manifest.go b/cmd/swarm/manifest.go index aa276e0f9..41a69a5d0 100644 --- a/cmd/swarm/manifest.go +++ b/cmd/swarm/manifest.go @@ -35,7 +35,7 @@ const bzzManifestJSON = "application/bzz-manifest+json" func add(ctx *cli.Context) { args := ctx.Args() if len(args) < 3 { - utils.Fatalf("Need atleast three arguments <MHASH> <path> <HASH> [<content-type>]") + utils.Fatalf("Need at least three arguments <MHASH> <path> <HASH> [<content-type>]") } var ( @@ -69,7 +69,7 @@ func update(ctx *cli.Context) { args := ctx.Args() if len(args) < 3 { - utils.Fatalf("Need atleast three arguments <MHASH> <path> <HASH>") + utils.Fatalf("Need at least three arguments <MHASH> <path> <HASH>") } var ( @@ -101,7 +101,7 @@ func update(ctx *cli.Context) { func remove(ctx *cli.Context) { args := ctx.Args() if len(args) < 2 { - utils.Fatalf("Need atleast two arguments <MHASH> <path>") + utils.Fatalf("Need at least two arguments <MHASH> <path>") } var ( |