chain: allow setting the client's birthday after creation
This commit is contained in:
parent
f4ae41ce5f
commit
1ddb9f2c11
2 changed files with 14 additions and 4 deletions
|
@ -108,6 +108,10 @@ type BitcoindClient struct {
|
|||
wg sync.WaitGroup
|
||||
}
|
||||
|
||||
// A compile-time check to ensure that BitcoindClient satisfies the
|
||||
// chain.Interface interface.
|
||||
var _ Interface = (*BitcoindClient)(nil)
|
||||
|
||||
// BackEnd returns the name of the driver.
|
||||
func (c *BitcoindClient) BackEnd() string {
|
||||
return "bitcoind"
|
||||
|
@ -596,6 +600,14 @@ func (c *BitcoindClient) ntfnHandler() {
|
|||
}
|
||||
}
|
||||
|
||||
// SetBirthday sets the birthday of the bitcoind rescan client.
|
||||
//
|
||||
// NOTE: This should be done before the client has been started in order for it
|
||||
// to properly carry its duties.
|
||||
func (c *BitcoindClient) SetBirthday(t time.Time) {
|
||||
c.birthday = t
|
||||
}
|
||||
|
||||
// BlockStamp returns the latest block notified by the client, or an error
|
||||
// if the client has been shut down.
|
||||
func (c *BitcoindClient) BlockStamp() (*waddrmgr.BlockStamp, error) {
|
||||
|
|
|
@ -333,15 +333,13 @@ func (c *BitcoindConn) getCurrentNet() (wire.BitcoinNet, error) {
|
|||
|
||||
// NewBitcoindClient returns a bitcoind client using the current bitcoind
|
||||
// connection. This allows us to share the same connection using multiple
|
||||
// clients. The birthday signifies the earliest time for which we should begin
|
||||
// scanning the chain.
|
||||
func (c *BitcoindConn) NewBitcoindClient(birthday time.Time) *BitcoindClient {
|
||||
// clients.
|
||||
func (c *BitcoindConn) NewBitcoindClient() *BitcoindClient {
|
||||
return &BitcoindClient{
|
||||
quit: make(chan struct{}),
|
||||
|
||||
id: atomic.AddUint64(&c.rescanClientCounter, 1),
|
||||
|
||||
birthday: birthday,
|
||||
chainParams: c.chainParams,
|
||||
chainConn: c,
|
||||
|
||||
|
|
Loading…
Reference in a new issue