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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
github
maticnetwork
bor
Commits
30cc1c3b
Commit
30cc1c3b
authored
7 years ago
by
Nicolas Guillaume
Browse files
Options
Downloads
Patches
Plain Diff
mobile: Add management methods to {Addresses,Topics,Hashes} structures
parent
da636c53
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mobile/common.go
+43
-0
43 additions, 0 deletions
mobile/common.go
mobile/ethereum.go
+17
-0
17 additions, 0 deletions
mobile/ethereum.go
with
60 additions
and
0 deletions
mobile/common.go
+
43
−
0
View file @
30cc1c3b
...
...
@@ -89,6 +89,18 @@ func (h *Hash) GetHex() string {
// Hashes represents a slice of hashes.
type
Hashes
struct
{
hashes
[]
common
.
Hash
}
// NewHashes creates a slice of uninitialized Hashes.
func
NewHashes
(
size
int
)
*
Hashes
{
return
&
Hashes
{
hashes
:
make
([]
common
.
Hash
,
size
),
}
}
// NewHashesEmpty creates an empty slice of Hashes values.
func
NewHashesEmpty
()
*
Hashes
{
return
NewHashes
(
0
)
}
// Size returns the number of hashes in the slice.
func
(
h
*
Hashes
)
Size
()
int
{
return
len
(
h
.
hashes
)
...
...
@@ -102,6 +114,20 @@ func (h *Hashes) Get(index int) (hash *Hash, _ error) {
return
&
Hash
{
h
.
hashes
[
index
]},
nil
}
// Set sets the Hash at the given index in the slice.
func
(
h
*
Hashes
)
Set
(
index
int
,
hash
*
Hash
)
error
{
if
index
<
0
||
index
>=
len
(
h
.
hashes
)
{
return
errors
.
New
(
"index out of bounds"
)
}
h
.
hashes
[
index
]
=
hash
.
hash
return
nil
}
// Append adds a new Hash element to the end of the slice.
func
(
h
*
Hashes
)
Append
(
hash
*
Hash
)
{
h
.
hashes
=
append
(
h
.
hashes
,
hash
.
hash
)
}
// Address represents the 20 byte address of an Ethereum account.
type
Address
struct
{
address
common
.
Address
...
...
@@ -164,6 +190,18 @@ func (a *Address) GetHex() string {
// Addresses represents a slice of addresses.
type
Addresses
struct
{
addresses
[]
common
.
Address
}
// NewAddresses creates a slice of uninitialized addresses.
func
NewAddresses
(
size
int
)
*
Addresses
{
return
&
Addresses
{
addresses
:
make
([]
common
.
Address
,
size
),
}
}
// NewAddressesEmpty creates an empty slice of Addresses values.
func
NewAddressesEmpty
()
*
Addresses
{
return
NewAddresses
(
0
)
}
// Size returns the number of addresses in the slice.
func
(
a
*
Addresses
)
Size
()
int
{
return
len
(
a
.
addresses
)
...
...
@@ -185,3 +223,8 @@ func (a *Addresses) Set(index int, address *Address) error {
a
.
addresses
[
index
]
=
address
.
address
return
nil
}
// Append adds a new address element to the end of the slice.
func
(
a
*
Addresses
)
Append
(
address
*
Address
)
{
a
.
addresses
=
append
(
a
.
addresses
,
address
.
address
)
}
This diff is collapsed.
Click to expand it.
mobile/ethereum.go
+
17
−
0
View file @
30cc1c3b
...
...
@@ -87,6 +87,18 @@ func (p *SyncProgress) GetKnownStates() int64 { return int64(p.progress.KnownS
// Topics is a set of topic lists to filter events with.
type
Topics
struct
{
topics
[][]
common
.
Hash
}
// NewTopics creates a slice of uninitialized Topics.
func
NewTopics
(
size
int
)
*
Topics
{
return
&
Topics
{
topics
:
make
([][]
common
.
Hash
,
size
),
}
}
// NewTopicsEmpty creates an empty slice of Topics values.
func
NewTopicsEmpty
()
*
Topics
{
return
NewTopics
(
0
)
}
// Size returns the number of topic lists inside the set
func
(
t
*
Topics
)
Size
()
int
{
return
len
(
t
.
topics
)
...
...
@@ -109,6 +121,11 @@ func (t *Topics) Set(index int, topics *Hashes) error {
return
nil
}
// Append adds a new topic list to the end of the slice.
func
(
t
*
Topics
)
Append
(
topics
*
Hashes
)
{
t
.
topics
=
append
(
t
.
topics
,
topics
.
hashes
)
}
// FilterQuery contains options for contact log filtering.
type
FilterQuery
struct
{
query
ethereum
.
FilterQuery
...
...
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