package bucash

var (
	ErrMsg map[int]string
)

const (
	OK       = 0
	TIME_OUT = iota + 40
	TRANSINFO_ERR
	INNER_ERR
	ADDRESS_ERR
	PARM_ERR
	BLOCKID_ERR
	BLOCKHEIGHT_ERR
	UNKNOWN_ERR
	KNOWN_ERR
)

func initErr() {
	ErrMsg = make(map[int]string)
	ErrMsg[OK] = "成功"
	ErrMsg[TRANSINFO_ERR] = "query trans by txid err"
	ErrMsg[INNER_ERR] = "inner error"
	ErrMsg[ADDRESS_ERR] = "query trans by address err"
	ErrMsg[PARM_ERR] = "parments error"
	ErrMsg[BLOCKID_ERR] = "query trans by blockid err"
	ErrMsg[BLOCKHEIGHT_ERR] = "query block height  err"
	ErrMsg[UNKNOWN_ERR] = ""

}

func setErrMsg(ret int, data string) {
	ErrMsg[ret] = data
}
func getErrMsg(ret int, data []byte) string {
	msg, ok := ErrMsg[ret]
	if ok {
		return msg
	}
	return string(data)
}
