github.com/braveheart12/just@v0.8.7/ledger/recentstorage/recentstorage.go (about) 1 /* 2 * Copyright 2019 Insolar 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package recentstorage 18 19 import ( 20 "context" 21 22 "github.com/insolar/insolar/core" 23 ) 24 25 // Provider provides different types of storages for a specific jet 26 //go:generate minimock -i github.com/insolar/insolar/ledger/recentstorage.Provider -o ./ -s _mock.go 27 type Provider interface { 28 GetIndexStorage(ctx context.Context, jetID core.RecordID) RecentIndexStorage 29 GetPendingStorage(ctx context.Context, jetID core.RecordID) PendingStorage 30 31 Count() int 32 33 CloneIndexStorage(ctx context.Context, fromJetID, toJetID core.RecordID) 34 ClonePendingStorage(ctx context.Context, fromJetID, toJetID core.RecordID) 35 36 DecreaseIndexesTTL(ctx context.Context) map[core.RecordID][]core.RecordID 37 38 RemovePendingStorage(ctx context.Context, id core.RecordID) 39 } 40 41 // RecentIndexStorage is a struct which contains `recent indexes` for a specific jet 42 // `recent index` is a index which was called between TTL-border 43 // If index is put to a recent storage, it'll be there for TTL-pulses at least 44 //go:generate minimock -i github.com/insolar/insolar/ledger/recentstorage.RecentIndexStorage -o ./ -s _mock.go 45 type RecentIndexStorage interface { 46 AddObject(ctx context.Context, id core.RecordID) 47 AddObjectWithTLL(ctx context.Context, id core.RecordID, ttl int) 48 49 GetObjects() map[core.RecordID]int 50 51 DecreaseIndexTTL(ctx context.Context) []core.RecordID 52 53 FilterNotExistWithLock(ctx context.Context, candidates []core.RecordID, fn func(filtered []core.RecordID)) 54 } 55 56 //go:generate minimock -i github.com/insolar/insolar/ledger/recentstorage.PendingStorage -o ./ -s _mock.go 57 type PendingStorage interface { 58 AddPendingRequest(ctx context.Context, obj, req core.RecordID) 59 SetContextToObject(ctx context.Context, obj core.RecordID, objContext PendingObjectContext) 60 61 GetRequests() map[core.RecordID]PendingObjectContext 62 GetRequestsForObject(obj core.RecordID) []core.RecordID 63 64 RemovePendingRequest(ctx context.Context, obj, req core.RecordID) 65 }