good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
76f215b0
Commit
76f215b0
authored
Mar 16, 2015
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
Getters shouldn't need to be pointer receiver
parent
0dd9ac37
No related branches found
No related tags found
Loading
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/types.go
+7
-8
7 additions, 8 deletions
common/types.go
with
7 additions
and
8 deletions
common/types.go
+
7
−
8
View file @
76f215b0
package
common
package
common
type
(
type
Hash
[
32
]
byte
Hash
[
32
]
byte
Address
[
20
]
byte
)
var
(
var
(
zeroHash
Hash
zeroHash
Hash
...
@@ -27,7 +24,7 @@ func StringToAddress(s string) Address { return BytesToAddress([]byte(s)) }
...
@@ -27,7 +24,7 @@ func StringToAddress(s string) Address { return BytesToAddress([]byte(s)) }
// Don't use the default 'String' method in case we want to overwrite
// Don't use the default 'String' method in case we want to overwrite
// Get the string representation of the underlying hash
// Get the string representation of the underlying hash
func
(
h
*
Hash
)
Str
()
string
{
func
(
h
Hash
)
Str
()
string
{
return
string
(
h
[
:
])
return
string
(
h
[
:
])
}
}
...
@@ -53,13 +50,15 @@ func (h *Hash) Set(other Hash) {
...
@@ -53,13 +50,15 @@ func (h *Hash) Set(other Hash) {
}
}
}
}
type
Address
[
20
]
byte
// Get the string representation of the underlying address
// Get the string representation of the underlying address
func
(
a
Address
)
Str
()
string
{
func
(
a
Address
)
Str
()
string
{
return
string
(
a
[
:
])
return
string
(
a
[
:
])
}
}
// Sets the address to the value of b. If b is larger than len(a) it will panic
// Sets the address to the value of b. If b is larger than len(a) it will panic
func
(
a
Address
)
SetBytes
(
b
[]
byte
)
{
func
(
a
*
Address
)
SetBytes
(
b
[]
byte
)
{
if
len
(
b
)
>
len
(
a
)
{
if
len
(
b
)
>
len
(
a
)
{
panic
(
"unable to set bytes. too big"
)
panic
(
"unable to set bytes. too big"
)
}
}
...
@@ -71,10 +70,10 @@ func (a Address) SetBytes(b []byte) {
...
@@ -71,10 +70,10 @@ func (a Address) SetBytes(b []byte) {
}
}
// Set string `s` to a. If s is larger than len(a) it will panic
// Set string `s` to a. If s is larger than len(a) it will panic
func
(
a
Address
)
SetString
(
s
string
)
{
a
.
SetBytes
([]
byte
(
s
))
}
func
(
a
*
Address
)
SetString
(
s
string
)
{
a
.
SetBytes
([]
byte
(
s
))
}
// Sets a to other
// Sets a to other
func
(
a
Address
)
Set
(
other
Address
)
{
func
(
a
*
Address
)
Set
(
other
Address
)
{
for
i
,
v
:=
range
other
{
for
i
,
v
:=
range
other
{
a
[
i
]
=
v
a
[
i
]
=
v
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment