mirror of
https://github.com/btcsuite/btcd.git
synced 2024-11-19 09:50:08 +01:00
add InvalidateBlock RPC command
This commit is contained in:
parent
45b9cb481d
commit
c72658166a
@ -10,3 +10,4 @@ Dave Collins <davec@conformal.com>
|
||||
Geert-Johan Riemer <geertjohan.riemer@gmail.com>
|
||||
Josh Rickmar <jrick@conformal.com>
|
||||
Michalis Kargakis <michaliskargakis@gmail.com>
|
||||
Ruben de Vries <ruben@rubensayshi.com
|
||||
|
32
chain.go
32
chain.go
@ -749,3 +749,35 @@ func (c *Client) RescanBlocksAsync(blockHashes []chainhash.Hash) FutureRescanBlo
|
||||
func (c *Client) RescanBlocks(blockHashes []chainhash.Hash) ([]btcjson.RescannedBlock, error) {
|
||||
return c.RescanBlocksAsync(blockHashes).Receive()
|
||||
}
|
||||
|
||||
// FutureInvalidateBlockResult is a future promise to deliver the result of a
|
||||
// InvalidateBlockAsync RPC invocation (or an applicable error).
|
||||
type FutureInvalidateBlockResult chan *response
|
||||
|
||||
// Receive waits for the response promised by the future and returns the raw
|
||||
// block requested from the server given its hash.
|
||||
func (r FutureInvalidateBlockResult) Receive() error {
|
||||
_, err := receiveFuture(r)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// InvalidateBlockAsync returns an instance of a type that can be used to get the
|
||||
// result of the RPC at some future time by invoking the Receive function on the
|
||||
// returned instance.
|
||||
//
|
||||
// See InvalidateBlock for the blocking version and more details.
|
||||
func (c *Client) InvalidateBlockAsync(blockHash *chainhash.Hash) FutureInvalidateBlockResult {
|
||||
hash := ""
|
||||
if blockHash != nil {
|
||||
hash = blockHash.String()
|
||||
}
|
||||
|
||||
cmd := btcjson.NewInvalidateBlockCmd(hash)
|
||||
return c.sendCmd(cmd)
|
||||
}
|
||||
|
||||
// InvalidateBlock invalidates a specific block.
|
||||
func (c *Client) InvalidateBlock(blockHash *chainhash.Hash) error {
|
||||
return c.InvalidateBlockAsync(blockHash).Receive()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user