Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions emulator/emulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func GenerateDefaultServiceKey(

return ServiceKey{
PrivateKey: privateKey,
PublicKey: privateKey.PublicKey(),
SigAlgo: sigAlgo,
HashAlgo: hashAlgo,
}
Expand All @@ -75,19 +76,9 @@ func (s ServiceKey) Signer() (sdkcrypto.Signer, error) {
}

func (s ServiceKey) AccountKey() *flowsdk.AccountKey {

var publicKey sdkcrypto.PublicKey
if s.PublicKey != nil {
publicKey = s.PublicKey
}

if s.PrivateKey != nil {
publicKey = s.PrivateKey.PublicKey()
}

return &flowsdk.AccountKey{
Index: s.Index,
PublicKey: publicKey,
PublicKey: s.PublicKey,
SigAlgo: s.SigAlgo,
HashAlgo: s.HashAlgo,
Weight: s.Weight,
Expand Down
18 changes: 16 additions & 2 deletions server/debugger/debugger.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ type Debugger struct {
logger *zerolog.Logger
emulator emulator.Emulator
port int
mu sync.Mutex // protects listener and stopped
listener net.Listener
stopped bool
quit chan interface{}
wg sync.WaitGroup
stopOnce sync.Once
Expand All @@ -58,7 +60,15 @@ func (d *Debugger) Start() (err error) {
if err != nil {
return err
}
d.mu.Lock()
d.listener = listener
alreadyStopped := d.stopped
d.mu.Unlock()

if alreadyStopped {
return listener.Close()
}

defer func() {
err = listener.Close()
}()
Expand Down Expand Up @@ -127,8 +137,12 @@ func (d *Debugger) handleConnection(conn net.Conn) {
func (d *Debugger) Stop() {
d.stopOnce.Do(func() {
close(d.quit)
if d.listener != nil {
_ = d.listener.Close()
d.mu.Lock()
l := d.listener
d.stopped = true
d.mu.Unlock()
if l != nil {
_ = l.Close()
}
for _, conn := range d.connections {
_ = conn.Close()
Expand Down
Loading