revocation: split up methods to get current pre-image and hash

This commit is contained in:
Olaoluwa Osuntokun 2015-12-20 21:46:41 -06:00
parent 34e35fe2d5
commit 422f0a9791

@ -9,6 +9,7 @@ import (
"sync" "sync"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/fastsha256"
) )
const ( const (
@ -135,11 +136,19 @@ func (h *HyperShaChain) AddNextHash(hash [32]byte) error {
return nil return nil
} }
// CurrentHash... // CurrentPreImage...
func (h *HyperShaChain) CurrentHash() (*wire.ShaHash, error) { func (h *HyperShaChain) CurrentPreImage() *wire.ShaHash {
h.Lock() h.RLock()
defer h.Unlock() defer h.RUnlock()
return &h.lastHash, nil return &h.lastHash
}
// CurrentRevocationHash...
// TODO(roasbeef): *wire.ShaHash vs [wire.HashSize]byte ?
func (h *HyperShaChain) CurrentRevocationHash() [wire.HashSize]byte {
h.RLock()
defer h.RUnlock()
return fastsha256.Sum256(h.lastHash[:])
} }
// LocatePreImage... // LocatePreImage...