accounthist

package
v0.9.0-beta9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

README

Account history service

This service keeps a partial, windowed history for each EOSIO account, truncating after a given number of actions.

It is different from dfuse Search, in that it doesn't truncate based on time, but on amount of actions.

As it keeps, say, 1000 actions per account, it can keep very old ones when there aren't many actions by/for a given account, and it will truncate aggressively on those accounts that spew mucho actions to the chain.

It brings a nice balance of value per byte kept.

Usage

grpcurl -plaintext -d '{"account": "eosio"}' localhost:13033 dfuse.eosio.accounthist.v1.AccountHistory.GetActions

Keyspace

Tables
max window = 3

block: 1

put: [02][eosio][^00000001] -> glob_seq,action_data
#put: [01][eosio] -> seq=1,prev=0,prevBlock=0

put: [03] -> block 1

block: 4

02:00000ef3438a:ff:ffffffffff600 -> 1000
02:00000ef3438a:ff:ffffffffffff7
02:00000ef3438a:ff:ffffffffffff6
02:00000ef3438a:fc:fffffffffffff
02:00000ef3438a:fc:ffffffffffffe
02:00000ef3438a:60:fffffffffffff


02:00000ef3438a:ff:ffffffffffffe
02:00000ef3438a:ff:fffffffffffff
02:00000ef3438a:fe:ffffffffffffe
02:00000ef3438a:fd:ffffffffffffd
02:00000ef3438a:fc:ffffffffffffc
put: [02][eosio][^00000002] -> action234,glob_seq
#put: [01][eosio] -> seq=2,prev=1,prevBlock=1

--

put: [02][eosio][^00000003] -> action345
#put: [01][eosio] -> seq=3

put: [03][ff] -> firstblockofshard: 10000, target: 0 (infinity), block 2_000_000
put: [03][fe] -> firstblockofshard: 5000, target: 9999, block 8000
put: [03][f4] -> firstblockofshard: 1, target: 4999, block 4000

block: 5

put: [02][eosio][^00000004] -> action456
del: [02][eosio][^00000001] -> action123

put: [03] -> block 5

---

put: [04][ff] /* first */ -> block 120M
put: [03][ff] /* last */ -> block 150M

Documentation

Index

Constants

View Source
const (
	DatabaseTimeout = 10 * time.Minute
)

Variables

This section is empty.

Functions

func FacetRangeLowerBound

func FacetRangeLowerBound(facet Facet, lowShardNum byte) (RowKey, RowKey)

func FacetShardRange

func FacetShardRange(facet Facet, shard byte) (RowKey, RowKey)

func ScanFacets

func ScanFacets(
	ctx context.Context,
	kvStore store.KVStore,
	facetCollectionPrefix byte,
	decoder RowKeyDecoderFunc,
	facetFunc FacetHandlerFunc,
) error

Types

type AccountContractFactory

type AccountContractFactory struct {
}

func (*AccountContractFactory) ActionFilter

func (f *AccountContractFactory) ActionFilter(act *pbcodec.ActionTrace) bool

func (*AccountContractFactory) Collection

func (f *AccountContractFactory) Collection() byte

func (*AccountContractFactory) DecodeRow

func (f *AccountContractFactory) DecodeRow(key []byte) (Facet, byte, uint64)

func (*AccountContractFactory) NewCheckpointKey

func (f *AccountContractFactory) NewCheckpointKey(shardNum byte) []byte

func (*AccountContractFactory) NewFacet

func (f *AccountContractFactory) NewFacet(blk *bstream.Block, act *pbcodec.ActionTrace, account uint64) Facet

type AccountContractKey

type AccountContractKey struct {
	// contains filtered or unexported fields
}

func (*AccountContractKey) Account

func (a *AccountContractKey) Account() uint64

func (*AccountContractKey) Bytes

func (a *AccountContractKey) Bytes() []byte

func (*AccountContractKey) Row

func (a *AccountContractKey) Row(shard byte, seqData uint64) RowKey

func (*AccountContractKey) String

func (a *AccountContractKey) String() string

type AccountFacet

type AccountFacet uint64

func (AccountFacet) Account

func (a AccountFacet) Account() uint64

func (AccountFacet) Bytes

func (a AccountFacet) Bytes() []byte

func (AccountFacet) Row

func (a AccountFacet) Row(shard byte, seqData uint64) RowKey

func (AccountFacet) String

func (a AccountFacet) String() string

type AccountFactory

type AccountFactory struct {
}

func (*AccountFactory) ActionFilter

func (f *AccountFactory) ActionFilter(act *pbcodec.ActionTrace) bool

func (*AccountFactory) Collection

func (f *AccountFactory) Collection() byte

func (*AccountFactory) DecodeRow

func (f *AccountFactory) DecodeRow(key []byte) (Facet, byte, uint64)

func (*AccountFactory) NewCheckpointKey

func (f *AccountFactory) NewCheckpointKey(shardNum byte) []byte

func (*AccountFactory) NewFacet

func (f *AccountFactory) NewFacet(blk *bstream.Block, act *pbcodec.ActionTrace, account uint64) Facet

type AccounthistMode

type AccounthistMode string
const (
	AccounthistModeAccount         AccounthistMode = "account"
	AccounthistModeAccountContract AccounthistMode = "account-contract"
)

type Facet

type Facet interface {
	String() string
	Bytes() []byte
	Account() uint64
	// TODO: should replace RowKey with store.Key
	Row(shard byte, seqData uint64) RowKey
}

facet is the key prefix for virtual tables (i.e. 02:account or 03:account:contract)

type FacetFactory

type FacetFactory interface {
	Collection() byte
	NewFacet(blk *bstream.Block, act *pbcodec.ActionTrace, account uint64) Facet
	NewCheckpointKey(shardNum byte) []byte
	DecodeRow(key []byte) (Facet, byte, uint64)
	ActionFilter(act *pbcodec.ActionTrace) bool
}

type FacetHandlerFunc

type FacetHandlerFunc func(facet Facet, shard byte, ordinalNum uint64) error

type KeyEncoderFunc

type KeyEncoderFunc func(blk *bstream.Block, act *pbcodec.ActionTrace, account uint64) Facet

type RowKey

type RowKey []byte

func (RowKey) String

func (k RowKey) String() string

type RowKeyDecoderFunc

type RowKeyDecoderFunc func(key []byte) (Facet, byte, uint64)

type SequenceData

type SequenceData struct {
	CurrentOrdinal     uint64 // while in memory, this value is the last written shard ordinal number that was assisgned
	LastGlobalSeq      uint64 // taken from the top-most action stored in this shard, defines by the chain
	LastDeletedOrdinal uint64 // taken from the top-most action stored in this shard
	MaxEntries         uint64 // initialized with the process' max entries per account, but can be reduced if some more recent shards covered this account
}

func LatestShardSeqDataPerFacet

func LatestShardSeqDataPerFacet(ctx context.Context, kvStore store.KVStore, key Facet, shardNum byte, decoder RowKeyDecoderFunc, unmarshalAction bool) (SequenceData, byte, error)

TODO: this should be under injector

func ShardSeqDataPerFacet

func ShardSeqDataPerFacet(ctx context.Context, kvStore store.KVStore, key Facet, shardNum byte, decoder RowKeyDecoderFunc, unmarshalAction bool) (SequenceData, error)

TODO: this should be under injector

func (*SequenceData) MarshalLogObject

func (sqd *SequenceData) MarshalLogObject(encoder zapcore.ObjectEncoder) error

Directories

Path Synopsis
app

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL