OSDN Git Service

delete useless code (#1960)
authorwyjDoraemon <46176410+wyjDoraemon@users.noreply.github.com>
Thu, 10 Jun 2021 07:52:52 +0000 (15:52 +0800)
committerGitHub <noreply@github.com>
Thu, 10 Jun 2021 07:52:52 +0000 (15:52 +0800)
Co-authored-by: Paladz <yzhu101@uottawa.ca>
blockchain/pseudohsm/keycache.go
blockchain/pseudohsm/pseudohsm.go
blockchain/pseudohsm/watch.go
config/genesis_test.go [deleted file]
crypto/ed25519/chainkd/chainkd.go

index 2068d2e..4806fbe 100644 (file)
@@ -198,14 +198,10 @@ func (kc *keyCache) scan() ([]XPub, error) {
        for _, fi := range files {
                path := filepath.Join(kc.keydir, fi.Name())
                if skipKeyFile(fi) {
-                       //log.Printf("ignoring file %v", path)
-                       //fmt.Printf("ignoring file %v", path)
                        continue
                }
                fd, err := os.Open(path)
                if err != nil {
-                       //log.Printf(err)
-                       fmt.Printf("err")
                        continue
                }
                buf.Reset(fd)
index 925edaf..9bc259e 100644 (file)
@@ -34,7 +34,6 @@ type HSM struct {
        cacheMu  sync.Mutex
        keyStore keyStore
        cache    *keyCache
-       //kdCache  map[chainkd.XPub]chainkd.XPrv
 }
 
 // XPub type for pubkey for anyone can see
@@ -50,7 +49,6 @@ func New(keypath string) (*HSM, error) {
        return &HSM{
                keyStore: &keyStorePassphrase{keydir, LightScryptN, LightScryptP},
                cache:    newKeyCache(keydir),
-               //kdCache:  make(map[chainkd.XPub]chainkd.XPrv),
        }, nil
 }
 
@@ -213,15 +211,11 @@ func (h *HSM) LoadChainKDKey(xpub chainkd.XPub, auth string) (xprv chainkd.XPrv,
        h.cacheMu.Lock()
        defer h.cacheMu.Unlock()
 
-       //if xprv, ok := h.kdCache[xpub]; ok {
-       //      return xprv, nil
-       //}
-
        _, xkey, err := h.loadDecryptedKey(xpub, auth)
        if err != nil {
                return xprv, ErrLoadKey
        }
-       //h.kdCache[xpb.XPub] = xkey.XPrv
+
        return xkey.XPrv, nil
 }
 
index 75f0999..8618f64 100644 (file)
@@ -2,22 +2,16 @@
 
 package pseudohsm
 
-//"fmt"
-//"github.com/rjeczalik/notify"
-//"time"
-
 type watcher struct {
        kc       *keyCache
        starting bool
        running  bool
-       //ev       chan notify.EventInfo
-       quit chan struct{}
+       quit     chan struct{}
 }
 
 func newWatcher(kc *keyCache) *watcher {
        return &watcher{
-               kc: kc,
-               //ev:   make(chan notify.EventInfo, 10),
+               kc:   kc,
                quit: make(chan struct{}),
        }
 }
@@ -44,52 +38,4 @@ func (w *watcher) loop() {
                w.starting = false
                w.kc.mu.Unlock()
        }()
-
-       /*
-               err := notify.Watch(w.kc.keydir, w.ev, notify.All)
-               if err != nil {
-                       fmt.Printf("can't watch %s: %v", w.kc.keydir, err)
-                       return
-               }
-               defer notify.Stop(w.ev)
-               fmt.Printf("now watching %s", w.kc.keydir)
-               defer fmt.Printf("no longer watching %s", w.kc.keydir)
-
-               w.kc.mu.Lock()
-               w.running = true
-               w.kc.mu.Unlock()
-
-               // Wait for file system events and reload.
-               // When an event occurs, the reload call is delayed a bit so that
-               // multiple events arriving quickly only cause a single reload.
-               var (
-                       debounce          = time.NewTimer(0)
-                       debounceDuration  = 500 * time.Millisecond
-                       inCycle, hadEvent bool
-               )
-               defer debounce.Stop()
-               for {
-                       select {
-                       case <-w.quit:
-                               return
-                       case <-w.ev:
-                               if !inCycle {
-                                       debounce.Reset(debounceDuration)
-                                       inCycle = true
-                               } else {
-                                       hadEvent = true
-                               }
-                       case <-debounce.C:
-                               w.kc.mu.Lock()
-                               w.kc.reload()
-                               w.kc.mu.Unlock()
-                               if hadEvent {
-                                       debounce.Reset(debounceDuration)
-                                       inCycle, hadEvent = true, false
-                               } else {
-                                       inCycle, hadEvent = false, false
-                               }
-                       }
-               }
-       */
 }
diff --git a/config/genesis_test.go b/config/genesis_test.go
deleted file mode 100644 (file)
index 3c30938..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-package config
-
-/*func TestGenerateGenesisBlock(t *testing.T) {
-       block := GenerateGenesisBlock()
-       nonce := block.Nonce
-       for {
-               hash := block.Hash()
-               if difficulty.CheckProofOfWork(&hash, consensus.InitialSeed, block.Bits) {
-                       break
-               }
-               block.Nonce++
-       }
-       if block.Nonce != nonce {
-               t.Errorf("correct nonce is %d, but get %d", block.Nonce, nonce)
-       }
-}*/
index a72895b..9fb6cdc 100644 (file)
@@ -87,15 +87,6 @@ func (xprv XPrv) nonhardenedChild(sel []byte) (res XPrv) {
 
        pruneIntermediateScalar(res[:32])
 
-       // Unrolled the following loop:
-       // var carry int
-       // carry = 0
-       // for i := 0; i < 32; i++ {
-       //         sum := int(xprv[i]) + int(res[i]) + carry
-       //         res[i] = byte(sum & 0xff)
-       //         carry = (sum >> 8)
-       // }
-
        sum := int(0)
 
        sum = int(xprv[0]) + int(res[0]) + (sum >> 8)