Introduced `lol.Tracer` for function entry/exit logging across various packages. This improves traceability and debugging of function executions while preserving existing behavior. Removed unused files `doc.go` and `nothing.go` to clean up the repository.
27 lines
623 B
Go
27 lines
623 B
Go
package addresstag
|
|
|
|
import (
|
|
"bytes"
|
|
"realy.lol/chk"
|
|
"realy.lol/hex"
|
|
"realy.lol/ints"
|
|
"realy.lol/lol"
|
|
)
|
|
|
|
// DecodeAddressTag unpacks the contents of an `a` tag.
|
|
func DecodeAddressTag(tagValue []byte) (k uint16, pkb []byte, d []byte) {
|
|
lol.Tracer("DecodeAddressTag", tagValue)
|
|
defer func() { lol.Tracer("end DecodeAddressTag", k, pkb, d) }()
|
|
split := bytes.Split(tagValue, []byte(":"))
|
|
if len(split) == 3 {
|
|
var err error
|
|
if pkb, _ = hex.DecAppend(pkb, split[1]); len(pkb) == 32 {
|
|
n := ints.New(0)
|
|
if _, err = n.Unmarshal(split[0]); !chk.E(err) {
|
|
return n.Uint16(), pkb, split[2]
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|