You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+6-12Lines changed: 6 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,7 +70,6 @@ To use the `entrypoint!` macro, use the following in your entrypoint definition:
70
70
usepinocchio::{
71
71
account::AccountView,
72
72
entrypoint,
73
-
msg,
74
73
ProgramResult,
75
74
Address
76
75
};
@@ -82,7 +81,6 @@ pub fn process_instruction(
82
81
accounts:&[AccountView],
83
82
instruction_data:&[u8],
84
83
) ->ProgramResult {
85
-
msg!("Hello from my program!");
86
84
Ok(())
87
85
}
88
86
```
@@ -114,7 +112,6 @@ use pinocchio::{
114
112
default_panic_handler,
115
113
entrypoint::InstructionContext,
116
114
lazy_program_entrypoint,
117
-
msg,
118
115
ProgramResult
119
116
};
120
117
@@ -125,7 +122,6 @@ default_panic_handler!();
125
122
pubfnprocess_instruction(
126
123
mutcontext:InstructionContext
127
124
) ->ProgramResult {
128
-
msg!("Hello from my lazy program!");
129
125
Ok(())
130
126
}
131
127
```
@@ -149,7 +145,6 @@ To use the `no_allocator!` macro, use the following in your entrypoint definitio
149
145
usepinocchio::{
150
146
account::AccountView,
151
147
default_panic_handler,
152
-
msg,
153
148
no_allocator,
154
149
program_entrypoint,
155
150
ProgramResult,
@@ -165,7 +160,6 @@ pub fn process_instruction(
165
160
accounts:&[AccountView],
166
161
instruction_data:&[u8],
167
162
) ->ProgramResult {
168
-
msg!("Hello from `no_std` program!");
169
163
Ok(())
170
164
}
171
165
```
@@ -174,13 +168,15 @@ pub fn process_instruction(
174
168
175
169
## Crate feature: `std`
176
170
177
-
By default, `pinocchio` is a `no_std` crate. This means that it does not use any code from the standard (`std`) library. While this does not affect how `pinocchio` is used, there is one particular apparent difference. In a `no_std` environment, the `msg!` macro does not provide any formatting options since the `format!` macro requires the `std` library. In order to use `msg!` with formatting, the `std` feature should be enabled when adding `pinocchio` as a dependency:
171
+
By default, Pinocchio is a `no_std` crate. This means that it does not use any code from the
172
+
standard (`std`) library. While this does not affect how Pinocchio is used, there is a one
173
+
particular apparent difference. Helpers that need to allocate memory, such as fetching `SlotHashes`
174
+
sysvar data, are not available. To enable these helpers, the `std` feature must be enabled when adding
175
+
Pinocchio as a dependency:
178
176
```
179
-
pinocchio = { version = "0.7.0", features = ["std"] }
177
+
pinocchio = { version = "0.10.0", features = ["std"] }
180
178
```
181
179
182
-
Instead of enabling the `std` feature to be able to format log messages with `msg!`, it is recommended to use the [`pinocchio-log`](https://crates.io/crates/pinocchio-log) crate. This crate provides a lightweight `log!` macro with better compute units consumption than the standard `format!` macro without requiring the `std` library.
183
-
184
180
## Advance entrypoint configuration
185
181
186
182
The symbols emitted by the entrypoint macros — program entrypoint, global allocator and default panic handler — can only be defined once globally. If the program crate is also intended to be used as a library, it is common practice to define a Cargo [feature](https://doc.rust-lang.org/cargo/reference/features.html) in your program crate to conditionally enable the module that includes the `entrypoint!` macro invocation. The convention is to name the feature `bpf-entrypoint`.
0 commit comments