aboutsummaryrefslogtreecommitdiffstats
path: root/swarm
diff options
context:
space:
mode:
authorJavier Peletier <jpeletier@users.noreply.github.com>2018-10-08 16:57:38 +0800
committerAnton Evangelatov <anton.evangelatov@gmail.com>2018-10-08 16:57:38 +0800
commitc5cb214f689e5c34bf487daa8eb4234d6e3237a7 (patch)
tree7e5c53aece32ae9dce8089a62ccfdbeb27527e82 /swarm
parentf95811e65bcc674ae32c19c043b29226a56a6a5f (diff)
downloadgo-tangerine-c5cb214f689e5c34bf487daa8eb4234d6e3237a7.tar.gz
go-tangerine-c5cb214f689e5c34bf487daa8eb4234d6e3237a7.tar.zst
go-tangerine-c5cb214f689e5c34bf487daa8eb4234d6e3237a7.zip
swarm/storage/feed: Expose MaxUpdateDataLength constant (#17858)
Diffstat (limited to 'swarm')
-rw-r--r--swarm/storage/feed/update.go8
-rw-r--r--swarm/storage/feed/update_test.go2
2 files changed, 6 insertions, 4 deletions
diff --git a/swarm/storage/feed/update.go b/swarm/storage/feed/update.go
index 627a537d1..21c004ca4 100644
--- a/swarm/storage/feed/update.go
+++ b/swarm/storage/feed/update.go
@@ -42,7 +42,9 @@ type Update struct {
}
const minimumUpdateDataLength = idLength + headerLength + 1
-const maxUpdateDataLength = chunk.DefaultSize - signatureLength - idLength - headerLength
+
+//MaxUpdateDataLength indicates the maximum payload size for a feed update
+const MaxUpdateDataLength = chunk.DefaultSize - signatureLength - idLength - headerLength
// binaryPut serializes the feed update information into the given slice
func (r *Update) binaryPut(serializedData []byte) error {
@@ -51,8 +53,8 @@ func (r *Update) binaryPut(serializedData []byte) error {
return NewError(ErrInvalidValue, "a feed update must contain data")
}
- if datalength > maxUpdateDataLength {
- return NewErrorf(ErrInvalidValue, "feed update data is too big (length=%d). Max length=%d", datalength, maxUpdateDataLength)
+ if datalength > MaxUpdateDataLength {
+ return NewErrorf(ErrInvalidValue, "feed update data is too big (length=%d). Max length=%d", datalength, MaxUpdateDataLength)
}
if len(serializedData) != r.binaryLength() {
diff --git a/swarm/storage/feed/update_test.go b/swarm/storage/feed/update_test.go
index 4007223c6..24c09b361 100644
--- a/swarm/storage/feed/update_test.go
+++ b/swarm/storage/feed/update_test.go
@@ -35,7 +35,7 @@ func TestUpdateLengthCheck(t *testing.T) {
testBinarySerializerLengthCheck(t, getTestFeedUpdate())
// Test fail if update is too big
update := getTestFeedUpdate()
- update.data = make([]byte, maxUpdateDataLength+100)
+ update.data = make([]byte, MaxUpdateDataLength+100)
serialized := make([]byte, update.binaryLength())
if err := update.binaryPut(serialized); err == nil {
t.Fatal("Expected update.binaryPut to fail since update is too big")