swarm/storage/feeds: Final package rename and moved files
This commit is contained in:
@ -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/>.
|
||||
|
||||
package mru
|
||||
package feeds
|
||||
|
||||
import "github.com/ethereum/go-ethereum/common/hexutil"
|
||||
|
@ -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/>.
|
||||
|
||||
package mru
|
||||
package feeds
|
||||
|
||||
import (
|
||||
"encoding/json"
|
@ -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/>.
|
||||
|
||||
package mru
|
||||
package feeds
|
||||
|
||||
import (
|
||||
"bytes"
|
@ -40,4 +40,4 @@ Request: Feed Update with signature
|
||||
Epoch: time slot where the update is stored
|
||||
|
||||
*/
|
||||
package mru
|
||||
package feeds
|
@ -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/>.
|
||||
|
||||
package mru
|
||||
package feeds
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@ -47,7 +47,7 @@ func (e *Error) Error() string {
|
||||
}
|
||||
|
||||
// Code returns the error code
|
||||
// Error codes are enumerated in the error.go file within the mru package
|
||||
// Error codes are enumerated in the error.go file within the feeds package
|
||||
func (e *Error) Code() int {
|
||||
return e.code
|
||||
}
|
@ -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/>.
|
||||
|
||||
package mru
|
||||
package feeds
|
||||
|
||||
import (
|
||||
"hash"
|
||||
@ -37,9 +37,9 @@ type Feed struct {
|
||||
const feedLength = TopicLength + common.AddressLength
|
||||
|
||||
// mapKey calculates a unique id for this feed. Used by the cache map in `Handler`
|
||||
func (u *Feed) mapKey() uint64 {
|
||||
func (f *Feed) mapKey() uint64 {
|
||||
serializedData := make([]byte, feedLength)
|
||||
u.binaryPut(serializedData)
|
||||
f.binaryPut(serializedData)
|
||||
hasher := hashPool.Get().(hash.Hash)
|
||||
defer hashPool.Put(hasher)
|
||||
hasher.Reset()
|
||||
@ -49,54 +49,54 @@ func (u *Feed) mapKey() uint64 {
|
||||
}
|
||||
|
||||
// binaryPut serializes this Feed instance into the provided slice
|
||||
func (u *Feed) binaryPut(serializedData []byte) error {
|
||||
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))
|
||||
}
|
||||
var cursor int
|
||||
copy(serializedData[cursor:cursor+TopicLength], u.Topic[:TopicLength])
|
||||
copy(serializedData[cursor:cursor+TopicLength], f.Topic[:TopicLength])
|
||||
cursor += TopicLength
|
||||
|
||||
copy(serializedData[cursor:cursor+common.AddressLength], u.User[:])
|
||||
copy(serializedData[cursor:cursor+common.AddressLength], f.User[:])
|
||||
cursor += common.AddressLength
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// binaryLength returns the expected size of this structure when serialized
|
||||
func (u *Feed) binaryLength() int {
|
||||
func (f *Feed) binaryLength() int {
|
||||
return feedLength
|
||||
}
|
||||
|
||||
// binaryGet restores the current instance from the information contained in the passed slice
|
||||
func (u *Feed) binaryGet(serializedData []byte) error {
|
||||
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))
|
||||
}
|
||||
|
||||
var cursor int
|
||||
copy(u.Topic[:], serializedData[cursor:cursor+TopicLength])
|
||||
copy(f.Topic[:], serializedData[cursor:cursor+TopicLength])
|
||||
cursor += TopicLength
|
||||
|
||||
copy(u.User[:], serializedData[cursor:cursor+common.AddressLength])
|
||||
copy(f.User[:], serializedData[cursor:cursor+common.AddressLength])
|
||||
cursor += common.AddressLength
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Hex serializes the Feed to a hex string
|
||||
func (u *Feed) Hex() string {
|
||||
func (f *Feed) Hex() string {
|
||||
serializedData := make([]byte, feedLength)
|
||||
u.binaryPut(serializedData)
|
||||
f.binaryPut(serializedData)
|
||||
return hexutil.Encode(serializedData)
|
||||
}
|
||||
|
||||
// FromValues deserializes this instance from a string key-value store
|
||||
// useful to parse query strings
|
||||
func (u *Feed) FromValues(values Values) (err error) {
|
||||
func (f *Feed) FromValues(values Values) (err error) {
|
||||
topic := values.Get("topic")
|
||||
if topic != "" {
|
||||
if err := u.Topic.FromHex(values.Get("topic")); err != nil {
|
||||
if err := f.Topic.FromHex(values.Get("topic")); err != nil {
|
||||
return err
|
||||
}
|
||||
} else { // see if the user set name and relatedcontent
|
||||
@ -108,18 +108,18 @@ func (u *Feed) FromValues(values Values) (err error) {
|
||||
}
|
||||
relatedContent = relatedContent[:storage.AddressLength]
|
||||
}
|
||||
u.Topic, err = NewTopic(name, relatedContent)
|
||||
f.Topic, err = NewTopic(name, relatedContent)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
u.User = common.HexToAddress(values.Get("user"))
|
||||
f.User = common.HexToAddress(values.Get("user"))
|
||||
return nil
|
||||
}
|
||||
|
||||
// AppendValues serializes this structure into the provided string key-value store
|
||||
// useful to build query strings
|
||||
func (u *Feed) AppendValues(values Values) {
|
||||
values.Set("topic", u.Topic.Hex())
|
||||
values.Set("user", u.User.Hex())
|
||||
func (f *Feed) AppendValues(values Values) {
|
||||
values.Set("topic", f.Topic.Hex())
|
||||
values.Set("user", f.User.Hex())
|
||||
}
|
@ -13,7 +13,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/>.
|
||||
package mru
|
||||
package feeds
|
||||
|
||||
import (
|
||||
"testing"
|
@ -16,7 +16,7 @@
|
||||
|
||||
// Handler is the API for Feeds
|
||||
// It enables creating, updating, syncing and retrieving feed updates and their data
|
||||
package mru
|
||||
package feeds
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@ -25,7 +25,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/swarm/storage/mru/lookup"
|
||||
"github.com/ethereum/go-ethereum/swarm/storage/feeds/lookup"
|
||||
|
||||
"github.com/ethereum/go-ethereum/swarm/log"
|
||||
"github.com/ethereum/go-ethereum/swarm/storage"
|
@ -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/>.
|
||||
|
||||
package mru
|
||||
package feeds
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@ -31,7 +31,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
"github.com/ethereum/go-ethereum/swarm/storage"
|
||||
"github.com/ethereum/go-ethereum/swarm/storage/mru/lookup"
|
||||
"github.com/ethereum/go-ethereum/swarm/storage/feeds/lookup"
|
||||
)
|
||||
|
||||
var (
|
@ -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/>.
|
||||
|
||||
package mru
|
||||
package feeds
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@ -22,7 +22,7 @@ import (
|
||||
"strconv"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/swarm/storage/mru/lookup"
|
||||
"github.com/ethereum/go-ethereum/swarm/storage/feeds/lookup"
|
||||
|
||||
"github.com/ethereum/go-ethereum/swarm/storage"
|
||||
)
|
@ -1,9 +1,9 @@
|
||||
package mru
|
||||
package feeds
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/swarm/storage/mru/lookup"
|
||||
"github.com/ethereum/go-ethereum/swarm/storage/feeds/lookup"
|
||||
)
|
||||
|
||||
func getTestID() *ID {
|
@ -3,7 +3,7 @@ package lookup_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/swarm/storage/mru/lookup"
|
||||
"github.com/ethereum/go-ethereum/swarm/storage/feeds/lookup"
|
||||
)
|
||||
|
||||
func TestMarshallers(t *testing.T) {
|
@ -22,7 +22,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/swarm/log"
|
||||
"github.com/ethereum/go-ethereum/swarm/storage/mru/lookup"
|
||||
"github.com/ethereum/go-ethereum/swarm/storage/feeds/lookup"
|
||||
)
|
||||
|
||||
type Data struct {
|
@ -14,14 +14,14 @@
|
||||
// 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/>.
|
||||
|
||||
package mru
|
||||
package feeds
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/swarm/storage/mru/lookup"
|
||||
"github.com/ethereum/go-ethereum/swarm/storage/feeds/lookup"
|
||||
)
|
||||
|
||||
// Query is used to specify constraints when performing an update lookup
|
@ -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/>.
|
||||
|
||||
package mru
|
||||
package feeds
|
||||
|
||||
import (
|
||||
"testing"
|
@ -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/>.
|
||||
|
||||
package mru
|
||||
package feeds
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@ -24,7 +24,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/swarm/storage"
|
||||
"github.com/ethereum/go-ethereum/swarm/storage/mru/lookup"
|
||||
"github.com/ethereum/go-ethereum/swarm/storage/feeds/lookup"
|
||||
)
|
||||
|
||||
// Request represents a request to sign or signed Feed Update message
|
@ -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/>.
|
||||
|
||||
package mru
|
||||
package feeds
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@ -26,7 +26,7 @@ import (
|
||||
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/swarm/storage"
|
||||
"github.com/ethereum/go-ethereum/swarm/storage/mru/lookup"
|
||||
"github.com/ethereum/go-ethereum/swarm/storage/feeds/lookup"
|
||||
)
|
||||
|
||||
func areEqualJSON(s1, s2 string) (bool, error) {
|
@ -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/>.
|
||||
|
||||
package mru
|
||||
package feeds
|
||||
|
||||
import (
|
||||
"crypto/ecdsa"
|
@ -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/>.
|
||||
|
||||
package mru
|
||||
package feeds
|
||||
|
||||
import (
|
||||
"context"
|
@ -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/>.
|
||||
|
||||
package mru
|
||||
package feeds
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
@ -22,7 +22,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// TimestampProvider sets the time source of the mru package
|
||||
// TimestampProvider sets the time source of the feeds package
|
||||
var TimestampProvider timestampProvider = NewDefaultTimestampProvider()
|
||||
|
||||
// Timestamp encodes a point in time as a Unix epoch
|
@ -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/>.
|
||||
|
||||
package mru
|
||||
package feeds
|
||||
|
||||
import (
|
||||
"bytes"
|
@ -1,4 +1,4 @@
|
||||
package mru
|
||||
package feeds
|
||||
|
||||
import (
|
||||
"testing"
|
@ -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/>.
|
||||
|
||||
package mru
|
||||
package feeds
|
||||
|
||||
import (
|
||||
"fmt"
|
@ -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/>.
|
||||
|
||||
package mru
|
||||
package feeds
|
||||
|
||||
import (
|
||||
"testing"
|
Reference in New Issue
Block a user