2023-03-11 14:49:07 +00:00
|
|
|
package index
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2023-03-11 16:21:16 +00:00
|
|
|
"errors"
|
2023-03-11 14:49:07 +00:00
|
|
|
|
|
|
|
"github.com/ipfs/go-cid"
|
2023-03-12 13:30:05 +00:00
|
|
|
|
|
|
|
"github.com/filecoin-project/go-state-types/abi"
|
2023-03-11 14:49:07 +00:00
|
|
|
)
|
|
|
|
|
2023-03-11 16:21:16 +00:00
|
|
|
var ErrNotFound = errors.New("message not found")
|
2023-03-11 20:09:31 +00:00
|
|
|
var ErrClosed = errors.New("index closed")
|
2023-03-11 16:21:16 +00:00
|
|
|
|
2023-03-11 14:49:07 +00:00
|
|
|
// MsgInfo is the Message metadata the index tracks.
|
|
|
|
type MsgInfo struct {
|
|
|
|
// the message this record refers to
|
|
|
|
Message cid.Cid
|
2023-03-16 15:33:12 +00:00
|
|
|
// the tipset where this message was included
|
2023-03-12 11:21:03 +00:00
|
|
|
TipSet cid.Cid
|
2023-03-16 15:33:12 +00:00
|
|
|
// the epoch where this message was included
|
2023-03-11 14:49:07 +00:00
|
|
|
Epoch abi.ChainEpoch
|
|
|
|
}
|
|
|
|
|
|
|
|
// MsgIndex is the interface to the message index
|
|
|
|
type MsgIndex interface {
|
|
|
|
// GetMsgInfo retrieves the message metadata through the index.
|
2023-03-13 10:14:30 +00:00
|
|
|
// The lookup is done using the onchain message Cid; that is the signed message Cid
|
|
|
|
// for SECP messages and unsigned message Cid for BLS messages.
|
2023-03-11 14:49:07 +00:00
|
|
|
GetMsgInfo(ctx context.Context, m cid.Cid) (MsgInfo, error)
|
|
|
|
// Close closes the index
|
|
|
|
Close() error
|
|
|
|
}
|
2023-03-12 13:25:07 +00:00
|
|
|
|
|
|
|
type dummyMsgIndex struct{}
|
|
|
|
|
2023-03-12 13:33:36 +00:00
|
|
|
func (dummyMsgIndex) GetMsgInfo(ctx context.Context, m cid.Cid) (MsgInfo, error) {
|
2023-03-12 13:25:07 +00:00
|
|
|
return MsgInfo{}, ErrNotFound
|
|
|
|
}
|
|
|
|
|
2023-03-12 13:33:36 +00:00
|
|
|
func (dummyMsgIndex) Close() error {
|
2023-03-12 13:25:07 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
var DummyMsgIndex MsgIndex = dummyMsgIndex{}
|