mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 09:23:48 +00:00
swarm/storage, swarm/api: Change noparam fmt.Errorf -> errors.New
This commit is contained in:
parent
703051b1aa
commit
c2e0be67c8
3 changed files with 13 additions and 12 deletions
|
|
@ -447,7 +447,7 @@ func (s *Server) HandleGet(w http.ResponseWriter, r *Request) {
|
||||||
return api.SkipManifest
|
return api.SkipManifest
|
||||||
})
|
})
|
||||||
if entry == nil {
|
if entry == nil {
|
||||||
s.NotFound(w, r, fmt.Errorf("Manifest entry could not be loaded"))
|
s.NotFound(w, r, errors.New("Manifest entry could not be loaded"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
key = storage.Key(common.Hex2Bytes(entry.Hash))
|
key = storage.Key(common.Hex2Bytes(entry.Hash))
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package storage
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -192,7 +193,7 @@ func (self *ResourceHandler) HashSize() int {
|
||||||
func (self *ResourceHandler) GetContent(name string) (Key, []byte, error) {
|
func (self *ResourceHandler) GetContent(name string) (Key, []byte, error) {
|
||||||
rsrc := self.getResource(name)
|
rsrc := self.getResource(name)
|
||||||
if rsrc == nil || !rsrc.isSynced() {
|
if rsrc == nil || !rsrc.isSynced() {
|
||||||
return nil, nil, fmt.Errorf("Resource does not exist or is not synced")
|
return nil, nil, errors.New("Resource does not exist or is not synced")
|
||||||
}
|
}
|
||||||
return rsrc.lastKey, rsrc.data, nil
|
return rsrc.lastKey, rsrc.data, nil
|
||||||
}
|
}
|
||||||
|
|
@ -201,7 +202,7 @@ func (self *ResourceHandler) GetLastPeriod(name string) (uint32, error) {
|
||||||
rsrc := self.getResource(name)
|
rsrc := self.getResource(name)
|
||||||
|
|
||||||
if rsrc == nil || !rsrc.isSynced() {
|
if rsrc == nil || !rsrc.isSynced() {
|
||||||
return 0, fmt.Errorf("Resource does not exist or is not synced")
|
return 0, errors.New("Resource does not exist or is not synced")
|
||||||
}
|
}
|
||||||
return rsrc.lastPeriod, nil
|
return rsrc.lastPeriod, nil
|
||||||
}
|
}
|
||||||
|
|
@ -209,7 +210,7 @@ func (self *ResourceHandler) GetLastPeriod(name string) (uint32, error) {
|
||||||
func (self *ResourceHandler) GetVersion(name string) (uint32, error) {
|
func (self *ResourceHandler) GetVersion(name string) (uint32, error) {
|
||||||
rsrc := self.getResource(name)
|
rsrc := self.getResource(name)
|
||||||
if rsrc == nil || !rsrc.isSynced() {
|
if rsrc == nil || !rsrc.isSynced() {
|
||||||
return 0, fmt.Errorf("Resource does not exist or is not synced")
|
return 0, errors.New("Resource does not exist or is not synced")
|
||||||
}
|
}
|
||||||
return rsrc.version, nil
|
return rsrc.version, nil
|
||||||
}
|
}
|
||||||
|
|
@ -228,7 +229,7 @@ func (self *ResourceHandler) NewResource(name string, frequency uint64) (*resour
|
||||||
|
|
||||||
// frequency 0 is invalid
|
// frequency 0 is invalid
|
||||||
if frequency == 0 {
|
if frequency == 0 {
|
||||||
return nil, fmt.Errorf("Frequency cannot be 0")
|
return nil, errors.New("Frequency cannot be 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !isSafeName(name) {
|
if !isSafeName(name) {
|
||||||
|
|
@ -360,7 +361,7 @@ func (self *ResourceHandler) LookupLatest(nameHash common.Hash, name string, ref
|
||||||
func (self *ResourceHandler) lookup(rsrc *resource, period uint32, version uint32, refresh bool) (*resource, error) {
|
func (self *ResourceHandler) lookup(rsrc *resource, period uint32, version uint32, refresh bool) (*resource, error) {
|
||||||
|
|
||||||
if period == 0 {
|
if period == 0 {
|
||||||
return nil, fmt.Errorf("period must be >0")
|
return nil, errors.New("period must be >0")
|
||||||
}
|
}
|
||||||
|
|
||||||
// start from the last possible block period, and iterate previous ones until we find a match
|
// start from the last possible block period, and iterate previous ones until we find a match
|
||||||
|
|
@ -396,7 +397,7 @@ func (self *ResourceHandler) lookup(rsrc *resource, period uint32, version uint3
|
||||||
log.Trace("rsrc update not found, checking previous period", "period", period, "key", key)
|
log.Trace("rsrc update not found, checking previous period", "period", period, "key", key)
|
||||||
period--
|
period--
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("no updates found")
|
return nil, errors.New("no updates found")
|
||||||
}
|
}
|
||||||
|
|
||||||
// load existing mutable resource into resource struct
|
// load existing mutable resource into resource struct
|
||||||
|
|
@ -525,10 +526,10 @@ func (self *ResourceHandler) Update(name string, data []byte) (Key, error) {
|
||||||
// get the cached information
|
// get the cached information
|
||||||
rsrc := self.getResource(name)
|
rsrc := self.getResource(name)
|
||||||
if rsrc == nil {
|
if rsrc == nil {
|
||||||
return nil, fmt.Errorf("Resource object not in index")
|
return nil, errors.New("Resource object not in index")
|
||||||
}
|
}
|
||||||
if !rsrc.isSynced() {
|
if !rsrc.isSynced() {
|
||||||
return nil, fmt.Errorf("Resource object not in sync")
|
return nil, errors.New("Resource object not in sync")
|
||||||
}
|
}
|
||||||
|
|
||||||
// an update can be only one chunk long
|
// an update can be only one chunk long
|
||||||
|
|
@ -747,7 +748,7 @@ func (r *resourceChunkStore) Get(key Key) (*Chunk, error) {
|
||||||
t := time.NewTimer(time.Second * 1)
|
t := time.NewTimer(time.Second * 1)
|
||||||
select {
|
select {
|
||||||
case <-t.C:
|
case <-t.C:
|
||||||
return nil, fmt.Errorf("timeout")
|
return nil, errors.New("timeout")
|
||||||
case <-chunk.C:
|
case <-chunk.C:
|
||||||
log.Trace("Received resource update chunk", "peer", chunk.Req.Source)
|
log.Trace("Received resource update chunk", "peer", chunk.Req.Source)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package storage
|
package storage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"errors"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
|
@ -15,7 +15,7 @@ type baseValidator struct {
|
||||||
|
|
||||||
func (b *baseValidator) sign(datahash common.Hash) (signature Signature, err error) {
|
func (b *baseValidator) sign(datahash common.Hash) (signature Signature, err error) {
|
||||||
if b.signFunc == nil {
|
if b.signFunc == nil {
|
||||||
return signature, fmt.Errorf("No signature function")
|
return signature, errors.New("No signature function")
|
||||||
}
|
}
|
||||||
return b.signFunc(datahash)
|
return b.signFunc(datahash)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue