lotus/chain/index/interface.go
2023-03-12 15:25:07 +02:00

45 lines
1.0 KiB
Go

package index
import (
"context"
"errors"
"github.com/filecoin-project/go-state-types/abi"
"github.com/ipfs/go-cid"
)
var ErrNotFound = errors.New("message not found")
var ErrClosed = errors.New("index closed")
// MsgInfo is the Message metadata the index tracks.
type MsgInfo struct {
// the message this record refers to
Message cid.Cid
// the tipset where this messages was executed
TipSet cid.Cid
// the epoch whre this message was executed
Epoch abi.ChainEpoch
// the canonical execution order of the message in the tipset
Index int
}
// MsgIndex is the interface to the message index
type MsgIndex interface {
// GetMsgInfo retrieves the message metadata through the index.
GetMsgInfo(ctx context.Context, m cid.Cid) (MsgInfo, error)
// Close closes the index
Close() error
}
type dummyMsgIndex struct{}
func (_ dummyMsgIndex) GetMsgInfo(ctx context.Context, m cid.Cid) (MsgInfo, error) {
return MsgInfo{}, ErrNotFound
}
func (_ dummyMsgIndex) Close() error {
return nil
}
var DummyMsgIndex MsgIndex = dummyMsgIndex{}