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
b8e88c5b
Unverified
Commit
b8e88c5b
authored
4 years ago
by
Luca Moser
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
sign the faucet tx (#586)
parent
94a77f55
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
dapps/faucet/dapp.go
+2
-2
2 additions, 2 deletions
dapps/faucet/dapp.go
dapps/faucet/packages/faucet.go
+11
-5
11 additions, 5 deletions
dapps/faucet/packages/faucet.go
with
13 additions
and
7 deletions
dapps/faucet/dapp.go
+
2
−
2
View file @
b8e88c5b
...
...
@@ -91,12 +91,12 @@ func configure(*node.Plugin) {
fundingWorkerPool
=
workerpool
.
New
(
func
(
task
workerpool
.
Task
)
{
msg
:=
task
.
Param
(
0
)
.
(
*
message
.
Message
)
addr
:=
msg
.
Payload
()
.
(
*
faucetpayload
.
Payload
)
.
Address
()
_
,
txID
,
err
:=
Faucet
()
.
SendFunds
(
msg
)
msg
,
txID
,
err
:=
Faucet
()
.
SendFunds
(
msg
)
if
err
!=
nil
{
log
.
Errorf
(
"couldn't fulfill funding request to %s: %s"
,
addr
,
err
)
return
}
log
.
Infof
(
"sent funds to address %s via tx %s"
,
addr
,
txID
)
log
.
Infof
(
"sent funds to address %s via tx
%s and msg
%s"
,
addr
,
txID
,
msg
.
Id
()
.
String
()
)
},
workerpool
.
WorkerCount
(
fundingWorkerCount
),
workerpool
.
QueueSize
(
fundingWorkerQueueSize
))
configureEvents
()
...
...
This diff is collapsed.
Click to expand it.
dapps/faucet/packages/faucet.go
+
11
−
5
View file @
b8e88c5b
...
...
@@ -7,16 +7,16 @@ import (
"time"
faucetpayload
"github.com/iotaledger/goshimmer/dapps/faucet/packages/payload"
"github.com/iotaledger/goshimmer/packages/binary/messagelayer/message"
"github.com/iotaledger/hive.go/events"
"github.com/iotaledger/goshimmer/dapps/valuetransfers"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/address"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/address/signaturescheme"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/balance"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/tangle"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/transaction"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/wallet"
"github.com/iotaledger/goshimmer/packages/binary/messagelayer/message"
"github.com/iotaledger/goshimmer/plugins/issuer"
"github.com/iotaledger/hive.go/events"
)
var
(
...
...
@@ -55,7 +55,7 @@ func (f *Faucet) SendFunds(msg *message.Message) (m *message.Message, txID strin
addr
:=
msg
.
Payload
()
.
(
*
faucetpayload
.
Payload
)
.
Address
()
// get the output ids for the inputs and remainder balance
outputIds
,
remainder
:=
f
.
collectUTXOsForFunding
()
outputIds
,
addrsIndices
,
remainder
:=
f
.
collectUTXOsForFunding
()
tx
:=
transaction
.
New
(
// inputs
...
...
@@ -75,6 +75,10 @@ func (f *Faucet) SendFunds(msg *message.Message) (m *message.Message, txID strin
tx
.
Outputs
()
.
Add
(
remainAddr
,
[]
*
balance
.
Balance
{
balance
.
New
(
balance
.
ColorIOTA
,
remainder
)})
}
for
index
:=
range
addrsIndices
{
tx
.
Sign
(
signaturescheme
.
ED25519
(
*
f
.
wallet
.
Seed
()
.
KeyPair
(
index
)))
}
// prepare value payload with value factory
payload
:=
valuetransfers
.
ValueObjectFactory
()
.
IssueTransaction
(
tx
)
...
...
@@ -125,9 +129,10 @@ func (f *Faucet) awaitTransactionBooked(txID transaction.ID, maxAwait time.Durat
// collectUTXOsForFunding iterates over the faucet's UTXOs until the token threshold is reached.
// this function also returns the remainder balance for the given outputs.
func
(
f
*
Faucet
)
collectUTXOsForFunding
()
(
outputIds
[]
transaction
.
OutputID
,
remainder
int64
)
{
func
(
f
*
Faucet
)
collectUTXOsForFunding
()
(
outputIds
[]
transaction
.
OutputID
,
addrsIndices
map
[
uint64
]
struct
{},
remainder
int64
)
{
var
total
=
f
.
tokensPerRequest
var
i
uint64
addrsIndices
=
map
[
uint64
]
struct
{}{}
// get a list of address for inputs
for
i
=
0
;
total
>
0
;
i
++
{
...
...
@@ -141,6 +146,7 @@ func (f *Faucet) collectUTXOsForFunding() (outputIds []transaction.OutputID, rem
for
_
,
coloredBalance
:=
range
output
.
Balances
()
{
val
+=
coloredBalance
.
Value
}
addrsIndices
[
i
]
=
struct
{}{}
// get unspent output ids and check if it's conflict
if
val
<=
total
{
...
...
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