swarm/storage/feeds: removed capital Feed throughout

This commit is contained in:
Javier Peletier
2018-10-02 09:32:46 +02:00
parent 68b8088cb9
commit 58c0879c2f
20 changed files with 60 additions and 60 deletions

View File

@ -30,7 +30,7 @@ const (
defaultRetrieveTimeout = 100 * time.Millisecond
)
// cacheEntry caches the last known update of a specific Feed.
// cacheEntry caches the last known update of a specific Swarm feed.
type cacheEntry struct {
Update
*bytes.Reader
@ -42,7 +42,7 @@ func (r *cacheEntry) Size(ctx context.Context, _ chan bool) (int64, error) {
return int64(len(r.Update.data)), nil
}
//returns the Feed's topic
//returns the feed's topic
func (r *cacheEntry) Topic() Topic {
return r.Feed.Topic
}

View File

@ -35,7 +35,7 @@ const (
ErrCnt
)
// Error is a the typed error object used for Swarm Feeds
// Error is a the typed error object used for Swarm feeds
type Error struct {
code int
err string
@ -52,7 +52,7 @@ func (e *Error) Code() int {
return e.code
}
// NewError creates a new Swarm Feeds Error object with the specified code and custom error message
// NewError creates a new Swarm feeds Error object with the specified code and custom error message
func NewError(code int, s string) error {
if code < 0 || code >= ErrCnt {
panic("no such error code!")

View File

@ -25,7 +25,7 @@ import (
"github.com/ethereum/go-ethereum/swarm/storage"
)
// Feed represents a particular user's stream of updates on a Topic
// Feed represents a particular user's stream of updates on a topic
type Feed struct {
Topic Topic `json:"topic"`
User common.Address `json:"user"`
@ -48,10 +48,10 @@ func (f *Feed) mapKey() uint64 {
return *(*uint64)(unsafe.Pointer(&hash[0]))
}
// binaryPut serializes this Feed instance into the provided slice
// binaryPut serializes this feed instance into the provided slice
func (f *Feed) binaryPut(serializedData []byte) error {
if len(serializedData) != feedLength {
return NewErrorf(ErrInvalidValue, "Incorrect slice size to serialize Feed. Expected %d, got %d", feedLength, len(serializedData))
return NewErrorf(ErrInvalidValue, "Incorrect slice size to serialize feed. Expected %d, got %d", feedLength, len(serializedData))
}
var cursor int
copy(serializedData[cursor:cursor+TopicLength], f.Topic[:TopicLength])
@ -71,7 +71,7 @@ func (f *Feed) binaryLength() int {
// binaryGet restores the current instance from the information contained in the passed slice
func (f *Feed) binaryGet(serializedData []byte) error {
if len(serializedData) != feedLength {
return NewErrorf(ErrInvalidValue, "Incorrect slice size to read Feed. Expected %d, got %d", feedLength, len(serializedData))
return NewErrorf(ErrInvalidValue, "Incorrect slice size to read feed. Expected %d, got %d", feedLength, len(serializedData))
}
var cursor int
@ -84,7 +84,7 @@ func (f *Feed) binaryGet(serializedData []byte) error {
return nil
}
// Hex serializes the Feed to a hex string
// Hex serializes the feed to a hex string
func (f *Feed) Hex() string {
serializedData := make([]byte, feedLength)
f.binaryPut(serializedData)

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
// Handler is the API for Feeds
// Handler is the API for feeds
// It enables creating, updating, syncing and retrieving feed updates and their data
package feeds
@ -57,7 +57,7 @@ func init() {
}
}
// NewHandler creates a new Swarm Feeds API
// NewHandler creates a new Swarm feeds API
func NewHandler(params *HandlerParams) *Handler {
fh := &Handler{
cache: make(map[uint64]*cacheEntry),
@ -74,7 +74,7 @@ func NewHandler(params *HandlerParams) *Handler {
return fh
}
// SetStore sets the store backend for the Swarm Feeds API
// SetStore sets the store backend for the Swarm feeds API
func (h *Handler) SetStore(store *storage.NetStore) {
h.chunkStore = store
}
@ -110,7 +110,7 @@ func (h *Handler) Validate(chunkAddr storage.Address, data []byte) bool {
return true
}
// GetContent retrieves the data payload of the last synced update of the Feed
// GetContent retrieves the data payload of the last synced update of the feed
func (h *Handler) GetContent(feed *Feed) (storage.Address, []byte, error) {
if feed == nil {
return nil, nil, NewError(ErrInvalidValue, "feed is nil")
@ -240,7 +240,7 @@ func (h *Handler) updateCache(request *Request) (*cacheEntry, error) {
}
// Update publishes a feed update
// Note that a Feed update cannot span chunks, and thus has a MAX NET LENGTH 4096, INCLUDING update header data and signature.
// Note that a feed update cannot span chunks, and thus has a MAX NET LENGTH 4096, INCLUDING update header data and signature.
// This results in a max payload of `maxUpdateDataLength` (check update.go for more details)
// An error will be returned if the total length of the chunk payload will exceed this limit.
// Update can only check if the caller is trying to overwrite the very last known version, otherwise it just puts the update
@ -286,7 +286,7 @@ func (h *Handler) get(feed *Feed) *cacheEntry {
return feedUpdate
}
// Sets the feed update cache value for the given Feed
// Sets the feed update cache value for the given feed
func (h *Handler) set(feed *Feed, feedUpdate *cacheEntry) {
mapKey := feed.mapKey()
h.cacheLock.Lock()

View File

@ -89,11 +89,11 @@ func TestFeedsHandler(t *testing.T) {
}
defer teardownTest()
// create a new Feed
// create a new feed
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
topic, _ := NewTopic("Mess with Swarm Feeds code and see what ghost catches you", nil)
topic, _ := NewTopic("Mess with Swarm feeds code and see what ghost catches you", nil)
feed := Feed{
Topic: topic,
User: signer.Address(),
@ -266,7 +266,7 @@ func TestSparseUpdates(t *testing.T) {
defer teardownTest()
defer os.RemoveAll(datadir)
// create a new Feed
// create a new feed
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
topic, _ := NewTopic("Very slow updates", nil)
@ -348,7 +348,7 @@ func TestValidator(t *testing.T) {
}
defer teardownTest()
// create new Feed
// create new feed
topic, _ := NewTopic(subtopicName, nil)
feed := Feed{
Topic: topic,
@ -382,7 +382,7 @@ func TestValidator(t *testing.T) {
}
// tests that the content address validator correctly checks the data
// tests that Feed update chunks are passed through content address validator
// tests that feed update chunks are passed through content address validator
// there is some redundancy in this test as it also tests content addressed chunks,
// which should be evaluated as invalid chunks by this validator
func TestValidatorInStore(t *testing.T) {
@ -409,7 +409,7 @@ func TestValidatorInStore(t *testing.T) {
t.Fatal(err)
}
// set up Swarm Feeds handler and add is as a validator to the localstore
// set up Swarm feeds handler and add is as a validator to the localstore
fhParams := &HandlerParams{}
fh := NewHandler(fhParams)
store.Validators = append(store.Validators, fh)
@ -463,7 +463,7 @@ func TestValidatorInStore(t *testing.T) {
}
}
// create rpc and Feeds Handler
// create rpc and feeds Handler
func setupTest(timeProvider timestampProvider, signer Signer) (fh *TestHandler, datadir string, teardown func(), err error) {
var fsClean func()

View File

@ -15,7 +15,7 @@
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
/*
Package lookup defines Feed lookup algorithms and provides tools to place updates
Package lookup defines feed lookup algorithms and provides tools to place updates
so they can be found
*/
package lookup

View File

@ -27,7 +27,7 @@ import (
"github.com/ethereum/go-ethereum/swarm/storage/feeds/lookup"
)
// Request represents a request to sign or signed Feed Update message
// Request represents a request to sign or signed feed update message
type Request struct {
Update // actual content that will be put on the chunk, less signature
Signature *Signature

View File

@ -47,7 +47,7 @@ func areEqualJSON(s1, s2 string) (bool, error) {
}
// TestEncodingDecodingUpdateRequests ensures that requests are serialized properly
// while also checking cryptographically that only the owner of a Feed can update it.
// while also checking cryptographically that only the owner of a feed can update it.
func TestEncodingDecodingUpdateRequests(t *testing.T) {
charlie := newCharlieSigner() //Charlie
@ -136,7 +136,7 @@ func TestEncodingDecodingUpdateRequests(t *testing.T) {
t.Fatal("Expected DecodeUpdateRequest to fail when trying to interpret a corrupt message with an invalid signature")
}
// Now imagine Bob wants to create an update of his own about the same Feed,
// Now imagine Bob wants to create an update of his own about the same feed,
// signing a message with his private key
if err := request.Sign(bob); err != nil {
t.Fatalf("Error signing: %s", err)
@ -228,7 +228,7 @@ func TestUpdateChunkSerializationErrorChecking(t *testing.T) {
var recovered Request
recovered.fromChunk(chunk.Address(), chunk.Data())
if !reflect.DeepEqual(recovered, r) {
t.Fatal("Expected recovered Request update to equal the original one")
t.Fatal("Expected recovered feed update request to equal the original one")
}
}
@ -248,7 +248,7 @@ func TestReverse(t *testing.T) {
// signer containing private key
signer := newAliceSigner()
// set up rpc and create Feeds handler
// set up rpc and create feeds handler
_, _, teardownTest, err := setupTest(timeProvider, signer)
if err != nil {
t.Fatal(err)

View File

@ -28,7 +28,7 @@ const signatureLength = 65
// Signature is an alias for a static byte array with the size of a signature
type Signature [signatureLength]byte
// Signer signs Feed update payloads
// Signer signs feed update payloads
type Signer interface {
Sign(common.Hash) (Signature, error)
Address() common.Address
@ -65,7 +65,7 @@ func (s *GenericSigner) Address() common.Address {
return s.address
}
// getUserAddr extracts the address of the Feed update signer
// getUserAddr extracts the address of the feed update signer
func getUserAddr(digest common.Hash, signature Signature) (common.Address, error) {
pub, err := crypto.SigToPub(digest.Bytes(), signature[:])
if err != nil {

View File

@ -30,7 +30,7 @@ var (
)
// tests that the content address validator correctly checks the data
// tests that Feed update chunks are passed through content address validator
// tests that feed update chunks are passed through content address validator
// the test checking the resouce update validator internal correctness is found in storage/feeds/handler_test.go
func TestValidator(t *testing.T) {
// set up localstore