Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
24c131a6
Commit
24c131a6
authored
Jan 18, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
9c9b3124
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
14 deletions
+13
-14
go/neo/internal/xsha1/xsha1.go
go/neo/internal/xsha1/xsha1.go
+13
-14
No files found.
go/neo/internal/xsha1/xsha1.go
View file @
24c131a6
...
...
@@ -17,8 +17,12 @@
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// Package xsha1, similarly to crypto/sha1, provides SHA1 computation, but
// makes it a noop if requested so from environment.
// Package xsha1 provides NEO-flavoured SHA1 sum.
//
// It is the same as regular SHA1, but returns all-zeros for empty input.
//
// Besides, checksum computation can be switched to be a noop if requested so
// from environment.
package
xsha1
import
(
...
...
@@ -27,7 +31,9 @@ import (
"os"
)
// XXX for benchmarking: how much sha1 computation takes time from latency
// Skip controls and indicates whether NEOSum skips SHA1 computation.
//
// It is used for benchmarking to see how much sha1 computation takes time from latency.
var
Skip
bool
func
init
()
{
if
os
.
Getenv
(
"X_NEOGO_SHA1_SKIP"
)
==
"y"
{
...
...
@@ -36,23 +42,16 @@ func init() {
}
}
func
Sum
(
b
[]
byte
)
[
sha1
.
Size
]
byte
{
if
!
Skip
{
return
sha1
.
Sum
(
b
)
}
return
[
sha1
.
Size
]
byte
{}
// all 0
}
// NEOSum returns SHA1(b) computed by NEO rules.
//
// it is the same as regular SHA1, but returns all-zeros for empty b.
// https://lab.nexedi.com/nexedi/neoppod/blob/c1c26894/neo/client/app.py#L464-468
//
// XXX merge into Sum?
func
NEOSum
(
b
[]
byte
)
[
sha1
.
Size
]
byte
{
if
len
(
b
)
==
0
{
return
[
sha1
.
Size
]
byte
{}
// all 0
}
return
Sum
(
b
)
if
!
Skip
{
return
sha1
.
Sum
(
b
)
}
return
[
sha1
.
Size
]
byte
{}
// all 0
}
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