core: reserve attributes range for experimantal purposes

This commit is contained in:
Anna Shaleva 2020-10-15 13:06:22 +03:00
parent 368ff820b3
commit 09b8b8de73
7 changed files with 107 additions and 7 deletions

View file

@ -30,28 +30,36 @@ type attrJSON struct {
func (attr *Attribute) DecodeBinary(br *io.BinReader) {
attr.Type = AttrType(br.ReadB())
switch attr.Type {
switch t := attr.Type; t {
case HighPriority:
return
case OracleResponseT:
attr.Value = new(OracleResponse)
attr.Value.DecodeBinary(br)
case NotValidBeforeT:
attr.Value = new(NotValidBefore)
attr.Value.DecodeBinary(br)
default:
if t >= ReservedLowerBound && t <= ReservedUpperBound {
attr.Value = new(Reserved)
break
}
br.Err = fmt.Errorf("failed decoding TX attribute usage: 0x%2x", int(attr.Type))
return
}
attr.Value.DecodeBinary(br)
}
// EncodeBinary implements Serializable interface.
func (attr *Attribute) EncodeBinary(bw *io.BinWriter) {
bw.WriteB(byte(attr.Type))
switch attr.Type {
switch t := attr.Type; t {
case HighPriority:
case OracleResponseT, NotValidBeforeT:
attr.Value.EncodeBinary(bw)
default:
if t >= ReservedLowerBound && t <= ReservedUpperBound {
attr.Value.EncodeBinary(bw)
break
}
bw.Err = fmt.Errorf("failed encoding TX attribute usage: 0x%2x", attr.Type)
}
}