Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
goshimmer
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
iota-imt
goshimmer
Commits
b0bfea5e
Commit
b0bfea5e
authored
5 years ago
by
capossele
Browse files
Options
Downloads
Patches
Plain Diff
WIP
parent
4ed4f35e
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
plugins/tangle/misc.go
+11
-0
11 additions, 0 deletions
plugins/tangle/misc.go
plugins/tangle/tx_per_address.go
+62
-0
62 additions, 0 deletions
plugins/tangle/tx_per_address.go
with
73 additions
and
0 deletions
plugins/tangle/misc.go
0 → 100644
+
11
−
0
View file @
b0bfea5e
package
tangle
import
"github.com/iotaledger/iota.go/trinary"
func
databaseKeyForHashPrefixedHash
(
address
trinary
.
Hash
,
transactionHash
trinary
.
Hash
)
[]
byte
{
return
append
(
databaseKeyForHashPrefix
(
address
),
trinary
.
MustTrytesToBytes
(
transactionHash
)
...
)
}
func
databaseKeyForHashPrefix
(
hash
trinary
.
Hash
)
[]
byte
{
return
trinary
.
MustTrytesToBytes
(
hash
)
}
This diff is collapsed.
Click to expand it.
plugins/tangle/tx_per_address.go
0 → 100644
+
62
−
0
View file @
b0bfea5e
package
tangle
import
(
"github.com/iotaledger/goshimmer/packages/database"
"github.com/iotaledger/iota.go/trinary"
)
var
(
transactionsHashesForAddressDatabase
database
.
Database
)
func
configureTransactionHashesForAddressDatabase
()
{
if
db
,
err
:=
database
.
Get
(
"transactionsHashesForAddress"
);
err
!=
nil
{
panic
(
err
)
}
else
{
transactionsHashesForAddressDatabase
=
db
}
}
type
TxHashForAddress
struct
{
Address
trinary
.
Hash
TxHash
trinary
.
Hash
}
func
StoreTransactionHashForAddressInDatabase
(
address
*
TxHashForAddress
)
error
{
if
err
:=
transactionsHashesForAddressDatabase
.
Set
(
databaseKeyForHashPrefixedHash
(
address
.
Address
,
address
.
TxHash
),
[]
byte
{},
);
err
!=
nil
{
return
ErrDatabaseError
.
Derive
(
err
,
"failed to store tx for address in database"
)
}
log
.
Info
(
"Stored Address:"
,
address
.
Address
)
log
.
Info
(
"TxHash:"
,
address
.
TxHash
)
log
.
Info
(
"txForAddr: "
,
trinary
.
MustBytesToTrytes
(
databaseKeyForHashPrefixedHash
(
address
.
Address
,
address
.
TxHash
),
81
))
return
nil
}
func
DeleteTransactionHashForAddressInDatabase
(
address
*
TxHashForAddress
)
error
{
if
err
:=
transactionsHashesForAddressDatabase
.
Delete
(
databaseKeyForHashPrefixedHash
(
address
.
Address
,
address
.
TxHash
),
);
err
!=
nil
{
return
ErrDatabaseError
.
Derive
(
err
,
"failed to delete tx for address"
)
}
return
nil
}
func
ReadTransactionHashesForAddressFromDatabase
(
address
trinary
.
Hash
)
([]
trinary
.
Hash
,
error
)
{
var
transactionHashes
[]
trinary
.
Hash
err
:=
transactionsHashesForAddressDatabase
.
ForEachWithPrefix
(
databaseKeyForHashPrefix
(
address
),
func
(
key
[]
byte
,
value
[]
byte
)
{
log
.
Info
(
"Len key:"
,
len
(
key
))
txHash
:=
trinary
.
MustBytesToTrytes
(
key
)[
81
:
]
log
.
Info
(
"Len ALL:"
,
len
(
txHash
))
transactionHashes
=
append
(
transactionHashes
,
txHash
)
})
if
err
!=
nil
{
return
nil
,
ErrDatabaseError
.
Derive
(
err
,
"failed to read tx per address from database"
)
}
else
{
return
transactionHashes
,
nil
}
}
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