github.com/stafiprotocol/go-substrate-rpc-client@v1.4.7/types/election_compute.go (about) 1 package types 2 3 import ( 4 "fmt" 5 6 "github.com/stafiprotocol/go-substrate-rpc-client/pkg/scale" 7 ) 8 9 type ElectionCompute byte 10 11 const ( 12 // Result was forcefully computed on chain at the end of the session. 13 OnChain ElectionCompute = 0 14 // Result was submitted and accepted to the chain via a signed transaction. 15 Signed ElectionCompute = 1 16 // Result was submitted and accepted to the chain via an unsigned transaction (by an authority). 17 Unsigned ElectionCompute = 2 18 ) 19 20 func (ec *ElectionCompute) Decode(decoder scale.Decoder) error { 21 b, err := decoder.ReadOneByte() 22 vb := ElectionCompute(b) 23 switch vb { 24 case OnChain, Signed, Unsigned: 25 *ec = vb 26 default: 27 return fmt.Errorf("unknown ElectionCompute enum: %v", vb) 28 } 29 return err 30 } 31 32 func (ec ElectionCompute) Encode(encoder scale.Encoder) error { 33 return encoder.PushByte(byte(ec)) 34 }