Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
c5cb214f
Commit
c5cb214f
authored
Oct 08, 2018
by
Javier Peletier
Committed by
Anton Evangelatov
Oct 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
swarm/storage/feed: Expose MaxUpdateDataLength constant (#17858)
parent
f95811e6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
4 deletions
+6
-4
update.go
swarm/storage/feed/update.go
+5
-3
update_test.go
swarm/storage/feed/update_test.go
+1
-1
No files found.
swarm/storage/feed/update.go
View file @
c5cb214f
...
...
@@ -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
>
m
axUpdateDataLength
{
return
NewErrorf
(
ErrInvalidValue
,
"feed update data is too big (length=%d). Max length=%d"
,
datalength
,
m
axUpdateDataLength
)
if
datalength
>
M
axUpdateDataLength
{
return
NewErrorf
(
ErrInvalidValue
,
"feed update data is too big (length=%d). Max length=%d"
,
datalength
,
M
axUpdateDataLength
)
}
if
len
(
serializedData
)
!=
r
.
binaryLength
()
{
...
...
swarm/storage/feed/update_test.go
View file @
c5cb214f
...
...
@@ -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
,
m
axUpdateDataLength
+
100
)
update
.
data
=
make
([]
byte
,
M
axUpdateDataLength
+
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"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment