-
Notifications
You must be signed in to change notification settings - Fork 178
/
execution_state.go
45 lines (38 loc) · 1.32 KB
/
execution_state.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package run
import (
"github.com/onflow/cadence"
"github.com/rs/zerolog"
"github.com/onflow/flow-go/crypto"
"github.com/onflow/flow-go/crypto/hash"
"github.com/onflow/flow-go/engine/execution/state/bootstrap"
ledger "github.com/onflow/flow-go/ledger/complete"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/module/metrics"
)
// NOTE: this is now unused and should become part of another tool.
func GenerateServiceAccountPrivateKey(seed []byte) (flow.AccountPrivateKey, error) {
priv, err := crypto.GeneratePrivateKey(crypto.ECDSASecp256k1, seed)
if err != nil {
return flow.AccountPrivateKey{}, err
}
return flow.AccountPrivateKey{
PrivateKey: priv,
SignAlgo: crypto.ECDSASecp256k1,
HashAlgo: hash.SHA2_256,
}, nil
}
// NOTE: this is now unused and should become part of another tool.
func GenerateExecutionState(
dbDir string,
accountKey flow.AccountPublicKey,
tokenSupply cadence.UFix64,
chain flow.Chain,
) (flow.StateCommitment, error) {
metricsCollector := &metrics.NoopCollector{}
ledgerStorage, err := ledger.NewLedger(dbDir, 100, metricsCollector, zerolog.Nop(), nil, ledger.DefaultPathFinderVersion)
if err != nil {
return nil, err
}
defer ledgerStorage.CloseStorage()
return bootstrap.NewBootstrapper(zerolog.Nop()).BootstrapLedger(ledgerStorage, accountKey, tokenSupply, chain)
}