mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-10-14 00:59:33 +00:00
[NOD-356] Add indication in getBlock that a block is an orphan. (#437)
This commit is contained in:
parent
7c9f5a65d8
commit
8ea97aa3fd
@ -65,6 +65,7 @@ const (
|
|||||||
ErrRPCSubnetworkNotFound RPCErrorCode = -5
|
ErrRPCSubnetworkNotFound RPCErrorCode = -5
|
||||||
ErrRPCRawTxString RPCErrorCode = -32602
|
ErrRPCRawTxString RPCErrorCode = -32602
|
||||||
ErrRPCDecodeHexString RPCErrorCode = -22
|
ErrRPCDecodeHexString RPCErrorCode = -22
|
||||||
|
ErrRPCOrphanBlock RPCErrorCode = -6
|
||||||
)
|
)
|
||||||
|
|
||||||
// Errors that are specific to btcd.
|
// Errors that are specific to btcd.
|
||||||
|
@ -22,6 +22,15 @@ func handleGetBlock(s *Server, cmd interface{}, closeChan <-chan struct{}) (inte
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, rpcDecodeHexError(c.Hash)
|
return nil, rpcDecodeHexError(c.Hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return an appropriate error if the block is an orphan
|
||||||
|
if s.cfg.DAG.IsKnownOrphan(hash) {
|
||||||
|
return nil, &btcjson.RPCError{
|
||||||
|
Code: btcjson.ErrRPCOrphanBlock,
|
||||||
|
Message: "Block is an orphan",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var blkBytes []byte
|
var blkBytes []byte
|
||||||
err = s.cfg.DB.View(func(dbTx database.Tx) error {
|
err = s.cfg.DB.View(func(dbTx database.Tx) error {
|
||||||
var err error
|
var err error
|
||||||
|
Loading…
x
Reference in New Issue
Block a user