beelite

package module
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: Apache-2.0 Imports: 107 Imported by: 1

README

bee-lite

Go Reference

bee-lite is an embeddable, lightweight bee node for applications to use swarm directly

How to run

lo := &beelite.LiteOptions {
    FullNodeMode:             false,
    BootnodeMode:             false,
    Bootnodes:                []string{"/dnsaddr/mainnet.ethswarm.org"},
    StaticNodes:              []string{<STATIC_NODE_ADDRESSES>},
    DataDir:                  dataDir,
    WelcomeMessage:           "Welcome from bee-lite by Solar Punk",
    BlockchainRpcEndpoint:    <RPC_ENDPOINT>,
    SwapInitialDeposit:       "10000000000000000",
    PaymentThreshold:         "100000000",
    SwapEnable:               true,
    ChequebookEnable:         true,
    DebugAPIEnable:           false,
    UsePostageSnapshot:       false,
    Mainnet:                  true,
    NetworkID:                1,
    NATAddr:                  "<NAT_ADDRESS>:<PORT>",
    CacheCapacity:            32 * 1024 * 1024,
    DBOpenFilesLimit:         50,
    DBWriteBufferSize:        32 * 1024 * 1024,
    DBBlockCacheCapacity:     32 * 1024 * 1024,
    DBDisableSeeksCompaction: false,
    RetrievalCaching:         true,
}

const loglevel = "4"
bl, err := beelite.Start(lo, password, loglevel)
if err != nil {
    return err
}

Development for mobile using gomobile

Requirements

Go version 1.24.2 Gomobile require JDK 1.8 or later

Installation
  1. Install golang. Recommend goenv.

  2. Install JDK - version 17. Recommend SDKMAN.

  3. Install Android Studio for easy SDK/NDK management. Android 16 - Api 36 installed with NDK 29.0.14206865

  4. Example env var config:

    GOROOT=/Users/YOUR_USERNAME/.goenv/versions/1.24.2
    GOPATH=/Users/YOUR_USERNAME/go/1.24.2
    ANDROID_HOME=/Users/YOUR_USERNAME/Library/Android/sdk
    ANDROID_NDK_HOME=/Users/YOUR_USERNAME/Library/Android/sdk/ndk/29.0.14206865
    SDKMAN_DIR=/Users/YOUR_USERNAME/.sdkman
    SDKMAN_CANDIDATES_API=https://api.sdkman.io/2
    SDKMAN_BROKER_API=https://broker.sdkman.io
    SDKMAN_PLATFORM=darwinarm64
    SDKMAN_CANDIDATES_DIR=/Users/YOUR_USERNAME/.sdkman/candidates
    binary_input=/Users/YOUR_USERNAME/.sdkman/tmp/java-17.0.12-tem.bin
    

Development for Android platform

Android has networking restrictions since API 30+ so to make libp2p work tweaks required on the Go repository that will be used to compile the code. Follow the steps to solve this known issues.

Based on the following github issues: dnsconfig_unix.go netlink_linux.go, interface_linux.go

  1. Copy the _android files under the net/ and syscall/ subfolders of this repo to their respective folders under your go installation, e.g.:

    cp ./patch/net/* /Users/username/.goenv/versions/1.24.2/src/net/
    cp ./patch/syscall/* /Users/username/.goenv/versions/1.24.2/src/syscall/
    
  2. Furthermore, open and add the following build directives to the existing dnsconfig_unix, interface_linux, netlink_linux files:

    //go:build !android
    

    or if a windows exclusion exists add android like this

    //go:build !windows && !android
    

    So when compiling go code to android target the newly added sources will run and those have fixes for the issues above.

  3. To make these changes effect you should recompile the go binaries from the modified sources above - with the newly added *_android files .

    For this go to source folder root /Users/username/.goenv/versions/1.24.2/src/ for example. Search for make.bash and open it. Search for 'bootgo' in this file. That version is required to compile the target Go version. Install it and point GOROOT_BOOTSTRAP to that GOROOT like GOROOT_BOOTSTRAP=/Users/username/.goenv/versions/1.22.6 on Mac. After this run make.bash and it should compile the distro

Compile with gomobile for Android

Target android api 21 is a nice sweet spot because it is Android Version: 5.0 (Lollipop) which is widely supported.

First you need gomobile and bind

go install golang.org/x/mobile/cmd/gomobile@latest
go get golang.org/x/mobile/bind

In the root of this project run gomobile init

Run the following:

gomobile bind -target=android -androidapi=21 -o bee-lite.aar

Important notes

  • gomobile has serious type limitation thats why complex types cannot be exported to the Java / JNI bridge easily. For details check these type restrictions section.
  • gomobile will export the public fields of the directory where it is executed! Of course the other and referenced code will work in the binary but those sources wont be visible in the .jar as .Java classes

Other references

The output can be used in Android or in React Native code (with Bridging)

Documentation

Index

Constants

View Source
const (
	ContentTypeHeader   = "Content-Type"
	ContentLengthHeader = "Content-Length"
)
View Source
const (
	LoggerName = "beelite"
)
View Source
const (
	ReserveCapacity = 4_194_304 // 2^22 chunks

)
View Source
const (
	TopicLength = 32
)

Variables

View Source
var ErrFailedToGetBzzReference = errors.New("failed to get bzz reference")
View Source
var ErrShutdownInProgress error = errors.New("shutdown in progress")

Functions

This section is empty.

Types

type Bee

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

func (*Bee) Shutdown

func (b *Bee) Shutdown() error

func (*Bee) SyncingStopped

func (b *Bee) SyncingStopped() chan struct{}

type Beelite

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

func NewBee

func NewBee(
	ctx context.Context,
	addr string,
	publicKey *ecdsa.PublicKey,
	signer crypto.Signer,
	networkID uint64,
	logger log.Logger,
	libp2pPrivateKey,
	pssPrivateKey *ecdsa.PrivateKey,
	session accesscontrol.Session,
	o *node.Options,
) (bl *Beelite, err error)

func Start

func Start(lo *LiteOptions, password string, verbosity string) (bl *Beelite, errMain error)

func (*Beelite) AddBytes

func (bl *Beelite) AddBytes(parentContext context.Context,
	batchHex string,
	act bool,
	historyAddress swarm.Address,
	encrypt bool,
	rLevel redundancy.Level,
	reader io.Reader,
) (reference swarm.Address, newHistoryAddress swarm.Address, err error)

func (*Beelite) AddChunk

func (bl *Beelite) AddChunk(parentContext context.Context,
	batchHex string,
	stampSig []byte,
	act bool,
	historyAddress swarm.Address,
	reader io.Reader,
	swarmTag uint64,
) (reference swarm.Address, newHistoryAddress swarm.Address, err error)

func (*Beelite) AddDirBzz added in v0.0.3

func (bl *Beelite) AddDirBzz(
	parentContext context.Context,
	batchHex,
	filename,
	contentType,
	indexFilename,
	errorFilename string,
	act bool,
	historyAddress swarm.Address,
	encrypt bool,
	rLevel redundancy.Level,
	reader io.Reader,
) (reference swarm.Address, newHistoryAddress swarm.Address, err error)

func (*Beelite) AddFeed

func (bl *Beelite) AddFeed(ctx context.Context,
	batchHex,
	owner,
	topic string,
	act bool,
	historyAddress swarm.Address,
	encrypt bool,
	rLevel redundancy.Level,
) (reference swarm.Address, newHistoryAddress swarm.Address, err error)

func (*Beelite) AddFileBzz

func (bl *Beelite) AddFileBzz(parentContext context.Context,
	batchHex,
	filename,
	contentType string,
	act bool,
	historyAddress swarm.Address,
	encrypt bool,
	rLevel redundancy.Level,
	reader io.Reader,
) (reference swarm.Address, newHistoryAddress swarm.Address, err error)

func (*Beelite) AddRevokeGrantees added in v0.0.5

func (bl *Beelite) AddRevokeGrantees(ctx context.Context, batchHex string, granteesAddress swarm.Address, historyAddress swarm.Address, addlist, revokelist []string) (swarm.Address, swarm.Address, error)

func (*Beelite) AddSOC

func (bl *Beelite) AddSOC(ctx context.Context,
	batchHex string,
	stampSig []byte,
	act bool,
	historyAddress swarm.Address,
	reader io.Reader,
	id []byte,
	owner []byte,
	sig []byte,
) (reference swarm.Address, newHistoryAddress swarm.Address, err error)

func (*Beelite) BeeNodeMode added in v0.0.3

func (bl *Beelite) BeeNodeMode() api.BeeNodeMode

func (*Beelite) BuyStamp

func (bl *Beelite) BuyStamp(amount *big.Int, depth uint64, label string, immutable bool) (common.Hash, []byte, error)

func (*Beelite) ChequebookAddr

func (bl *Beelite) ChequebookAddr() common.Address

func (*Beelite) ChequebookBalance

func (bl *Beelite) ChequebookBalance() (*big.Int, error)

func (*Beelite) ChequebookWithdraw

func (bl *Beelite) ChequebookWithdraw(amount *big.Int) (common.Hash, error)

func (*Beelite) ConnectedPeerCount added in v0.0.3

func (bl *Beelite) ConnectedPeerCount() int

func (*Beelite) CreateGrantees added in v0.0.5

func (bl *Beelite) CreateGrantees(ctx context.Context, batchHex string, historyAddress swarm.Address, granteeList []string) (swarm.Address, swarm.Address, error)

func (*Beelite) GetAllBatches

func (bl *Beelite) GetAllBatches() []*postage.StampIssuer

func (*Beelite) GetBytes

func (bl *Beelite) GetBytes(parentContext context.Context, reference swarm.Address, publisher *ecdsa.PublicKey, historyAddress *swarm.Address, timestamp *int64) (io.Reader, error)

func (*Beelite) GetBzz

func (bl *Beelite) GetBzz(parentContext context.Context, address swarm.Address, publisher *ecdsa.PublicKey, historyAddress *swarm.Address, timestamp *int64) (io.Reader, string, error)

func (*Beelite) GetChunk

func (bl *Beelite) GetChunk(parentContext context.Context, reference swarm.Address, publisher *ecdsa.PublicKey, historyAddress *swarm.Address, timestamp *int64) (swarm.Chunk, error)

func (*Beelite) GetGranteeList added in v0.0.5

func (bl *Beelite) GetGranteeList(ctx context.Context, encryptedglRef swarm.Address, cache bool) ([]string, error)

func (*Beelite) GetLogger added in v0.0.11

func (bl *Beelite) GetLogger() beelog.Logger

func (*Beelite) GetUsableBatches

func (bl *Beelite) GetUsableBatches() []*postage.StampIssuer

func (*Beelite) OverlayEthAddress added in v0.0.2

func (bl *Beelite) OverlayEthAddress() common.Address

func (*Beelite) Shutdown added in v0.0.11

func (bl *Beelite) Shutdown() error

func (*Beelite) TransactionService added in v0.0.7

func (bl *Beelite) TransactionService() transaction.Service

type FileInfo added in v0.0.3

type FileInfo struct {
	Path        string
	Name        string
	ContentType string
	Size        int64
	Reader      io.Reader
}

type LiteOptions added in v0.0.2

type LiteOptions struct {
	FullNodeMode             bool
	BootnodeMode             bool
	Bootnodes                []string
	StaticNodes              []string
	DataDir                  string
	WelcomeMessage           string
	BlockchainRpcEndpoint    string
	SwapInitialDeposit       string
	PaymentThreshold         string
	SwapEnable               bool
	ChequebookEnable         bool
	UsePostageSnapshot       bool
	Mainnet                  bool
	NetworkID                uint64
	NATAddr                  string
	CacheCapacity            uint64
	DBOpenFilesLimit         uint64
	DBWriteBufferSize        uint64
	DBBlockCacheCapacity     uint64
	DBDisableSeeksCompaction bool
	RetrievalCaching         bool
}

type SnapshotGetter added in v0.0.10

type SnapshotGetter interface {
	GetBatchSnapshot() []byte
}

type SnapshotLogFilterer added in v0.0.10

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

func NewSnapshotLogFilterer added in v0.0.10

func NewSnapshotLogFilterer(logger log.Logger, getter SnapshotGetter) *SnapshotLogFilterer

func (*SnapshotLogFilterer) BlockNumber added in v0.0.10

func (f *SnapshotLogFilterer) BlockNumber(_ context.Context) (uint64, error)

func (*SnapshotLogFilterer) FilterLogs added in v0.0.10

func (f *SnapshotLogFilterer) FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error)

type Topic

type Topic [TopicLength]byte

Jump to

Keyboard shortcuts

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