Documentation ¶
Index ¶
- Constants
- func BytesToHash(b []byte) types.Hash
- func FromHex(s string) []byte
- func Hex2Bytes(str string) []byte
- func HexToHash(s string) types.Hash
- func NewP2PTestEventCenter() types.EventCenter
- type P2PTestEventCenter
- func (e *P2PTestEventCenter) Notify(eventType types.EventType, value interface{}) (err error)
- func (e *P2PTestEventCenter) NotifyAll() (errs []error)
- func (e *P2PTestEventCenter) NotifySubscriber(eventFunc types.EventFunc, value interface{})
- func (e *P2PTestEventCenter) Subscribe(eventType types.EventType, eventFunc types.EventFunc) types.Subscriber
- func (e *P2PTestEventCenter) UnSubscribe(eventType types.EventType, subscriber types.Subscriber) (err error)
- func (e *P2PTestEventCenter) UnSubscribeAll()
Constants ¶
View Source
const (
HashLength = 32
)
Lengths of hashes and addresses in bytes.
Variables ¶
This section is empty.
Functions ¶
func BytesToHash ¶
BytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.
func FromHex ¶
FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".
func HexToHash ¶
HexToHash sets byte representation of s to hash. If b is larger than len(h), b will be cropped from the left.
func NewP2PTestEventCenter ¶
func NewP2PTestEventCenter() types.EventCenter
Types ¶
type P2PTestEventCenter ¶
type P2PTestEventCenter struct { Subscribers map[types.EventType]map[types.Subscriber]types.EventFunc // contains filtered or unexported fields }
func (*P2PTestEventCenter) Notify ¶
func (e *P2PTestEventCenter) Notify(eventType types.EventType, value interface{}) (err error)
Notify subscribers that Subscribe specified event
func (*P2PTestEventCenter) NotifyAll ¶
func (e *P2PTestEventCenter) NotifyAll() (errs []error)
Notify all event subscribers
func (*P2PTestEventCenter) NotifySubscriber ¶
func (e *P2PTestEventCenter) NotifySubscriber(eventFunc types.EventFunc, value interface{})
func (*P2PTestEventCenter) Subscribe ¶
func (e *P2PTestEventCenter) Subscribe(eventType types.EventType, eventFunc types.EventFunc) types.Subscriber
adds a new subscriber to P2PTestEventCenter.
func (*P2PTestEventCenter) UnSubscribe ¶
func (e *P2PTestEventCenter) UnSubscribe(eventType types.EventType, subscriber types.Subscriber) (err error)
UnSubscribe removes the specified subscriber
func (*P2PTestEventCenter) UnSubscribeAll ¶
func (e *P2PTestEventCenter) UnSubscribeAll()
unsubscribe all event and subscriber elegant
Click to show internal directories.
Click to hide internal directories.