Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Goshimmer_without_tipselection
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
COLLET Ismael
Goshimmer_without_tipselection
Commits
6de58044
Commit
6de58044
authored
5 years ago
by
Hans Moog
Browse files
Options
Downloads
Patches
Plain Diff
Refactor: removed unused code
parent
46e2a62c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/binary/tangle/model/approvers_old/approvers.go
+0
-163
0 additions, 163 deletions
packages/binary/tangle/model/approvers_old/approvers.go
packages/binary/tangle/model/approvers_old/cached_approvers.go
+0
-21
0 additions, 21 deletions
...ges/binary/tangle/model/approvers_old/cached_approvers.go
with
0 additions
and
184 deletions
packages/binary/tangle/model/approvers_old/approvers.go
deleted
100644 → 0
+
0
−
163
View file @
46e2a62c
package
approvers_old
import
(
"encoding/binary"
"sync"
"github.com/iotaledger/goshimmer/packages/binary/tangle/model/transaction"
"github.com/iotaledger/goshimmer/packages/binary/types"
"github.com/iotaledger/hive.go/objectstorage"
)
type
Approvers
struct
{
objectstorage
.
StorableObjectFlags
transactionId
transaction
.
Id
approvers
map
[
transaction
.
Id
]
types
.
Empty
approversMutex
sync
.
RWMutex
}
func
New
(
transactionId
transaction
.
Id
)
*
Approvers
{
return
&
Approvers
{
transactionId
:
transactionId
,
approvers
:
make
(
map
[
transaction
.
Id
]
types
.
Empty
),
}
}
// Get's called when we restore the approvers from storage. The bytes and the content will be unmarshaled by an external
// caller (the objectStorage factory).
func
FromStorage
(
id
[]
byte
)
(
result
objectstorage
.
StorableObject
)
{
var
transactionId
transaction
.
Id
copy
(
transactionId
[
:
],
id
)
result
=
&
Approvers
{
transactionId
:
transactionId
,
}
return
}
func
(
approvers
*
Approvers
)
GetTransactionId
()
transaction
.
Id
{
return
approvers
.
transactionId
}
func
(
approvers
*
Approvers
)
Get
()
(
result
map
[
transaction
.
Id
]
types
.
Empty
)
{
approvers
.
approversMutex
.
RLock
()
result
=
make
(
map
[
transaction
.
Id
]
types
.
Empty
,
len
(
approvers
.
approvers
))
for
approverId
:=
range
approvers
.
approvers
{
result
[
approverId
]
=
types
.
Void
}
approvers
.
approversMutex
.
RUnlock
()
return
}
func
(
approvers
*
Approvers
)
Add
(
transactionId
transaction
.
Id
)
(
modified
bool
)
{
approvers
.
approversMutex
.
RLock
()
if
_
,
exists
:=
approvers
.
approvers
[
transactionId
];
!
exists
{
approvers
.
approversMutex
.
RUnlock
()
approvers
.
approversMutex
.
Lock
()
if
_
,
exists
:=
approvers
.
approvers
[
transactionId
];
!
exists
{
approvers
.
approvers
[
transactionId
]
=
types
.
Void
modified
=
true
approvers
.
SetModified
()
}
approvers
.
approversMutex
.
Unlock
()
}
else
{
approvers
.
approversMutex
.
RUnlock
()
}
return
}
func
(
approvers
*
Approvers
)
Remove
(
transactionId
transaction
.
Id
)
(
modified
bool
)
{
approvers
.
approversMutex
.
RLock
()
if
_
,
exists
:=
approvers
.
approvers
[
transactionId
];
exists
{
approvers
.
approversMutex
.
RUnlock
()
approvers
.
approversMutex
.
Lock
()
if
_
,
exists
:=
approvers
.
approvers
[
transactionId
];
exists
{
delete
(
approvers
.
approvers
,
transactionId
)
modified
=
true
approvers
.
SetModified
()
}
approvers
.
approversMutex
.
Unlock
()
}
else
{
approvers
.
approversMutex
.
RUnlock
()
}
return
}
func
(
approvers
*
Approvers
)
Size
()
(
result
int
)
{
approvers
.
approversMutex
.
RLock
()
result
=
len
(
approvers
.
approvers
)
approvers
.
approversMutex
.
RUnlock
()
return
}
func
(
approvers
*
Approvers
)
GetStorageKey
()
[]
byte
{
transactionId
:=
approvers
.
GetTransactionId
()
return
transactionId
[
:
]
}
func
(
approvers
*
Approvers
)
Update
(
other
objectstorage
.
StorableObject
)
{
panic
(
"approvers should never be overwritten and only stored once to optimize IO"
)
}
func
(
approvers
*
Approvers
)
MarshalBinary
()
(
result
[]
byte
,
err
error
)
{
approvers
.
approversMutex
.
RLock
()
approversCount
:=
len
(
approvers
.
approvers
)
result
=
make
([]
byte
,
4
+
approversCount
*
transaction
.
IdLength
)
offset
:=
0
binary
.
LittleEndian
.
PutUint32
(
result
[
offset
:
],
uint32
(
approversCount
))
offset
+=
4
for
approverId
:=
range
approvers
.
approvers
{
marshaledBytes
,
marshalErr
:=
approverId
.
MarshalBinary
()
if
marshalErr
!=
nil
{
err
=
marshalErr
approvers
.
approversMutex
.
RUnlock
()
return
}
copy
(
result
[
offset
:
],
marshaledBytes
)
offset
+=
len
(
marshaledBytes
)
}
approvers
.
approversMutex
.
RUnlock
()
return
}
func
(
approvers
*
Approvers
)
UnmarshalBinary
(
data
[]
byte
)
(
err
error
)
{
approvers
.
approvers
=
make
(
map
[
transaction
.
Id
]
types
.
Empty
)
offset
:=
0
approversCount
:=
int
(
binary
.
LittleEndian
.
Uint32
(
data
[
offset
:
]))
offset
+=
4
for
i
:=
0
;
i
<
approversCount
;
i
++
{
var
approverId
transaction
.
Id
if
err
=
approverId
.
UnmarshalBinary
(
data
[
offset
:
]);
err
!=
nil
{
return
}
offset
+=
transaction
.
IdLength
approvers
.
approvers
[
approverId
]
=
types
.
Void
}
return
}
This diff is collapsed.
Click to expand it.
packages/binary/tangle/model/approvers_old/cached_approvers.go
deleted
100644 → 0
+
0
−
21
View file @
46e2a62c
package
approvers_old
import
(
"github.com/iotaledger/hive.go/objectstorage"
)
type
CachedApprovers
struct
{
objectstorage
.
CachedObject
}
func
(
cachedObject
*
CachedApprovers
)
Unwrap
()
*
Approvers
{
if
untypedObject
:=
cachedObject
.
Get
();
untypedObject
==
nil
{
return
nil
}
else
{
if
typedObject
:=
untypedObject
.
(
*
Approvers
);
typedObject
==
nil
||
typedObject
.
IsDeleted
()
{
return
nil
}
else
{
return
typedObject
}
}
}
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