tangled
alpha
login
or
join now
gbl08ma.com
/
didplcbft
24
fork
atom
A very experimental PLC implementation which uses BFT consensus for decentralization
24
fork
atom
overview
issues
pulls
pipelines
Fine-tuning
gbl08ma.com
2 months ago
562e402d
d65facfb
verified
This commit was signed with the committer's
known signature
.
gbl08ma.com
SSH Key Fingerprint:
SHA256:NkaTDGnGWRZlEnrKxt4ih8fpbNEuHeYdbkJk7VYd+1o=
+12
-5
3 changed files
expand all
collapse all
unified
split
abciapp
app.go
execution.go
main.go
+2
-2
abciapp/app.go
···
37
func NewDIDPLCApplication(badgerDB *badger.DB, snapshotDirectory string) (*DIDPLCApplication, plc.PLC, func(), error) {
38
treePrefix := []byte{}
39
mkTree := func() *iavl.MutableTree {
40
-
return iavl.NewMutableTree(badgeradapter.AdaptBadger(badgerDB, treePrefix), 2048, false, iavl.NewNopLogger(), iavl.AsyncPruningOption(true))
41
}
42
43
tree := mkTree()
···
102
case <-time.After(5 * time.Minute):
103
}
104
treeVersion := tree.Version()
105
-
if treeVersion > int64(lastSnapshotVersion+1000) {
106
err = d.createSnapshot(treeVersion, filepath.Join(snapshotDirectory, "snapshot.tmp"))
107
if err != nil {
108
fmt.Println("FAILED TO TAKE SNAPSHOT", stacktrace.Propagate(err, ""))
···
37
func NewDIDPLCApplication(badgerDB *badger.DB, snapshotDirectory string) (*DIDPLCApplication, plc.PLC, func(), error) {
38
treePrefix := []byte{}
39
mkTree := func() *iavl.MutableTree {
40
+
return iavl.NewMutableTree(badgeradapter.AdaptBadger(badgerDB, treePrefix), 2048, false, iavl.NewNopLogger(), iavl.AsyncPruningOption(false))
41
}
42
43
tree := mkTree()
···
102
case <-time.After(5 * time.Minute):
103
}
104
treeVersion := tree.Version()
105
+
if treeVersion > int64(lastSnapshotVersion+10000) {
106
err = d.createSnapshot(treeVersion, filepath.Join(snapshotDirectory, "snapshot.tmp"))
107
if err != nil {
108
fmt.Println("FAILED TO TAKE SNAPSHOT", stacktrace.Propagate(err, ""))
+3
-2
abciapp/execution.go
···
5
"context"
6
"fmt"
7
"slices"
0
8
"time"
9
10
abcitypes "github.com/cometbft/cometbft/abci/types"
···
214
}
215
}
216
217
-
minHeightToKeep := max(newVersion-100, 0)
218
minVerToKeep := max(minHeightToKeep-5, 0)
219
if minVerToKeep > 0 {
220
err = d.tree.DeleteVersionsTo(minVerToKeep)
221
-
if err != nil {
222
return nil, stacktrace.Propagate(err, "")
223
}
224
}
···
5
"context"
6
"fmt"
7
"slices"
8
+
"strings"
9
"time"
10
11
abcitypes "github.com/cometbft/cometbft/abci/types"
···
215
}
216
}
217
218
+
minHeightToKeep := max(newVersion-5, 0)
219
minVerToKeep := max(minHeightToKeep-5, 0)
220
if minVerToKeep > 0 {
221
err = d.tree.DeleteVersionsTo(minVerToKeep)
222
+
if err != nil && !strings.Contains(err.Error(), "active readers") {
223
return nil, stacktrace.Propagate(err, "")
224
}
225
}
+7
-1
main.go
···
55
badgerDBPath := filepath.Join(homeDir, "badger")
56
badgerDB, err := badger.Open(badger.
57
DefaultOptions(badgerDBPath).
0
58
WithBlockSize(8 * 1024).
59
WithNumMemtables(3).
60
WithNumLevelZeroTables(3).
61
-
WithCompression(options.ZSTD))
62
if err != nil {
63
log.Fatalf("Opening badger database: %v", err)
64
}
···
66
for err == nil {
67
err = badgerDB.RunValueLogGC(0.5)
68
}
0
0
0
0
0
69
70
var wg sync.WaitGroup
71
closeGoroutinesCh := make(chan struct{})
···
55
badgerDBPath := filepath.Join(homeDir, "badger")
56
badgerDB, err := badger.Open(badger.
57
DefaultOptions(badgerDBPath).
58
+
WithBlockCacheSize(2 << 30).
59
WithBlockSize(8 * 1024).
60
WithNumMemtables(3).
61
WithNumLevelZeroTables(3).
62
+
WithCompression(options.Snappy))
63
if err != nil {
64
log.Fatalf("Opening badger database: %v", err)
65
}
···
67
for err == nil {
68
err = badgerDB.RunValueLogGC(0.5)
69
}
70
+
71
+
/*err = badgerDB.Flatten(4)
72
+
if err != nil {
73
+
log.Fatalf("Flattening badger database: %v", err)
74
+
}*/
75
76
var wg sync.WaitGroup
77
closeGoroutinesCh := make(chan struct{})