dc4bc/storage/types.go

33 lines
679 B
Go
Raw Normal View History

package storage
2020-08-14 05:34:15 -07:00
import (
"bytes"
"crypto/ed25519"
)
2020-08-13 08:27:28 -07:00
type Message struct {
2020-08-18 09:41:43 -07:00
ID string `json:"id"`
DkgRoundID string `json:"dkg_round_id"`
Offset uint64 `json:"offset"`
Event string `json:"event"`
Data []byte `json:"data"`
Signature []byte `json:"signature"`
SenderAddr string `json:"sender"`
2020-08-14 05:34:15 -07:00
}
func (m *Message) Bytes() []byte {
buf := bytes.NewBuffer(nil)
buf.Write(m.Data)
return buf.Bytes()
}
func (m *Message) Verify(pubKey ed25519.PublicKey) bool {
return ed25519.Verify(pubKey, m.Bytes(), m.Signature)
}
type Storage interface {
Send(message Message) (Message, error)
2020-07-30 03:29:47 -07:00
GetMessages(offset uint64) ([]Message, error)
Close() error
}