Documentation
¶
Index ¶
- func Attribute(key, value string) processor.Attribute
- func MakeWallet(pubkey string) (string, *processor.InvalidTransactionError)
- func Must(endpoint string, handler *Handler)
- func NewTPRequestBytes(cmd int32, data proto.Message) ([]byte, error)
- func Run(endpoint string, handler *Handler) error
- func TxErrore(err error) *processor.InvalidTransactionError
- func TxErrorf(format string, a ...interface{}) *processor.InvalidTransactionError
- func TxErrorp(msg string, m proto.Message) *processor.InvalidTransactionError
- func UnmarshalTPRequest(data []byte, pb proto.Message) (int32, error)
- type Context
- func (ctx *Context) AddEvent(typ string, data []byte, attributes ...processor.Attribute) *processor.InvalidTransactionError
- func (ctx *Context) AddEventMessage(typ string, data proto.Message, attributes ...processor.Attribute) *processor.InvalidTransactionError
- func (ctx *Context) AddReceiptData(data proto.Message) *processor.InvalidTransactionError
- func (ctx *Context) Cmd() int32
- func (ctx *Context) Context() *processor.Context
- func (ctx *Context) Del(addrs []string) ([]string, error)
- func (ctx *Context) Get(address string, data proto.Message) (bool, *processor.InvalidTransactionError)
- func (ctx *Context) GetAll(data map[string]proto.Message) *processor.InvalidTransactionError
- func (ctx *Context) Set(address string, data proto.Message) *processor.InvalidTransactionError
- func (ctx *Context) SetAll(data map[string]proto.Message) *processor.InvalidTransactionError
- func (ctx *Context) Setting(address string) (string, *processor.InvalidTransactionError)
- func (ctx *Context) SignerPublicKey() string
- func (ctx *Context) String() string
- type ErrCode
- type Family
- type Handler
- type HandlerFunc
- type RequestValidator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeWallet ¶
func MakeWallet(pubkey string) (string, *processor.InvalidTransactionError)
MakeWallet return a wallet address from public key
func NewTPRequestBytes ¶
NewTPRequestBytes returns bytes encoding from request.
func TxErrore ¶
func TxErrore(err error) *processor.InvalidTransactionError
TxErrore returns a InvaildTransactionError with an error.
func TxErrorf ¶
func TxErrorf(format string, a ...interface{}) *processor.InvalidTransactionError
TxErrorf returns a InvaildTransactionError with a formatted string.
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context wraps sawtooth processor context.
func (*Context) AddEvent ¶
func (ctx *Context) AddEvent(typ string, data []byte, attributes ...processor.Attribute) *processor.InvalidTransactionError
AddEvent adds event to chain.
func (*Context) AddEventMessage ¶
func (ctx *Context) AddEventMessage(typ string, data proto.Message, attributes ...processor.Attribute) *processor.InvalidTransactionError
AddEventMessage adds event to chain.
func (*Context) AddReceiptData ¶
func (ctx *Context) AddReceiptData(data proto.Message) *processor.InvalidTransactionError
AddReceiptData adds receipt data.
func (*Context) Get ¶
func (ctx *Context) Get(address string, data proto.Message) (bool, *processor.InvalidTransactionError)
Get returns a state with address.
func (*Context) Setting ¶
func (ctx *Context) Setting(address string) (string, *processor.InvalidTransactionError)
Setting returns value in setting-tp.
func (*Context) SignerPublicKey ¶
SignerPublicKey returns transaction signer public key.
type ErrCode ¶
type ErrCode uint32
ErrCode ...
const ( Internal ErrCode = 999987 // internal error. Wallet ErrCode = 999988 // generating wallet failure. BadParameters ErrCode = 999989 // any fields in request is invalid. LenNotMatch ErrCode = 999990 // data length not match. Conflict ErrCode = 999991 // address conflict. NotFound ErrCode = 999992 // state not found. GetState ErrCode = 999993 // getting state error. SetState ErrCode = 999994 // setting state error. Events ErrCode = 999995 // add event error. ReceiptData ErrCode = 999996 // add event error. Unmarshal ErrCode = 999997 // data (protobuf) unmarshal failure. Marshal ErrCode = 999998 // data (protobuf) marshal failure. UnknownCmd ErrCode = 999999 // unknown command. )
Errors of tp.
type Family ¶
type Family struct {
// contains filtered or unexported fields
}
Family is for TransactionProcessor.
func (*Family) FamilyName ¶
FamilyName returns family name defined in processor.TransactionHandler.
func (*Family) FamilyVersions ¶
FamilyVersions returns family support versions defined in processor.TransactionHandler.
func (*Family) Namespaces ¶
Namespaces returns namespaces of family defined in processor.TransactionHandler.
type Handler ¶
type Handler struct {
*Family
// contains filtered or unexported fields
}
Handler is a handler for Sawtooth Transaction Processor.
func (*Handler) Add ¶
func (h *Handler) Add(cmd int32, hf HandlerFunc)
Add an handler function for some command.
func (*Handler) Apply ¶
func (h *Handler) Apply(req *processor_pb2.TpProcessRequest, ctx *processor.Context) error
Apply implements Apply function of processor.TransactionHandler. Decode payload in req (*processor_pb2.TpProcessRequest), and change to user's payload.
type HandlerFunc ¶
type HandlerFunc func(ctx *Context, req *TPRequest) *processor.InvalidTransactionError
HandlerFunc SawTK TP handler function.
func MakeHandlerFunc ¶
func MakeHandlerFunc(f interface{}) HandlerFunc
MakeHandlerFunc returns a HandlerFunc. It will unmarshal payload to specific datatype defined in f automatically.
type RequestValidator ¶
type RequestValidator interface {
proto.Message
Validate() *processor.InvalidTransactionError
}
RequestValidator is for MakeHandlerFunc to check req is ok or not.