-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sample Go FFI bindings for freezer reads
- Loading branch information
Showing
8 changed files
with
849 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use std::env; | ||
use std::path::PathBuf; | ||
use std::process::Command; | ||
|
||
fn main() { | ||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); | ||
|
||
let mut go_build = Command::new("go"); | ||
go_build | ||
.arg("build") | ||
.arg("-buildmode=c-archive") | ||
.arg("-o") | ||
.arg(out_path.join("libfreezer.a")) | ||
.arg("./geth-bind/freezer.go"); | ||
|
||
go_build.status().expect("Go build failed"); | ||
|
||
println!("cargo:rerun-if-changed=./geth-bind/freezer.go"); | ||
println!( | ||
"cargo:rustc-link-search=native={}", | ||
out_path.to_str().unwrap() | ||
); | ||
println!("cargo:rustc-link-lib=static=freezer"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Go output | ||
out/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
all: | ||
go build -buildmode=c-archive -o out/libfreezer.so |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package main | ||
|
||
/* | ||
#include <stdlib.h> | ||
*/ | ||
import "C" | ||
import "unsafe" | ||
|
||
// import ( | ||
// "github.com/ethereum/go-ethereum/core/rawdb" | ||
// ) | ||
|
||
//export FetchReceipts | ||
func FetchReceipts() *C.char { | ||
return C.CString("hi from the freezer") | ||
} | ||
|
||
//export GoFree | ||
func GoFree(ptr *C.char) { | ||
C.free(unsafe.Pointer(ptr)) | ||
} | ||
|
||
func main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
module anton.systems/geth-freezer-bindings | ||
|
||
go 1.21.4 | ||
|
||
require github.com/ethereum/go-ethereum v1.13.5 | ||
|
||
require ( | ||
github.com/DataDog/zstd v1.4.5 // indirect | ||
github.com/StackExchange/wmi v1.2.1 // indirect | ||
github.com/beorn7/perks v1.0.1 // indirect | ||
github.com/bits-and-blooms/bitset v1.7.0 // indirect | ||
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect | ||
github.com/cespare/xxhash/v2 v2.2.0 // indirect | ||
github.com/cockroachdb/errors v1.8.1 // indirect | ||
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f // indirect | ||
github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 // indirect | ||
github.com/cockroachdb/redact v1.0.8 // indirect | ||
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 // indirect | ||
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect | ||
github.com/consensys/bavard v0.1.13 // indirect | ||
github.com/consensys/gnark-crypto v0.12.1 // indirect | ||
github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect | ||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect | ||
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect | ||
github.com/go-ole/go-ole v1.2.5 // indirect | ||
github.com/go-stack/stack v1.8.1 // indirect | ||
github.com/gofrs/flock v0.8.1 // indirect | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/golang/protobuf v1.5.3 // indirect | ||
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect | ||
github.com/holiman/uint256 v1.2.3 // indirect | ||
github.com/klauspost/compress v1.15.15 // indirect | ||
github.com/kr/pretty v0.3.1 // indirect | ||
github.com/kr/text v0.2.0 // indirect | ||
github.com/mattn/go-runewidth v0.0.13 // indirect | ||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect | ||
github.com/mmcloughlin/addchain v0.4.0 // indirect | ||
github.com/olekukonko/tablewriter v0.0.5 // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/prometheus/client_golang v1.12.0 // indirect | ||
github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a // indirect | ||
github.com/prometheus/common v0.32.1 // indirect | ||
github.com/prometheus/procfs v0.7.3 // indirect | ||
github.com/rivo/uniseg v0.2.0 // indirect | ||
github.com/rogpeppe/go-internal v1.9.0 // indirect | ||
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect | ||
github.com/supranational/blst v0.3.11 // indirect | ||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect | ||
github.com/tklauser/go-sysconf v0.3.12 // indirect | ||
github.com/tklauser/numcpus v0.6.1 // indirect | ||
golang.org/x/crypto v0.14.0 // indirect | ||
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect | ||
golang.org/x/sync v0.3.0 // indirect | ||
golang.org/x/sys v0.13.0 // indirect | ||
google.golang.org/protobuf v1.27.1 // indirect | ||
rsc.io/tmplfunc v0.0.3 // indirect | ||
) |
Oops, something went wrong.